From 9f43890bcd6bf6c0bf75e0ec748d29dc9b01dab5 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Wed, 23 Jul 2014 02:13:48 +0200 Subject: [PATCH] [jsinterp] Allow digits in function names --- test/test_youtube_signature.py | 6 ++++++ youtube_dl/jsinterp.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index e8a67c4c0..f0f33f1db 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -57,6 +57,12 @@ _TESTS = [ u'F375F75BF2AFDAAF2666E43868D46816F83F13E81C46.3725A8218E446A0DECD33F79DC282994D6AA92C92C9', u'9C29AA6D499282CD97F33DCED0A644E8128A5273.64C18E31F38361864D86834E6662FAADFA2FB57F' ), + ( + u'https://s.ytimg.com/yts/jsbin/html5player-en_US-vflBb0OQx.js', + u'js', + 84, + u'123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ0STUVWXYZ!"#$%&\'()*+,@./:;<=>' + ) ] diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index ae5bca2e6..13ad5ba1a 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -114,13 +114,13 @@ class JSInterpreter(object): obj = {} obj_m = re.search( (r'(?:var\s+)?%s\s*=\s*\{' % re.escape(objname)) + - r'\s*(?P([a-zA-Z$]+\s*:\s*function\(.*?\)\s*\{.*?\})*)' + + r'\s*(?P([a-zA-Z$0-9]+\s*:\s*function\(.*?\)\s*\{.*?\})*)' + r'\}\s*;', self.code) fields = obj_m.group('fields') # Currently, it only supports function definitions fields_m = re.finditer( - r'(?P[a-zA-Z$]+)\s*:\s*function' + r'(?P[a-zA-Z$0-9]+)\s*:\s*function' r'\((?P[a-z,]+)\){(?P[^}]+)}', fields) for f in fields_m: -- 2.22.2