Add another form of YouTube links
This commit is contained in:
parent
e8fe0dad81
commit
f0c64c69c3
|
@ -51,8 +51,11 @@ if youtube_api_key == "":
|
||||||
|
|
||||||
print ("ZYKLONB register")
|
print ("ZYKLONB register")
|
||||||
|
|
||||||
re_link_1 = re.compile ('youtube\\.[a-z]+/[^ ]*[&?]v=([-_A-Za-z0-9]+)')
|
regexes = map (lambda x: re.compile (x), [
|
||||||
re_link_2 = re.compile ('youtu\\.be/([-_A-Za-z0-9]+)')
|
'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):
|
def print_video_info (channel, video_id):
|
||||||
global youtube_api_key
|
global youtube_api_key
|
||||||
|
@ -88,7 +91,6 @@ for line in sys.stdin:
|
||||||
if not ctx.startswith (('#', '+', '&', '!')):
|
if not ctx.startswith (('#', '+', '&', '!')):
|
||||||
ctx = nick
|
ctx = nick
|
||||||
|
|
||||||
for i in re_link_1.findall (args[1]):
|
for regex in regexes:
|
||||||
print_video_info (ctx, i)
|
for i in regex.findall (args[1]):
|
||||||
for i in re_link_2.findall (args[1]):
|
print_video_info (ctx, i)
|
||||||
print_video_info (ctx, i)
|
|
||||||
|
|
Loading…
Reference in New Issue