youtube-dl icon indicating copy to clipboard operation
youtube-dl copied to clipboard

ERROR: unable to download video data: HTTP Error 403: Forbidden

Open scottkyoung opened this issue 2 years ago • 3 comments

Fairly long download which ended abnormally.
I had previously downloaded day 2 without a problem: https://www.youtube.com/watch?v=VwAuvNoFZl0 But couldn't download day 3: https://www.youtube.com/watch?v=UsyfAzTbxjA

The download started at ‎Tuesday, ‎December ‎6, ‎2022, ‏‎12:30:15 AM and failed at ‎Tuesday, ‎December ‎6, ‎2022, ‏‎6:30:45 AM.

The verbose log is as follows:

D:\Users\esnsy\Videos>youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]" https://www.youtube.com/watch?v=UsyfAzTbxjA --verbose
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]', 'https://www.youtube.com/watch?v=UsyfAzTbxjA', '--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.22621
[debug] exe versions: ffmpeg git-2020-06-12-38737b3, ffprobe git-2020-06-12-38737b3
[debug] Proxy map: {}
[youtube] UsyfAzTbxjA: Downloading webpage
[youtube] UsyfAzTbxjA: Downloading player ac058a09
[debug] Invoking downloader on 'https://rr2---sn-p5qs7nsk.googlevideo.com/videoplayback?expire=1670326213&ei=ZdOOY83MKo2G8wShwpGICg&ip=68.118.229.46&id=o-AFuCJ7trYuRFQaHdzfglRGPeyv_uU7785Q93xYWM0mDJ&itag=137&aitags=134%2C136%2C137%2C160%2C243&source=youtube&requiressl=yes&mh=FT&mm=31%2C26&mn=sn-p5qs7nsk%2Csn-vgqsknsk&ms=au%2Conr&mv=m&mvi=2&pl=19&initcwndbps=1885000&vprv=1&mime=video%2Fmp4&ns=LCo8OyWfzqAf9GQUKEepRrUJ&gir=yes&clen=5733731037&dur=10404.998&lmt=1670245827748908&mt=1670304340&fvip=4&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=7219224&n=uUI047hTgh4zTJF&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgUBZ1oO_Bt8_vhcnbFBPvmoBhpL07ktjEpExhc8dEG_UCIDNWofEz7sj6_wxuFP7yEHCmSEaFIOzSeDXOPXt-HJa_&sig=AOq0QJ8wRgIhAKVX2elPRcCxG_Vv9UHQeVhTdQUgnwvKCGRprerdqrJFAiEAlAeJo9o9BOs2drOwyl7BAoRmI9jRBNalzhX76XU7Lws='
[download] Destination: 2022 Gompei Invitational, Day 3 Finals-UsyfAzTbxjA.f137.mp4
[download]  11.9% of 5.34GiB at 77.19KiB/s ETA 17:45:42 [download] Got server HTTP error: [WinError 10054] An existing connection was forcibly closed by the remote host. Retrying (attempt 1 of 10)...
[download] Destination: 2022 Gompei Invitational, Day 3 Finals-UsyfAzTbxjA.f137.mp4
[download]  23.4% of 5.34GiB at 50.00KiB/s ETA 23:49:02      ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\YoutubeDL.py", line 1970, in process_info
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\YoutubeDL.py", line 1915, in dl
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\downloader\common.py", line 366, in download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\downloader\http.py", line 351, in real_download
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\downloader\http.py", line 116, in establish_connection
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\downloader\http.py", line 110, in establish_connection
  File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpupik7c6w\build\youtube_dl\YoutubeDL.py", line 2288, in urlopen
  File "C:\Python\Python34\lib\urllib\request.py", line 470, in open
  File "C:\Python\Python34\lib\urllib\request.py", line 580, in http_response
  File "C:\Python\Python34\lib\urllib\request.py", line 508, in error
  File "C:\Python\Python34\lib\urllib\request.py", line 442, in _call_chain
  File "C:\Python\Python34\lib\urllib\request.py", line 588, in http_error_default
urllib.error.HTTPError: HTTP Error 403: Forbidden

D:\Users\esnsy\Videos>

scottkyoung avatar Dec 06 '22 23:12 scottkyoung

Sometimes YT offers a media link that gives 403, or 404.

You could try a different video format, or hope that YT fixes its CDN.

Otherwise, run youtube-dl --get-url --f 137 UsyfAzTbxjA to find the up-to-date media link, similar to that listed above:

https://rr2---sn-p5qs7nsk.googlevideo.com/videoplayback?expire=1670326213&ei=ZdOOY83MKo2G8wShwpGICg&ip=68.118.229.46&id=o-AFuCJ7trYuRFQaHdzfglRGPeyv_uU7785Q93xYWM0mDJ&itag=137&aitags=134%2C136%2C137%2C160%2C243&source=youtube&requiressl=yes&mh=FT&mm=31%2C26&mn=sn-p5qs7nsk%2Csn-vgqsknsk&ms=au%2Conr&mv=m&mvi=2&pl=19&initcwndbps=1885000&vprv=1&mime=video%2Fmp4&ns=LCo8OyWfzqAf9GQUKEepRrUJ&gir=yes&clen=5733731037&dur=10404.998&lmt=1670245827748908&mt=1670304340&fvip=4&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=7219224&n=uUI047hTgh4zTJF&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgUBZ1oO_Bt8_vhcnbFBPvmoBhpL07ktjEpExhc8dEG_UCIDNWofEz7sj6_wxuFP7yEHCmSEaFIOzSeDXOPXt-HJa_&sig=AOq0QJ8wRgIhAKVX2elPRcCxG_Vv9UHQeVhTdQUgnwvKCGRprerdqrJFAiEAlAeJo9o9BOs2drOwyl7BAoRmI9jRBNalzhX76XU7Lws=

In this enormous URL YT has hidden backup host details. Find the URL query parameter mm and fvip:

mn=sn-p5qs7nsk%2Csn-vgqsknsk
fvip=4

Split the mn value into two parts, on either side of %2C.

Replace the digit(s) before the --- in the hostname with the value of fvip; replace the remaining part of the first host domain component after the --- (which should match the first part of the mn value) with the second part of the mn value. Thus:

https://rr4---sn-vgqsknsk.googlevideo.com/videoplayback?expire=1670326213&ei=ZdOOY83MKo2G8wShwpGICg&ip=68.118.229.46&id=o-AFuCJ7trYuRFQaHdzfglRGPeyv_uU7785Q93xYWM0mDJ&itag=137&aitags=134%2C136%2C137%2C160%2C243&source=youtube&requiressl=yes&mh=FT&mm=31%2C26&mn=sn-p5qs7nsk%2Csn-vgqsknsk&ms=au%2Conr&mv=m&mvi=2&pl=19&initcwndbps=1885000&vprv=1&mime=video%2Fmp4&ns=LCo8OyWfzqAf9GQUKEepRrUJ&gir=yes&clen=5733731037&dur=10404.998&lmt=1670245827748908&mt=1670304340&fvip=4&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=7219224&n=uUI047hTgh4zTJF&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgUBZ1oO_Bt8_vhcnbFBPvmoBhpL07ktjEpExhc8dEG_UCIDNWofEz7sj6_wxuFP7yEHCmSEaFIOzSeDXOPXt-HJa_&sig=AOq0QJ8wRgIhAKVX2elPRcCxG_Vv9UHQeVhTdQUgnwvKCGRprerdqrJFAiEAlAeJo9o9BOs2drOwyl7BAoRmI9jRBNalzhX76XU7Lws=

Download this with a yt-dl command like so:

youtube-dl -o "2022 Gompei Invitational, Day 3 Finals-UsyfAzTbxjA.f137.mp4" "modified_enormous_URL"`

Then, if you run the original download command (don't use --no-continue, not that you would), yt-dl will recognise the .f137. file that you just created, and won't try to download it again, instead downloading the .f140. audio file and merging them.

dirkf avatar Dec 07 '22 01:12 dirkf

Thanks for breaking down how to decipher the backup URL embedded in YouTube media URLs. Haven't seen anyone elaborate on that before, and I was curious how that worked. Thanks for that 👍.

observeroftime01 avatar Dec 16 '22 02:12 observeroftime01

See

  • https://github.com/yt-dlp/yt-dlp/issues/1986
  • https://github.com/yt-dlp/yt-dlp/pull/5639.

dirkf avatar Dec 16 '22 15:12 dirkf

Duplicate of #31247.

dirkf avatar Jan 12 '23 02:01 dirkf

Try to upgrade to the latest version of yt-dlp

python -m pip install -U yt-dlp

v-nhandt21 avatar Aug 15 '23 04:08 v-nhandt21