youtube-dl: cannot download video from facebook url

Checklist

  • I’m reporting a broken site support issue
  • I’ve verified that I’m running youtube-dl version 2021.12.17
  • I’ve checked that all provided URLs are alive and playable in a browser
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar bug reports including closed ones
  • I’ve read bugs section in FAQ

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '--username', 'PRIVATE', '--password', 'PRIVATE', '-F', 'https://www.facebook.com/groups/352666925484718/permalink/1112505706167499/']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.8.10 (CPython) - Linux-5.4.0-91-generic-x86_64-with-glibc2.29
[debug] exe versions: none
[debug] Proxy map: {}
[facebook] Downloading login page
[facebook] Logging in
[facebook] 1112505706167499: Downloading webpage
Traceback (most recent call last):
  File "/home/videodl/vdl/vdl_env/bin/youtube-dl", line 8, in <module>
    sys.exit(main())
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/__init__.py", line 475, in main
    _real_main(argv)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2068, in download
    res = self.extract_info(
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/extractor/facebook.py", line 680, in _real_extract
    return self._extract_from_url(real_url, video_id)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/extractor/facebook.py", line 499, in _extract_from_url
    parse_attachment(attachment)
  File "/home/videodl/vdl/vdl_env/lib/python3.8/site-packages/youtube_dl/extractor/facebook.py", line 480, in parse_attachment
    media = attachment.get(key) or {}
AttributeError: 'NoneType' object has no attribute 'get'

Description

Youtube-dl was working with the same url, username and password. It stopped working recently. video url given in verbose.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I updated the patch above to add error-checking that should avoid the crash above, though that may not affect whether media are found.

imported cookies still not working, some public page still downloadable , but some just failed,

below is in private group

[facebook] 4743714749016405: Downloading webpage
Traceback (most recent call last):
  File "__main__.py", line 19, in <module>
  File "youtube_dl\__init__.pyc", line 475, in main
  File "youtube_dl\__init__.pyc", line 465, in _real_main
  File "youtube_dl\YoutubeDL.pyc", line 2068, in download
  File "youtube_dl\YoutubeDL.pyc", line 808, in extract_info
  File "youtube_dl\YoutubeDL.pyc", line 815, in wrapper
  File "youtube_dl\YoutubeDL.pyc", line 836, in __extract_info
  File "youtube_dl\extractor\common.pyc", line 534, in extract
  File "youtube_dl\extractor\facebook.pyc", line 680, in _real_extract
  File "youtube_dl\extractor\facebook.pyc", line 499, in _extract_from_url
  File "youtube_dl\extractor\facebook.pyc", line 480, in parse_attachment
AttributeError: 'NoneType' object has no attribute 'get'

Thanx @dirkf it worked.

The Facebook extractor is pretty complicated and I have no idea which extraction technique stopped working.

However this patch gets a video from the problem page without any authentication data (updated with further error checking):

--- old/youtube-dl/youtube_dl/extractor/facebook.py
+++ new/youtube-dl/youtube_dl/extractor/facebook.py
@@ -27,6 +27,7 @@
     qualities,
     sanitized_Request,
     try_get,
+    url_or_none,
     urlencode_postdata,
     urljoin,
 )
@@ -493,9 +494,12 @@
                     ], list) or []
                     for attachment in attachments:
                         attachment = try_get(attachment, lambda x: x['style_type_renderer']['attachment'], dict)
+                        if not attachment:
+                            continue
                         ns = try_get(attachment, lambda x: x['all_subattachments']['nodes'], list) or []
                         for n in ns:
-                            parse_attachment(n)
+                            if ns:
+                                parse_attachment(n)
                         parse_attachment(attachment)
 
                 edges = try_get(data, lambda x: x['mediaset']['currMedia']['edges'], list) or []
@@ -591,6 +595,11 @@
             video_data = extract_from_jsmods_instances(tahoe_js_data)
 
         if not video_data:
+            twip = url_or_none(self._html_search_meta('twitter:player', webpage))
+            if twip:
+                return self.url_result(twip)
+
+        if not video_data:
             raise ExtractorError('Cannot parse data')
 
         if len(video_data) > 1:

Ideally, that would be the desired target video in the problem log: I hope it is.

The unpatched extractor fails in the same way as #30473 when no authentication data is passed.