Skip to content

Commit

Permalink
Update facebook.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yinyajiang committed Dec 25, 2024
1 parent 66ca39e commit 3206c24
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions yt_dlp/extractor/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=(?P<id>https.+)'
Expand Down

0 comments on commit 3206c24

Please sign in to comment.