diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2016-03-10 15:26:32 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2016-03-10 15:26:32 +0800 |
commit | 5080cbf9fd26441256390f169d24ab3259c740f7 (patch) | |
tree | c4e48a7774e77a75b56dfd6a97e17d16de4c0f83 | |
parent | 98801241965ff81afd68392df52e38a54d49ded2 (diff) |
[facebook] Handle escaped swf params
Fixes #8713
-rw-r--r-- | youtube_dl/extractor/facebook.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/youtube_dl/extractor/facebook.py b/youtube_dl/extractor/facebook.py index b354c5521..49231d3e9 100644 --- a/youtube_dl/extractor/facebook.py +++ b/youtube_dl/extractor/facebook.py @@ -103,6 +103,15 @@ class FacebookIE(InfoExtractor): 'uploader': 'S. Saint', }, }, { + 'note': 'swf params escaped', + 'url': 'https://www.facebook.com/barackobama/posts/10153664894881749', + 'md5': '97ba073838964d12c70566e0085c2b91', + 'info_dict': { + 'id': '10153664894881749', + 'ext': 'mp4', + 'title': 'Facebook video #10153664894881749', + }, + }, { 'url': 'https://www.facebook.com/video.php?v=10204634152394104', 'only_matching': True, }, { @@ -189,11 +198,12 @@ class FacebookIE(InfoExtractor): video_data = None - BEFORE = '{swf.addParam(param[0], param[1]);});\n' + BEFORE = '{swf.addParam(param[0], param[1]);});' AFTER = '.forEach(function(variable) {swf.addVariable(variable[0], variable[1]);});' - m = re.search(re.escape(BEFORE) + '(.*?)' + re.escape(AFTER), webpage) + m = re.search(re.escape(BEFORE) + '(?:\n|\\\\n)(.*?)' + re.escape(AFTER), webpage) if m: - data = dict(json.loads(m.group(1))) + swf_params = m.group(1).replace('\\\\', '\\').replace('\\"', '"') + data = dict(json.loads(swf_params)) params_raw = compat_urllib_parse_unquote(data['params']) video_data = json.loads(params_raw)['video_data'] |