[jsinterp] Allow digits in function names
authorPhilipp Hagemeister <phihag@phihag.de>
Wed, 23 Jul 2014 00:13:48 +0000 (02:13 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Wed, 23 Jul 2014 00:13:48 +0000 (02:13 +0200)
test/test_youtube_signature.py
youtube_dl/jsinterp.py

index e8a67c4c0141efad9d6475af7835a8ee2fd95697..f0f33f1db2643b6eeb1c4b82202e071c40f826fb 100644 (file)
@@ -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!"#$%&\'()*+,@./:;<=>'
+    )
 ]
 
 
index ae5bca2e643f1ec4d719e8e895b0a655a98a151a..13ad5ba1a32f0a57e1f49a078a50dbdca698342e 100644 (file)
@@ -114,13 +114,13 @@ class JSInterpreter(object):
         obj = {}
         obj_m = re.search(
             (r'(?:var\s+)?%s\s*=\s*\{' % re.escape(objname)) +
-            r'\s*(?P<fields>([a-zA-Z$]+\s*:\s*function\(.*?\)\s*\{.*?\})*)' +
+            r'\s*(?P<fields>([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<key>[a-zA-Z$]+)\s*:\s*function'
+            r'(?P<key>[a-zA-Z$0-9]+)\s*:\s*function'
             r'\((?P<args>[a-z,]+)\){(?P<code>[^}]+)}',
             fields)
         for f in fields_m: