From ec9b25043f399de6a591d8370d32bf0e66c117f2 Mon Sep 17 00:00:00 2001 From: kclauhk <78251477+kclauhk@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:36:09 +0800 Subject: [PATCH] [ie/facebook] Fix formats extraction (#11343) Closes #11337 Authored by: kclauhk --- yt_dlp/extractor/facebook.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/facebook.py b/yt_dlp/extractor/facebook.py index 1adb35b5f..2bcb5a841 100644 --- a/yt_dlp/extractor/facebook.py +++ b/yt_dlp/extractor/facebook.py @@ -564,11 +564,12 @@ def extract_from_jsmods_instances(js_data): js_data, lambda x: x['jsmods']['instances'], list) or []) def extract_dash_manifest(video, formats): - dash_manifest = traverse_obj(video, 'dash_manifest', 'playlist', expected_type=str) + dash_manifest = traverse_obj( + video, 'dash_manifest', 'playlist', 'dash_manifest_xml_string', expected_type=str) if dash_manifest: formats.extend(self._parse_mpd_formats( compat_etree_fromstring(urllib.parse.unquote_plus(dash_manifest)), - mpd_url=video.get('dash_manifest_url'))) + mpd_url=url_or_none(video.get('dash_manifest_url')))) def process_formats(info): # Downloads with browser's User-Agent are rate limited. Working around @@ -618,12 +619,13 @@ def parse_graphql_video(video): video = video['creation_story'] video['owner'] = traverse_obj(video, ('short_form_video_context', 'video_owner')) video.update(reel_info) + fmt_data = traverse_obj(video, ('videoDeliveryLegacyFields', {dict})) or video formats = [] q = qualities(['sd', 'hd']) for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'), ('playable_url_dash', ''), ('browser_native_hd_url', 'hd'), ('browser_native_sd_url', 'sd')): - playable_url = video.get(key) + playable_url = fmt_data.get(key) if not playable_url: continue if determine_ext(playable_url) == 'mpd': @@ -635,7 +637,7 @@ def parse_graphql_video(video): 'quality': q(format_id) - 3, 'url': playable_url, }) - extract_dash_manifest(video, formats) + extract_dash_manifest(fmt_data, formats) if not formats: # Do not append false positive entry w/o any formats return