From 57e5a1fddc6bce475859fc5a1c7c8e64eca87be6 Mon Sep 17 00:00:00 2001 From: chantzish Date: Tue, 19 Sep 2023 11:35:08 +0300 Subject: [PATCH 1/2] Fix: [Facebook] Cannot parse data The internal structure for the video urls seems to have been changed --- youtube_dl/extractor/facebook.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/facebook.py b/youtube_dl/extractor/facebook.py index 04650af39..c5d24b642 100644 --- a/youtube_dl/extractor/facebook.py +++ b/youtube_dl/extractor/facebook.py @@ -420,12 +420,12 @@ class FacebookIE(InfoExtractor): def extract_relay_data(_filter): return self._parse_json(self._search_regex( - r'handleWithCustomApplyEach\([^,]+,\s*({.*?%s.*?})\);' % _filter, + [r'handleWithCustomApplyEach\([^,]+,\s*({.*?%s.*?})\);' % _filter, r'(.*?%s.*?)' % _filter], webpage, 'replay data', default='{}'), video_id, fatal=False) or {} def extract_relay_prefetched_data(_filter): replay_data = extract_relay_data(_filter) - for require in (replay_data.get('require') or []): + for require in ((replay_data.get('require') or []) + (try_get(replay_data, lambda x: x['require'][0][3][0]['__bbox']['require'], list) or [])): if require[0] == 'RelayPrefetchedStreamCache': return try_get(require, lambda x: x[3][1]['__bbox']['result']['data'], dict) or {} @@ -446,7 +446,7 @@ class FacebookIE(InfoExtractor): formats = [] q = qualities(['sd', 'hd']) for (suffix, format_id) in [('', 'sd'), ('_quality_hd', 'hd')]: - playable_url = video.get('playable_url' + suffix) + playable_url = video.get('playable_url' + suffix) or video.get('browser_native_'+format_id+'_url') if not playable_url: continue formats.append({ From 060ea59fb10a906719909f54deb3cec439b2e917 Mon Sep 17 00:00:00 2001 From: chantzish Date: Tue, 19 Sep 2023 13:52:25 +0300 Subject: [PATCH 2/2] Fix: [Facebook] download failure when there is no dash_manifest --- youtube_dl/extractor/facebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/facebook.py b/youtube_dl/extractor/facebook.py index c5d24b642..e154c7f5a 100644 --- a/youtube_dl/extractor/facebook.py +++ b/youtube_dl/extractor/facebook.py @@ -438,7 +438,7 @@ class FacebookIE(InfoExtractor): if not video_data: data = extract_relay_prefetched_data( - r'"(?:dash_manifest|playable_url(?:_quality_hd)?)"\s*:\s*"[^"]+"') + r'"(?:dash_manifest|playable_url(?:_quality_hd)?|browser_native_(?:sd|hd)_url)"\s*:\s*"[^"]+"') if data: entries = []