Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ie/Facebook] Fix Unhandled IndexError #8681

Merged
merged 14 commits into from
Dec 24, 2023
9 changes: 5 additions & 4 deletions yt_dlp/extractor/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FacebookIE(InfoExtractor):
)\?(?:.*?)(?:v|video_id|story_fbid)=|
[^/]+/videos/(?:[^/]+/)?|
[^/]+/posts/|
groups/[^/]+/permalink/|
groups/[^/]+/(?:permalink|posts)/|
watchparty/
)|
facebook:
Expand Down Expand Up @@ -612,9 +612,10 @@ def parse_attachment(attachment, key='media'):
nodes = variadic(traverse_obj(data, 'nodes', 'node') or [])
attachments = traverse_obj(nodes, (
..., 'comet_sections', 'content', 'story', (None, 'attached_story'), 'attachments',
..., ('styles', 'style_type_renderer'), 'attachment'), expected_type=dict) or []
..., ('styles', 'throwbackStyles', 'style_type_renderer'), (None, ...), 'attachment'), expected_type=dict) or []
kclauhk marked this conversation as resolved.
Show resolved Hide resolved
for attachment in attachments:
ns = try_get(attachment, lambda x: x['all_subattachments']['nodes'], list) or []
ns = (try_get(attachment, lambda x: x['all_subattachments']['nodes'], list)
or traverse_obj(attachment, (..., 'attachments', ..., 'styles', 'attachment'), expected_type=dict) or [])
kclauhk marked this conversation as resolved.
Show resolved Hide resolved
for n in ns:
parse_attachment(n)
parse_attachment(attachment)
Expand All @@ -637,7 +638,7 @@ def parse_attachment(attachment, key='media'):
if len(entries) > 1:
return self.playlist_result(entries, video_id)

video_info = entries[0]
video_info = entries[0] if entries else {'id': video_id}
webpage_info = extract_metadata(webpage)
# honor precise duration in video info
if video_info.get('duration'):
Expand Down