summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-12 02:18:27 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-12 02:18:27 +0100
commitf0c64c69c39fb6892a52e0a4ca0384b8f77fe07d (patch)
treec6db99d672e075a22ef470e3dc736151ee64017d /plugins
parente8fe0dad81378920c6c537013f8759dfe9144bac (diff)
downloadxK-f0c64c69c39fb6892a52e0a4ca0384b8f77fe07d.tar.gz
xK-f0c64c69c39fb6892a52e0a4ca0384b8f77fe07d.tar.xz
xK-f0c64c69c39fb6892a52e0a4ca0384b8f77fe07d.zip
Add another form of YouTube links
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/youtube14
1 files 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)