From f0c64c69c39fb6892a52e0a4ca0384b8f77fe07d Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 12 Feb 2015 02:18:27 +0100 Subject: Add another form of YouTube links --- plugins/youtube | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/youtube b/plugins/youtube index 48fa824..65f7ce1 100755 --- a/plugins/youtube +++ b/plugins/youtube @@ -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) -- cgit v1.2.3-70-g09d2