Add another form of YouTube links

This commit is contained in:
Přemysl Eric Janouch 2015-02-12 02:18:27 +01:00
parent e8fe0dad81
commit f0c64c69c3

View File

@ -51,8 +51,11 @@ if youtube_api_key == "":
print ("ZYKLONB register")
re_link_1 = re.compile ('youtube\\.[a-z]+/[^ ]*[&?]v=([-_A-Za-z0-9]+)')
re_link_2 = re.compile ('youtu\\.be/([-_A-Za-z0-9]+)')
regexes = map (lambda x: re.compile (x), [
'youtube\\.[a-z]+/[^ ]*[&?]v=([-_A-Za-z0-9]+)',
'youtube\\.[a-z]+/v/([-_A-Za-z0-9]+)',
'youtu\\.be/([-_A-Za-z0-9]+)'
])
def print_video_info (channel, video_id):
global youtube_api_key
@ -88,7 +91,6 @@ for line in sys.stdin:
if not ctx.startswith (('#', '+', '&', '!')):
ctx = nick
for i in re_link_1.findall (args[1]):
print_video_info (ctx, i)
for i in re_link_2.findall (args[1]):
print_video_info (ctx, i)
for regex in regexes:
for i in regex.findall (args[1]):
print_video_info (ctx, i)