ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.92k stars 10k forks source link

Some Facebook plugin URLs are unsupported #10795

Open wanchihh opened 8 years ago

wanchihh commented 8 years ago

Please follow the guide below


Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.09.27. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.


The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

> youtube-dl.exe "https://www.facebook.com/v2.3/plugins/video.php?allowfullscreen=true&app_id=&channel=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fx
d_arbiter%2Fr%2FP5DLcu0KGJB.js%3Fversion%3D42%23cb%3Df1d45e6da%26domain%3Dwww.mycarforum.com%26origin%3Dhttp%253A%252F%252Fwww.mycarforum.com%252Ff1e33442e4%26r
elation%3Dparent.parent&container_width=883&href=http%3A%2F%2Fwww.mycarforum.com%2FTheStraitsTimes%2Fvideos%2F10153797435237115%2F%3Ftype%3D3&locale=en_US&sdk=j
oey" -v                                                                                                                                                         
[debug] System config: []                                                                                                                                       
[debug] User config: []                                                                                                                                         
[debug] Command-line args: ['https://www.facebook.com/v2.3/plugins/video.php?allowfullscreen=true&app_id=&channel=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2
Fxd_arbiter%2Fr%2FP5DLcu0KGJB.js%3Fversion%3D42%23cb%3Df1d45e6da%26domain%3Dwww.mycarforum.com%26origin%3Dhttp%253A%252F%252Fwww.mycarforum.com%252Ff1e33442e4%2
6relation%3Dparent.parent&container_width=883&href=http%3A%2F%2Fwww.mycarforum.com%2FTheStraitsTimes%2Fvideos%2F10153797435237115%2F%3Ftype%3D3&locale=en_US&sdk
=joey', '-v']                                                                                                                                                   
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252                                                                                               
[debug] youtube-dl version 2016.09.27                                                                                                                           
[debug] Python version 3.4.4 - Windows-7-6.1.7601-SP1                                                                                                           
[debug] exe versions: ffmpeg N-74113-gcdb0225, ffprobe N-74113-gcdb0225                                                                                         
[debug] Proxy map: {}                                                                                                                                           
[generic] video.php?allowfullscreen=true&app_id=&channel=http://staticxx.facebook.com/connect/xd_arbiter/r/P5DLcu0KGJB.js?version=42#cb=f1d45e6da&domain=www.myc
arforum.com&origin=http%3A%2F%2Fwww.mycarforum.com%2Ff1e33442e4&relation=parent.parent&container_width=883&href=http://www.mycarforum: Requesting header        
WARNING: Falling back on generic information extractor.                                                                                                         
[generic] video.php?allowfullscreen=true&app_id=&channel=http://staticxx.facebook.com/connect/xd_arbiter/r/P5DLcu0KGJB.js?version=42#cb=f1d45e6da&domain=www.myc
arforum.com&origin=http%3A%2F%2Fwww.mycarforum.com%2Ff1e33442e4&relation=parent.parent&container_width=883&href=http://www.mycarforum: Downloading webpage      
[generic] video.php?allowfullscreen=true&app_id=&channel=http://staticxx.facebook.com/connect/xd_arbiter/r/P5DLcu0KGJB.js?version=42#cb=f1d45e6da&domain=www.myc
arforum.com&origin=http%3A%2F%2Fwww.mycarforum.com%2Ff1e33442e4&relation=parent.parent&container_width=883&href=http://www.mycarforum: Extracting information   
ERROR: Unsupported URL: https://www.facebook.com/v2.3/plugins/video.php?allowfullscreen=true&app_id=&channel=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_a
rbiter%2Fr%2FP5DLcu0KGJB.js%3Fversion%3D42%23cb%3Df1d45e6da%26domain%3Dwww.mycarforum.com%26origin%3Dhttp%253A%252F%252Fwww.mycarforum.com%252Ff1e33442e4%26rela
tion%3Dparent.parent&container_width=883&href=http%3A%2F%2Fwww.mycarforum.com%2FTheStraitsTimes%2Fvideos%2F10153797435237115%2F%3Ftype%3D3&locale=en_US&sdk=joey

Traceback (most recent call last):                                                                                                                              
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpaa64pv68\build\youtube_dl\YoutubeDL.py", line 694, in extract_info                         
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpaa64pv68\build\youtube_dl\extractor\common.py", line 355, in extract                       
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\rg3\tmpaa64pv68\build\youtube_dl\extractor\generic.py", line 2424, in _real_extract               
youtube_dl.utils.UnsupportedError: Unsupported URL: https://www.facebook.com/v2.3/plugins/video.php?allowfullscreen=true&app_id=&channel=http%3A%2F%2Fstaticxx.f
acebook.com%2Fconnect%2Fxd_arbiter%2Fr%2FP5DLcu0KGJB.js%3Fversion%3D42%23cb%3Df1d45e6da%26domain%3Dwww.mycarforum.com%26origin%3Dhttp%253A%252F%252Fwww.mycarfor
um.com%252Ff1e33442e4%26relation%3Dparent.parent&container_width=883&href=http%3A%2F%2Fwww.mycarforum.com%2FTheStraitsTimes%2Fvideos%2F10153797435237115%2F%3Fty
pe%3D3&locale=en_US&sdk=joey                                                                                                                                    
...
<end of log>

Description of your issue, suggested solution and other information

Hi,

When I tried downloading videos from the Facebook urls beginning with "https://www.facebook.com/v2.3/plugins/video.php", the Unsupported URL error is returned.

Eg.:

Note the youtube-dl is able to download videos from Facebook urls beginning with "https://www.facebook.com/plugins/video.php"

Thanks.

ole-tange commented 7 years ago

This also does not work: https://www.facebook.com/groups/ateistiskselskab/permalink/10154930137678856/

It thinks you need to log in - which is clearly not true.

yan12125 commented 7 years ago

@ole-tange That's a different bug. Could you open a new issue?

mcepl commented 1 year ago

Is this the same as mine problem?

fun~$ youtube-dl --verbose 'https://www.facebook.com/reel/1463302304499951'
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.facebook.com/reel/1463302304499951']
[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.11.3 (CPython) - Linux-6.3.9-1-default-x86_64-with-glibc2.37
[debug] exe versions: ffmpeg 6.0, ffprobe 6.0
[debug] Proxy map: {}
[generic] 1463302304499951: Requesting header
WARNING: Falling back on generic information extractor.
[generic] 1463302304499951: Downloading webpage
[generic] 1463302304499951: Extracting information
[generic] 1463302304499951: Requesting header
WARNING: Falling back on generic information extractor.
[generic] 1463302304499951: Downloading webpage
[generic] 1463302304499951: Extracting information
[redirect] Following redirect to https://www.facebook.com/plugins/video.php?height=1920&width=1080&href=%2F100013522218132%2Fvideos%2Fmassive-us-aircraft-carrier-in-waters-of-split-croatia-with-70-planes-that-can-r%2F1463302304499951%2F&_fb_noscript=1
[generic] video: Requesting header
WARNING: Falling back on generic information extractor.
[generic] video: Downloading webpage
[generic] video: Extracting information
ERROR: Unsupported URL: https://www.facebook.com/plugins/video.php?height=1920&width=1080&href=%2F100013522218132%2Fvideos%2Fmassive-us-aircraft-carrier-in-waters-of-split-croatia-with-70-planes-that-can-r%2F1463302304499951%2F&_fb_noscript=1
Traceback (most recent call last):
  File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/youtube-dl/youtube_dl/extractor/generic.py", line 3489, in _real_extract
    raise UnsupportedError(url)
youtube_dl.utils.UnsupportedError: Unsupported URL: https://www.facebook.com/plugins/video.php?height=1920&width=1080&href=%2F100013522218132%2Fvideos%2Fmassive-us-aircraft-carrier-in-waters-of-split-croatia-with-70-planes-that-can-r%2F1463302304499951%2F&_fb_noscript=1

fun~$ 
dirkf commented 1 year ago

It's certainly similar. yt-dlp gets the /reel/ page without redirecting, so a back-port could help.

Instead, we can let the redirect work and fix (up to a point) the FacebookPluginsVideoIE for the URL patterns here:

  1. match URLs with "/vm.n/" and with the href not starting "http"
  2. correctly redirect to both FB and external URLs

    --- a/youtube_dl/extractor/facebook.py
    +++ b/youtube_dl/extractor/facebook.py
    @@ -681,7 +681,7 @@ class FacebookIE(InfoExtractor):
    
    class FacebookPluginsVideoIE(InfoExtractor):
    -    _VALID_URL = r'https?://(?:[\w-]+\.)?facebook\.com/plugins/video\.php\?.*?\bhref=(?P<id>https.+)'
    +    _VALID_URL = r'(?s)https?://(?:[\w-]+\.)?facebook\.com/(?:v[\d.]+/)?plugins/video\.php\?(?:.*?&)?href=(?P<id>(?:http|%2[fF]|/).+?)(?:$|&)'
    
     _TESTS = [{
         'url': 'https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fgov.sg%2Fvideos%2F10154383743583686%2F&show_text=0&width=560',
    @@ -704,6 +704,5 @@ class FacebookPluginsVideoIE(InfoExtractor):
     }]
    
     def _real_extract(self, url):
    -        return self.url_result(
    -            compat_urllib_parse_unquote(self._match_id(url)),
    -            FacebookIE.ie_key())
    +        return self.url_result(urljoin(
    +            'https://www.facebook.com', compat_urllib_parse_unquote(self._match_id(url))))

    The external site has to be supported, unlike www.mycarforum.com in the original problem URLs.

Then:

$ python -m youtube_dl -v -F 'https://www.facebook.com/reel/1463302304499951'[debug] System config: [u'--prefer-ffmpeg']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-F', u'https://www.facebook.com/reel/1463302304499951']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: 87c77a0b0
[debug] Python 2.7.18 (CPython i686 32bit) - Linux-4.4.0-210-generic-i686-with-Ubuntu-16.04-xenial - OpenSSL 1.1.1t  7 Feb 2023 - glibc 2.15
[debug] exe versions: avconv 4.3, avprobe 4.3, ffmpeg 4.3, ffprobe 4.3
[debug] Proxy map: {}
[generic] 1463302304499951: Requesting header
WARNING: Falling back on generic information extractor.
[generic] 1463302304499951: Downloading webpage
[generic] 1463302304499951: Extracting information
[facebook] 1463302304499951: Downloading webpage
WARNING: Unknown codec vp09.00.30.08.00.01.01.01.00
WARNING: Unknown codec vp09.00.30.08.00.01.01.01.00
WARNING: Unknown codec vp09.00.31.08.00.01.01.01.00
WARNING: Unknown codec vp09.00.31.08.00.01.01.01.00
WARNING: Unknown codec vp09.00.31.08.00.01.01.01.00
WARNING: Unknown codec vp09.00.31.08.00.01.01.01.00
WARNING: Unknown codec vp09.00.40.08.00.01.01.01.00
[download] Downloading playlist: 1463302304499951
[facebook] playlist 1463302304499951: Collected 1 video ids (downloading 1 of them)
[download] Downloading video 1 of 1
[info] Available formats for 1463302304499951:
format code        extension  resolution note
1129638768438872a  m4a        audio only DASH audio   79k , m4a_dash container, mp4a.40.5 (44100Hz)
185997627502804v   mp4        580x1032   DASH video  124k , mp4_dash container, av01.0.09M.08, video only
923349152097085v   mp4        720x1280   DASH video  370k , mp4_dash container, av01.0.09M.08, video only
990139268842798v   mp4        720x1280   DASH video  878k , mp4_dash container, av01.0.09M.08, video only
147789984937182v   mp4        720x1280   DASH video 1807k , mp4_dash container, av01.0.09M.08, video only
718304283463765v   mp4        720x1280   DASH video 3383k , mp4_dash container, av01.0.09M.08, video only
7117972781550284v  mp4        1080x1920  DASH video 4300k , mp4_dash container, av01.0.09M.08, video only
1208605577206543v  mp4        384x682    DASH video   98k , mp4_dash container
1682239612250282v  mp4        556x988    DASH video  208k , mp4_dash container
3646292515656183v  mp4        720x1280   DASH video  533k , mp4_dash container
809403937361013v   mp4        720x1280   DASH video 1331k , mp4_dash container
599380479046409v   mp4        720x1280   DASH video 2732k , mp4_dash container
829015408555345v   mp4        720x1280   DASH video 4627k , mp4_dash container
1636173010182348v  mp4        1080x1920  DASH video 6113k , mp4_dash container
sd                 mp4        unknown    
hd                 mp4        unknown    (best)
[download] Finished downloading playlist: 1463302304499951
$ 
mcepl commented 1 year ago

@dirkf Thank you, that really makes youtube-dl working for me again! Passed it to the openSUSE package.