diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2017-05-26 21:58:18 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2017-05-26 21:58:18 +0800 |
commit | 5552c9eb0fece567f7dda13810939fca32d7d65a (patch) | |
tree | f3bde11319d42fbe7013dc1326c83ad799c39892 /youtube_dl | |
parent | 59ed87cbd9ea08c889514a05b646141004f432a1 (diff) |
[utils] Recognize more patterns in strip_jsonp()
Used in Youku Show pages
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 4293a77f5..6c84bfe0f 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2211,7 +2211,12 @@ def parse_age_limit(s): def strip_jsonp(code): return re.sub( - r'(?s)^[a-zA-Z0-9_.$]+\s*\(\s*(.*)\);?\s*?(?://[^\n]*)*$', r'\1', code) + r'''(?sx)^ + (?:window\.)?(?P<func_name>[a-zA-Z0-9_.$]+) + (?:\s*&&\s*(?P=func_name))? + \s*\(\s*(?P<callback_data>.*)\);? + \s*?(?://[^\n]*)*$''', + r'\g<callback_data>', code) def js_to_json(code): |