From 3206c24475056adb179ef97c21197740590631c5 Mon Sep 17 00:00:00 2001 From: yinyajiang <32933356+yinyajiang@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:13:55 +0800 Subject: [PATCH] Update facebook.py --- yt_dlp/extractor/facebook.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/yt_dlp/extractor/facebook.py b/yt_dlp/extractor/facebook.py index d9c7c97ea0b4..652b88e0d984 100644 --- a/yt_dlp/extractor/facebook.py +++ b/yt_dlp/extractor/facebook.py @@ -643,6 +643,7 @@ def parse_graphql_video(video): 'quality': q(format_id) - 3, 'url': playable_url, }) + self._correct_format(formats[-1]) extract_dash_manifest(fmt_data, formats) # New videoDeliveryResponse formats extraction @@ -899,6 +900,19 @@ def _real_extract(self, url): real_url = self._VIDEO_PAGE_TEMPLATE % video_id if url.startswith('facebook:') else url return self._extract_from_url(real_url, video_id) + @staticmethod + def _correct_format(f): + if not f: + return + if f.get('format_id', '') in ('sd', 'hd') and 'acodec' not in f and 'vcodec' not in f: + format_ext = determine_ext(f.get('url', '')) + if format_ext == 'mp4': + f['vcodec'] = 'mp4' + f['acodec'] = 'none' + elif format_ext == 'm4a': + f['vcodec'] = 'none' + f['acodec'] = 'm4a' + class FacebookPluginsVideoIE(InfoExtractor): _VALID_URL = r'https?://(?:[\w-]+\.)?facebook\.com/plugins/video\.php\?.*?\bhref=(?Phttps.+)'