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

[Youtube] Got server error HTTP Error 403: Forbidden(latest master version) #32905

Open
6 tasks done
Linux2010 opened this issue Aug 8, 2024 · 99 comments
Open
6 tasks done

Comments

@Linux2010
Copy link

Linux2010 commented Aug 8, 2024

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2024.08.07(the latest master version)
  • 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: ['-v']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2024.08.07.local
[debug] Python 3.8.5 (CPython x86_64 64bit) - macOS-10.16-x86_64-i386-64bit - OpenSSL 1.1.1h  22 Sep 2020
[debug] exe versions: ffmpeg 7.0.1-tessus, ffprobe 6.1.1, rtmpdump 2.4
[debug] Proxy map: {'http': 'http://127.0.0.1:58309', 'https': 'http://127.0.0.1:58309'}
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

PASTE VERBOSE LOG HERE

Description

  • The download will run normally for a short time, and then a 403 error will appear
youtube-dl 'https://www.youtube.com/watch?v=lLSkbZ3-EOs'
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 3 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 4 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 5 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 6 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 7 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 8 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 9 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 41 (attempt 10 of 10)...
[download] Skipping fragment 41...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 42 (attempt 1 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 42 (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 42 (attempt 3 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 42 (attempt 4 of 10)...
@Linux2010 Linux2010 changed the title reoporting bug :Got server HTTP error: HTTP Error 403: Forbidden(the least version) reoporting bug :Got server HTTP error: HTTP Error 403: Forbidden(the latest version) Aug 8, 2024
@Linux2010 Linux2010 changed the title reoporting bug :Got server HTTP error: HTTP Error 403: Forbidden(the latest version) reoporting bug :Got server HTTP error: HTTP Error 403: Forbidden(the latest master version) Aug 8, 2024
@dirkf
Copy link
Contributor

dirkf commented Aug 8, 2024

Indeed this seems to be a pathological video where almost all video formats fail on the first fragment and 299 may fail later, regardless of Python 2.7/3.5/3.9 and User-Agent settings.

yt-dlp 2024.08.06 still works, apparently. It has fancy networking that we can't easily replicate: maybe punt to curl for all requests?

@dirkf dirkf changed the title reoporting bug :Got server HTTP error: HTTP Error 403: Forbidden(the latest master version) [Youtube]: Got server error HTTP Error 403: Forbidden(latest master version) Aug 8, 2024
@dirkf dirkf changed the title [Youtube]: Got server error HTTP Error 403: Forbidden(latest master version) [Youtube] Got server error HTTP Error 403: Forbidden(latest master version) Aug 8, 2024
@tansy
Copy link

tansy commented Aug 8, 2024

I have that with every single video I try. Curiously enough format '18' work all the time. Other formats that work are '136', '137', '248' and/or '160', but it depends on video - not always the case. Still, format '18' is the most reliable to work.

@dirkf
Copy link
Contributor

dirkf commented Aug 8, 2024

So

  1. poToken (I agree, this is always being detected today) randomly breaks the download rather than uniformly giving 403 as with the revised n-sig "throttling"?
  2. different clients get more or less functional links for formats with the same itag?

@GregoriusT
Copy link

Can confirm that a lot of the video-only formats are just being 403-ed in the middle with their downloads, resulting in me getting files that stop after about 10-20 minutes into the video, but still have full sized audio.

By now I have written something into my scripts to just pick format 18 as long as a flag is set, because i foresee this issue happening again in the future once it is eventually fixed... >.>

@dirkf
Copy link
Contributor

dirkf commented Aug 8, 2024

So has anyone tried fetching fragments in fragments of <1MB? We already had a work-around to download in fragments to avoid throttling IIRC.

Otherwise:

  1. actually ignore the data with poToken and use the existing "punt to API" logic with a selected unafflicted client.
  2. extend to user-specified other, or selection of, clients similar to the yt-dlp extractor logic.

@iactix
Copy link

iactix commented Aug 8, 2024

Apparently the latest fix worked for not even a day, that doesn't bode well. Personally I keep getting "giving up after 0 fragment retries" in my python stuff.

From what I read in yesterdays thread, it seems like this will just not work out with fake JS interpretation if they try to combat this in the slightest. Like, that almost doesn't deserve the name attack vector, that's an attack landscape.

@tansy
Copy link

tansy commented Aug 9, 2024

This change is significant. I checked old, pre quantum Firefox and videos don't work any more, when 3 days ago they did.

@dirkf
Copy link
Contributor

dirkf commented Aug 9, 2024

Maybe the new player JS uses some G JS syntax extension (aka ECMA2021+) that hadn't been contemplated in those FF versions. Is there an error in the JS console?

@tansy
Copy link

tansy commented Aug 9, 2024

It used to work as embedded or as mobile (when used mobile user agent). Now all of them display all saying error:

An error occurred. Please try again later. (Playback ID: j-bZsC_YehYVyZZ8)
Learn More (https://support.google.com/youtube/?p=player_error1&hl=en)

Loading any video at https://www.youtube.com/embed/1234567890a:

Content Security Policy: Couldn't process unknown directive 'require-trusted-types-for' <unknown>
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create www-embed-player.js:26:77
InvalidStateError www-embed-player.js:1128:42

Then pressing play:

Error: WebGL: Error during native OpenGL init. base.js:11283:169
Error: WebGL: WebGL creation failed. base.js:11283:169

ED.

If it's of any help, despite what was said before, there are some videos that work.

First - this one doesn't, and gives following console log

Content Security Policy: Couldn't process unknown directive 'require-trusted-types-for' <unknown>
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create www-embed-player.js:26:77
InvalidStateError www-embed-player.js:1128:42
Empty string passed to getElementById(). zVhcVoOEv7o line 2 > eval:795:28944

Error: WebGL: getParameter: parameter: invalid enum value <enum 0x9246> base.js:11283:254

This one does and, with this log:

Content Security Policy: Couldn't process unknown directive 'require-trusted-types-for' <unknown>
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create www-embed-player.js:26:77
InvalidStateError www-embed-player.js:1128:42
Empty string passed to getElementById(). KAR4fAX5T7Y line 2 > eval:4650:33869

So, after clicking 'play' it gives this error: Error: WebGL: getParameter: parameter: invalid enum value <enum 0x9246> base.js:11283:254.

@TheHolyRoger
Copy link

TheHolyRoger commented Aug 9, 2024

No matter what chunk size I use I'm seeing hard 403 errors at 1Meg as others have reported - I'm able to download as many fragments as I want up to 1Meg and then get a 403.

Have experimented with generating cpns (nonces) and adding them to the format fragment URLs without any luck as well as using rn (request numbers) in the URL query instead of byte ranges. Have tried sleeping between fragments to mimick video playback also without joy.

It feels like they've added a check somewhere which fails at the 1Meg mark but I haven't found anything yet where that might be.

Checking via the browser I can see that youtube is happily downloading /videoplayback fragment URLs above 1Meg without any issue...

@dirkf
Copy link
Contributor

dirkf commented Aug 9, 2024

But in the browser the media links have the pot parameter with its poToken challenge result, no? Which is what we can't haz.

In line with step 1 above, I'm gradually pulling stuff from the yt-dlp extractor, enough to download HLS with client ios, but plainly not yet enough to get unblocked links from tv or web_creator, eg with format 135. Should I be expecting that?

@TheHolyRoger
Copy link

TheHolyRoger commented Aug 9, 2024

But in the browser the media links have the pot parameter with its poToken challenge result, no? Which is what we can't haz.

In line with step 1 above, I'm gradually pulling stuff from the yt-dlp extractor, enough to download HLS with client ios, but plainly not yet enough to get unblocked links from tv or web_creator, eg with format 135. Should I be expecting that?

I'm not seeing a pot parameter in the query strings, I am seeing post data in the /videoplayback requests which is referred to in the source as playbackCookie

Edit: Looks like the playbackCookie / POST data is extracted from the bytes of the previous fragment response somehow

@8chanAnon
Copy link

This is the procedure that I am using in my own code.

Load https://www.youtube.com/embed/<id#> and find the base.js link. Do the usual to extract the sig and n-sig. Extract the signatureTimestamp for the next step.

Load https://www.youtube.com/youtubei/v1/player with the signatureTimestamp and TVHTML5_SIMPLY_EMBEDDED_PLAYER as the client name.

If the JSON response contains "formats" and/or "adaptiveFormats" then we're good. This covers most videos, including age-gated ones. The 403 problem occurs when we have go to the next step. We can't use "www.youtube.com". We must use "m.youtube.com" with the user agent set to something like "Mozilla/5.0 (Android 14)" which is what I'm using.

Load https://m.youtube.com/watch?v=<id#> and extract the JSON structures that you would otherwise have gotten from the previous step.

And that's it. The extra step is only required for videos that disallow embedding.

@dirkf
Copy link
Contributor

dirkf commented Aug 10, 2024

Please don't bother to supply any "me too" reports unless the log shows some novelty that may help with rectification. Just "Like", or whatever, an existing similar report.

You can see how a poToken is being sent in POST data by the browser in the Invidious code that shows how to capture the value. But I understood from yt-dlp discussions that a pot query parameter was used in the media links associated with the pot-ified session.

@8chanAnon's algorithm is what is currently done for age-gate videos, up to the last step with m.youtube.com which is new and interesting. What happens if you skip straight to that step?

Step 2 will only work if TVHTML5_SIMPLY_EMBEDDED_PLAYER is not pot-ified, and that seems to be in question.

@dirkf
Copy link
Contributor

dirkf commented Aug 10, 2024

Indeed, Android 14/FF 122 at m.youtube.com didn't list the poToken experiment IDs although yt-dlp has reported unsuccess with Android clients.

@TheHolyRoger
Copy link

TheHolyRoger commented Aug 10, 2024

I don't think it's worth trying to get around the poToken, it will eventually be required in all clients.

I keep digging into base.js when I get some time trying to understand how the token is created, it does seem to be extracted from the bytes of at least the first video fragment as far as I can tell, but not all fragments?...

There's a Uint8Array which appears to be the fragment response data?... manipulated several times and then 82/84/68 bytes of that array are stored as playbackCookie which is then sent in the POST data

@dirkf
Copy link
Contributor

dirkf commented Aug 10, 2024

At least it would be good to have a program that is not not-youtube-dl while a long term solution to the twattery is being investigated.

@PatrickJRed
Copy link

PatrickJRed commented Aug 10, 2024

@dirkf

yt-dlp 2024.08.06 still works, apparently. It has fancy networking that we can't easily replicate: maybe punt to curl for all requests?

On a lot of websites I want to download from youtube-dl and curl dont even get the correct html,
instead of the one i would get in my Browser , they receives a version that has the captcha.

Instead I have a bash-script that predownloads the non-captcha html via "https://github.com/lwthiker/curl-impersonate" (runs in docker container , i use tag: 0.5.2-ff-alpine)

AFAIK lwthiker/curl-impersonate is the only http client that completly impersonates an actual browser like firefox.
A lot of the problems I had with 403 errors in youtube-dl where captchas triggered by http-client not being exactly like an official version of firefox or chrome :) (this might even be valid for fragment-downloads)

@dirkf
Copy link
Contributor

dirkf commented Aug 10, 2024

Yes, but so far as captcha is generally understood (G/recaptcha, hacaptcha, Cloudflare challenge aka breaks the Web), that is not the problem. Even if it solved the poToken issue, a dependency running under Docker would not be an acceptable solution for the main functionality of the program, though it might be a PoC for a solution.

@TheHolyRoger
Copy link

Yeah not relevant here but I did bookmark it for other things, looks like a decent tool :)

@PatrickJRed
Copy link

I only said that i run it in docker.
Apparently it can be used as a library, see https://github.com/lwthiker/curl-impersonate?tab=readme-ov-file#Advanced-usage .
Though I have not looked into that as I run youtube-dl and almost any other apps via docker anyway :)

debanjum added a commit to debanjum/org-music that referenced this issue Nov 1, 2024
…ccess

Changes allow specifying a different (video) download format from
the final audio format to persist on disk.

Current stable youtube-dl has high download failures. See
ytdl-org/youtube-dl#32905 to track issue.

To fix that the song download command has been updated to improve
download success. This has been verified to work with the nightly
youtube-dl version 2024.08.07 (from ytdl-org/ytdl-nightly).
@bstojkovic
Copy link

@dirkf I tried that and it works, thank you.

Though just a note, I got an output that looks like this: 'Numb (Official Music Video) [4K UPGRADE] – Linkin Park.f18.mp4'. including the quotes, having to rename the file. Did I do something wrong?

Also, how do I get the audio part, preferably mp3, from youtube-dl, or do I have to use ffmpeg manually?

PS. Nvm, sorry, I had to replace single quotes with double quotes and use worstaudio.

But when I try to download a playlist with this, I get the following:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/playlist?list=PL1DA88121783E6DDE', '-v', '-f', 'worstaudio', '-o', '%(title)s.f%(format_id)s.%(ext)s', '--user-agent', 'Mozilla/5.0 (Android 14; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0']
[debug] Encodings: locale cp1250, fs utf-8, out utf-8, pref cp1250
[debug] youtube-dl version 2024.08.07 [c5098961b]
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 3.13.0 (CPython AMD64 64bit) - Windows-11-10.0.26100-SP0 - OpenSSL 3.0.15 3 Sep 2024
[debug] exe versions: ffmpeg 7.1-full_build-www.gyan.dev, ffprobe 7.1-full_build-www.gyan.dev
[debug] Proxy map: {}
[youtube:tab] PL1DA88121783E6DDE: Downloading webpage
ERROR: Unable to extract yt initial data; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.
Traceback (most recent call last):
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 975, in __extract_info
    ie_result = ie.extract(url)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\extractor\common.py", line 571, in extract
    ie_result = self._real_extract(url)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\extractor\youtube.py", line 3472, in _real_extract
    data = self._extract_yt_initial_data(item_id, webpage)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\extractor\youtube.py", line 309, in _extract_yt_initial_data
    self._search_regex(
    ~~~~~~~~~~~~~~~~~~^
        (r'%s\s*%s' % (self._YT_INITIAL_DATA_RE, self._YT_INITIAL_BOUNDARY_RE),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         self._YT_INITIAL_DATA_RE), webpage, 'yt initial data'),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\extractor\common.py", line 1101, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract yt initial data; please report this issue on https://github.com/ytdl-org/youtube-dl/issues , using the appropriate issue template. Make sure you are using the latest version; see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update. Be sure to call youtube-dl with the --verbose option and include the complete output.

@3052
Copy link

3052 commented Nov 1, 2024

@bstojkovic unless you are reporting the 403 in the original post, please get out.

@bstojkovic
Copy link

I'm sorry about that.

I tried fixing this error by following this fix, which didn't work until I changed the user agent to match my browser's.

Now it started downloading, but I again got the same 403 error after the first video:

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/playlist?list=PLlqZM4covn1EbvC_6cuERQ59QaMbPkUyE', '-v', '-f', 'worstaudio', '-o', '%(title)s.f%(format_id)s.%(ext)s', '--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0', '--cookie', 'cookie.txt']
[debug] Encodings: locale cp1250, fs utf-8, out utf-8, pref cp1250
[debug] youtube-dl version 2024.08.07 [c5098961b]
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 3.13.0 (CPython AMD64 64bit) - Windows-11-10.0.26100-SP0 - OpenSSL 3.0.15 3 Sep 2024
[debug] exe versions: ffmpeg 7.1-full_build-www.gyan.dev, ffprobe 7.1-full_build-www.gyan.dev
[debug] Proxy map: {}
[youtube:tab] PLlqZM4covn1EbvC_6cuERQ59QaMbPkUyE: Downloading webpage
[download] Downloading playlist: Linkin Park - Meteora (Full Album)
[youtube:tab] Downloading page 1
[youtube:tab] playlist Linkin Park - Meteora (Full Album): Downloading 13 videos
[download] Downloading video 1 of 13
[youtube] U6R-twDkrcI: Downloading webpage
[debug] [youtube] Extracting signature function js_4e23410d_111
[debug] [youtube] Decrypted nsig GZiRgt2-PHartct64 => gt87pM5r1_J33g
[debug] [youtube] Decrypted nsig T1nZG_24zM690R8Q1 => r5F117fhn5OhKQ
[debug] [youtube] Extracting signature function js_4e23410d_107
[debug] Invoking downloader on 'https://rr4---sn-uiu-15be.googlevideo.com/videoplayback?expire=1730473817&ei=-ZokZ6iHBo3Gi9oP4MWz-AY&ip=78.1.32.211&id=o-AAT0ggZDnpQcdw-Vy5gyh8CKYobPY6i2IiF47efYH7N-&itag=249&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1730452217%2C&mh=J0&mm=31%2C29&mn=sn-uiu-15be%2Csn-c0q7lns7&ms=au%2Crdu&mv=m&mvi=4&pl=20&rms=au%2Cau&initcwndbps=1131250&bui=AQn3pFQfo40qmZrJwi_bFPcKV7rY928cDI2OvVJGyLjQA3ckc5Zk7Eg3weIJnpvUPfdUMCdl9vLhwT3n&spc=qtApAbySq7fu2WVar6YzjKEV-Tsg_6g-AifXGquonylPEFCFl-IRYTs&vprv=1&svpuc=1&mime=audio%2Fwebm&ns=3698YDeDS9PsV_tLG2D8tVMQ&rqh=1&gir=yes&clen=72618&dur=14.021&lmt=1727862061501188&mt=1730451670&fvip=1&keepalive=yes&fexp=51312688%2C51326932%2C51331021&c=WEB&sefc=1&txp=4432434&n=r5F117fhn5OhKQ&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=ACJ0pHgwRAIgcM5KiANDJKpm4aUdQ0pfgzFxlijbMiaYCZG9I_r6srcCIAmAtWvTdq9u17DbH3HOrxRsCW3hM_KMNhVpbyBStO2C&sig=AJfQdSswRAIgHLnBXlF_PoxKLw5X65maCnztl47wB9piPkhaZ0BZh6oCIGELRRRJRwCalWjQCOU7H4c9idG1N9nCVsGiWCV1Xd7p'
[dashsegments] Total fragments: 1
[download] Destination: Foreword - Linkin Park (Meteora).f249.webm
[download] 100% of 70.92KiB in 00:00
[download] Downloading video 2 of 13
[youtube] oWfGOVWrueo: Downloading webpage
[debug] [youtube] Decrypted nsig D27kGRBmimGGA6dbB => 76ycp_1uov4kiQ
[debug] [youtube] Decrypted nsig RHMcZAVixdMDPK2C0 => l7RIMnHRzg8UDA
[debug] Invoking downloader on 'https://rr1---sn-uiu-15bl.googlevideo.com/videoplayback?expire=1730473819&ei=-5okZ4aiGorsi9oPrZ7AsQc&ip=78.1.32.211&id=o-AGX1FEab3IkQZy_74MhntSikWyv6UPkOhvbwTXX-gloY&itag=249&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1730452219%2C&mh=Nl&mm=31%2C29&mn=sn-uiu-15bl%2Csn-c0q7lnz7&ms=au%2Crdu&mv=m&mvi=1&pl=20&rms=au%2Cau&initcwndbps=1193750&bui=AQn3pFQJZLSwmAQJ-OeYhTWDmgL_TtS7_MN-a53IcrKAqiZEd_GswVcFVWpo_1CSwGoqbAOwG1R_HNPi&spc=qtApAWDoETuSEaY8NBGcRslDcEnq7WsZzQxl6h_3IL6fbk8BOQ5l38c&vprv=1&svpuc=1&mime=audio%2Fwebm&ns=fnNIO-US1Z2IsoQzZnBtHJcQ&rqh=1&gir=yes&clen=1108963&dur=188.021&lmt=1727372021758657&mt=1730451670&fvip=2&keepalive=yes&fexp=51312688%2C51326932%2C51331021&c=WEB&sefc=1&txp=4532434&n=l7RIMnHRzg8UDA&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=ACJ0pHgwRAIgF-pQsqcv4E3sLwPKAj8Yf7aBcBwMO7JdWZm_VpgXBF4CIGViEhzWRw3RfOxQPE_NBrq0mSbKWwFQRBQotBfYvW3u&sig=AJfQdSswRAIge324X26GQ79r_2P1V63Gd91g-PNwrv9ljzgLCws-SFkCIE72gbWvurp27diJOcimEttPBoupG3rzyIMRhOtq5KDf'
[dashsegments] Total fragments: 1
[download] Destination: Don't Stay - Linkin Park (Meteora).f249.webm
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 1 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 3 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 4 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 5 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 6 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 7 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 8 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 9 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 10 of 10)...
ERROR: giving up after 10 fragment retries
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\__main__.py", line 19, in <module>
    youtube_dl.main()
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\__init__.py", line 477, in main
    _real_main(argv)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\__init__.py", line 467, in _real_main
    retcode = ydl.download(all_urls)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 2257, in download
    res = self.extract_info(
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 872, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 986, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1076, in process_ie_result
    return self.__process_playlist(ie_result, download)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1210, in __process_playlist
    entry_result = self.__process_iterable_entry(entry, download, extra)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1219, in __process_iterable_entry
    return self.process_ie_result(
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1024, in process_ie_result
    return self.extract_info(ie_result['url'],
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 872, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 986, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1020, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1864, in process_video_result
    self.process_info(new_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 142, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 2162, in process_info
    success = dl(filename, info_dict)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 2092, in dl
    return fd.download(name, new_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\downloader\common.py", line 380, in download
    return self.real_download(filename, info_dict)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\downloader\dash.py", line 78, in real_download
    self.report_error('giving up after %s fragment retries' % count)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\downloader\common.py", line 175, in report_error
    self.ydl.report_error(*args, **kargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 682, in report_error
    self.trouble(*args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 634, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())

@dirkf
Copy link
Contributor

dirkf commented Nov 1, 2024

  1. 'single-quoting' in POSIX shell unless you specifically want shell variables in the "quoted value to be ${expanded}"; "double-quoting" in Windows cmd; someone who knows can say what should be done in Powershell, etc.
  2. -f worst was just to get the smallest result for a test. You can pick whichever quality you like from the --list-formats/-F output.
  3. -f worstaudio gets a single audio-only format, saved with its format ID prepended to the file suffix; normally you would get the video too (eg, with the default format option) and the resulting file would be either be a single combined format, with no format ID in the name, or a merged format from individual video and audio formats, similarly. It may have been a bug that a single audio or video file is not renamed according to the template if there is no merger, but this is now a feature that can't be changed.
  4. With this 403, consider going away for a bit, then use [a] suitable --...sleep-interval ... option[s] to limit the frequency of hitting YT.
  5. As noted earlier but now vexingly concealed by GH who can't write a simple multi-page issue handler, the music UA may not help with playlists. Feel free to expand the posts endlessly until you find the relevant comment.
  6. -x/--extract-audio will convert the download to an audio file according to --audio-format .... Happily this works with a single audio download or a combined download. IIRC the default format for audio extraction becomes bestaudio/best to avoid unnecessarily downloading a video-only file.

@bstojkovic
Copy link

  1. Okay, I understand now
  2. Oh, I thought there was a problem with other formats, nvm
  3. Not sure I understood this fully. I do want an individual audio format from the videos
  4. Okay
  5. I am using an Edge desktop browser UA. Not sure what music UA is
  6. Okay

Having all this in mind, I executed a new command, but still get the same problem.

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.youtube.com/playlist?list=PLlqZM4covn1EbvC_6cuERQ59QaMbPkUyE', '-v', '--extract-audio', '--audio-format', 'mp3', '--sleep-interval', '15', '--max-sleep-interval', '60', '-o', '%(title)s.f%(format_id)s.%(ext)s', '--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0', '--cookie', 'cookie.txt']
[debug] Encodings: locale cp1250, fs utf-8, out utf-8, pref cp1250
[debug] youtube-dl version 2024.08.07 [c5098961b]
[debug] ** This version was built from the latest master code at https://github.com/ytdl-org/youtube-dl.
[debug] ** For support, visit the main site.
[debug] Python 3.13.0 (CPython AMD64 64bit) - Windows-11-10.0.26100-SP0 - OpenSSL 3.0.15 3 Sep 2024
[debug] exe versions: ffmpeg 7.1-full_build-www.gyan.dev, ffprobe 7.1-full_build-www.gyan.dev
[debug] Proxy map: {}
[youtube:tab] PLlqZM4covn1EbvC_6cuERQ59QaMbPkUyE: Downloading webpage
[download] Downloading playlist: Linkin Park - Meteora (Full Album)
[youtube:tab] Downloading page 1
[youtube:tab] playlist Linkin Park - Meteora (Full Album): Downloading 13 videos
[download] Downloading video 1 of 13
[youtube] U6R-twDkrcI: Downloading webpage
[debug] [youtube] Extracting signature function js_4e23410d_111
[debug] [youtube] Decrypted nsig Bt2UmQjC35K8fKdm0 => BD3TCI24xHXRuw
[debug] [youtube] Extracting signature function js_4e23410d_107
[debug] [youtube] Decrypted nsig XTVUaHCzqChiN4-yU => ja17ZASsmgar6A
[debug] Invoking downloader on 'https://rr4---sn-uiu-15be.googlevideo.com/videoplayback?expire=1730500377&ei=uQIlZ9WjAs6Fi9oPweK3wA0&ip=78.1.32.211&id=o-AOCuc8kn0IAynmwiLGM5crMcjLmHUcCw-GAGv4573PBm&itag=140&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1730478777%2C&mh=J0&mm=31%2C29&mn=sn-uiu-15be%2Csn-c0q7lns7&ms=au%2Crdu&mv=m&mvi=4&pcm2cms=yes&pl=20&rms=au%2Cau&initcwndbps=837500&bui=AQn3pFREK0nJj6EMcCRmmLBKhv1zxXCgpIqXQidl_j94Pb_gVCYoVdclUeLYWTrDYThHyVeezjt3TA-x&spc=qtApAf-gWldRuBShlpS4YdojzxkNVscgOUdICYbCQhbNdelKV3IHiM0&vprv=1&svpuc=1&mime=audio%2Fmp4&ns=htTcHybsWqB47MCARMuIKSEQ&rqh=1&gir=yes&clen=228176&dur=14.048&lmt=1727862061256275&mt=1730478323&fvip=1&keepalive=yes&fexp=51312688%2C51326932%2C51331021&c=WEB&sefc=1&txp=4432434&n=ja17ZASsmgar6A&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Crms%2Cinitcwndbps&lsig=ACJ0pHgwRgIhAMZRvZi5_AzwwMjA0zkV3lo_a2L6hCzZ3YrP8aSmD643AiEAn-taIaBT6poH-4dmGGut5DbMB7lRDjT_TSe92o9r6bs%3D&sig=AJfQdSswRQIhAK9ZeyubPbVxcqdZTOkaVH6Lsp3erJmdHCKyFDXSpoBsAiBlDqiO0PgopRd5yLunj6i5g_8DndAdqpxh-IOgrjkewg%3D%3D'
[download] Sleeping 41.34 seconds...
[dashsegments] Total fragments: 1
[download] Destination: Foreword - Linkin Park (Meteora).f140.m4a
[download] 100% of 222.83KiB in 00:00
[ffmpeg] Correcting container in "Foreword - Linkin Park (Meteora).f140.m4a"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Foreword - Linkin Park (Meteora).f140.m4a" -c copy -f mp4 "file:Foreword - Linkin Park (Meteora).f140.temp.m4a"
[debug] ffmpeg command line: ffprobe -show_streams "file:Foreword - Linkin Park (Meteora).f140.m4a"
[ffmpeg] Destination: Foreword - Linkin Park (Meteora).f140.mp3
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Foreword - Linkin Park (Meteora).f140.m4a" -vn -acodec libmp3lame "-q:a" 5 "file:Foreword - Linkin Park (Meteora).f140.mp3"
Deleting original file Foreword - Linkin Park (Meteora).f140.m4a (pass -k to keep)
[download] Downloading video 2 of 13
[youtube] oWfGOVWrueo: Downloading webpage
[debug] [youtube] Decrypted nsig lB-gv90rz9H7FrRDz => xm3GK7zk_9N-_Q
[debug] [youtube] Decrypted nsig DkC2dRj1XWO_NqPf4 => bM85kxw3jKFZHg
[debug] Invoking downloader on 'https://rr1---sn-uiu-15bl.googlevideo.com/videoplayback?expire=1730500421&ei=5QIlZ7OrHomFi9oPvNj-4A0&ip=78.1.32.211&id=o-AJUHgn2MyeGdxAgbUKL7kAGYredoh52f7CqpfHw-wkWR&itag=140&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1730478821%2C&mh=Nl&mm=31%2C29&mn=sn-uiu-15bl%2Csn-c0q7lnz7&ms=au%2Crdu&mv=m&mvi=1&pcm2cms=yes&pl=20&rms=au%2Cau&initcwndbps=962500&bui=AQn3pFSjvxfalZRLSIF1ZGn6rb3TU4a0RdAF3B8AJbd-zvPWcWYrgiPQRSzRPGkArt4jbZ_Ze6JfJlyI&spc=qtApAXc5wLJ2g1zSmI9I0WVcQBv7VjahGFNrhQUapY8mwamfBHrj9zU&vprv=1&svpuc=1&mime=audio%2Fmp4&ns=SIid59X60e_8XVaX19pYI-IQ&rqh=1&gir=yes&clen=3044289&dur=188.058&lmt=1727371732352084&mt=1730478554&fvip=2&keepalive=yes&fexp=51312688%2C51326932%2C51331021&c=WEB&sefc=1&txp=4532434&n=bM85kxw3jKFZHg&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Crms%2Cinitcwndbps&lsig=ACJ0pHgwRQIhAIG5O6wkr0KsaW5oxBreBpj92Ts6Pjq9NWnFzVAcrzQoAiBQovEVeKiqRtgQZPr6pOlC5cscop7Hw7fXlopddW7LVQ%3D%3D&sig=AJfQdSswRQIhAIk30ldwKFtEiSIBkLV5cvaOtFi7VVVt1OG158BIQbqPAiBN_MwY-wolTJltIzZVvlv8Uc2fhjqT7mHGGNvMY9JUqw%3D%3D'
[download] Sleeping 49.53 seconds...
[dashsegments] Total fragments: 1
[download] Destination: Don't Stay - Linkin Park (Meteora).f140.m4a
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 1 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 3 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 4 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 5 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 6 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 7 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 8 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 9 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 10 of 10)...
ERROR: giving up after 10 fragment retries
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\__main__.py", line 19, in <module>
    youtube_dl.main()
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\__init__.py", line 477, in main
    _real_main(argv)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\__init__.py", line 467, in _real_main
    retcode = ydl.download(all_urls)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 2257, in download
    res = self.extract_info(
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 872, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 986, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1076, in process_ie_result
    return self.__process_playlist(ie_result, download)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1210, in __process_playlist
    entry_result = self.__process_iterable_entry(entry, download, extra)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1219, in __process_iterable_entry
    return self.process_ie_result(
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1024, in process_ie_result
    return self.extract_info(ie_result['url'],
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 872, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 879, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 986, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1020, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 1864, in process_video_result
    self.process_info(new_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 142, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 2162, in process_info
    success = dl(filename, info_dict)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 2092, in dl
    return fd.download(name, new_info)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\downloader\common.py", line 380, in download
    return self.real_download(filename, info_dict)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\downloader\dash.py", line 78, in real_download
    self.report_error('giving up after %s fragment retries' % count)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\downloader\common.py", line 175, in report_error
    self.ydl.report_error(*args, **kargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 682, in report_error
    self.trouble(*args, **kwargs)
  File "C:\Users\bozos\AppData\Local\Programs\Python\Python313\Lib\site-packages\youtube_dl\YoutubeDL.py", line 634, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())

I'm hoping I didn't follow the advice incorrectly.

@dirkf
Copy link
Contributor

dirkf commented Nov 1, 2024

To avoid 403 on the media download, you need a work-around, which is to use a UA like the one I showed, which causes YT to use its mobile web client. The downside is that the current extractor may not be able to extract playlists from the mobile page format. You could list the playlist IDs with --flat-playlist --get-id, not specifying any UA (add --get-title for a hint as to the content associated with each ID); then get each wanted audio item using the mobile UA and other parameters similar to what you have above. You should scroll back in the issue, I'm afraid, for all the details.

@Rekrullurker
Copy link

Thank you!

I haven't visited this thread in quite some time. I just skimmed it, saw the part about changing the user agent, added that to my script, and youtube-dl is working again. At least for now.

@Rekrullurker
Copy link

Well, it was nice while it lasted, but now it's throttled down to a crawl again. :(

@josephecombs
Copy link

josephecombs commented Nov 9, 2024

Adding --user-agent "Mozilla/5.0 (Android 14; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0" worked for me just now on a previously failing

11:18:03 ruby-3.2.2 (master) ~/Dropbox/-> yd https://www.youtube.com/watch?v=cKw_Rjtn3uc
[youtube] cKw_Rjtn3uc: Downloading webpage
[youtube] cKw_Rjtn3uc: Downloading player baafab19
[dashsegments] Total fragments: 1
[download] Destination: Addison Rae - Diet Pepsi (Kastra Remix) _ Lyric Video-cKw_Rjtn3uc.m4a
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 1 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 3 of 10)...

where my alias yd is

alias yd='cd /Users/myusername/Dropbox/ && youtube-dl -x --audio-quality 0 --audio-format mp3 --user-agent "Mozilla/5.0 (Android 14; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0"'

@umrashrf
Copy link

% youtube-dl -v 'https://www.youtube.com/watch?v=H9FrNLzK_WE'
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://www.youtube.com/watch?v=H9FrNLzK_WE']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: 254bf3fe9d
[debug] Python version 3.12.7 (CPython) - macOS-14.6.1-arm64-arm-64bit
[debug] exe versions: none
[debug] Proxy map: {}
[youtube] H9FrNLzK_WE: Downloading webpage
WARNING: unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
[debug] Default format spec: best/bestvideo+bestaudio
[debug] Invoking downloader on 'https://rr3---sn-t0aedn7l.googlevideo.com/videoplayback?expire=1732834411&ei=C6BIZ7PDGtbdybgPtJ-j2Qg&ip=2607%3Afa49%3A5742%3A2300%3A476%3A2fb1%3Ab8d7%3Ad61&id=o-AOkZjgb1dzkTyOPBDKo8oInLci42ttpNLSElS_NhMyPI&itag=18&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1732812811%2C&mh=55&mm=31%2C29&mn=sn-t0aedn7l%2Csn-t0aekn7e&ms=au%2Crdu&mv=m&mvi=3&pl=40&rms=au%2Cau&initcwndbps=1460000&bui=AQn3pFT1TFynKpG2CnhOIXdwfZul4FSpPW7bbhM82STpcKAghKYFBQRzkp8avO_5ANpCRRzCEea1WoS8&spc=qtApASOyRgAezGj6GVdKg6vLgarZd9eUWee6RQ8T9WG1-QzDgjBnM9YysM7WlYc&vprv=1&svpuc=1&mime=video%2Fmp4&ns=5SgaM_LqEQXLSxvJv4w4VNoQ&rqh=1&gir=yes&clen=110270895&ratebypass=yes&dur=1420.968&lmt=1732325389520475&mt=1732812319&fvip=2&fexp=51326932%2C51335594&c=WEB&sefc=1&txp=5538434&n=D1oF9sMbE9u4Ls_l5EW&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AJfQdSswRAIgXMxQE8XpsYWWdGUdQinMi--2O3dtEaQqqFIb49f3GjoCIFW6_4CMK3SISuymlGZSpEv_ehqzbgxEUq7xaHO-j0os&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=AGluJ3MwRQIhAP37774uoPHg9nY6PZsS1q6E8TyHhGsz85338O8_o3F5AiB_OFeIsgQus4OjgDpP5RHL29ORLqyWpURWPY51l9LNsg%3D%3D'
ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/YoutubeDL.py", line 1976, in process_info
    success = dl(filename, info_dict)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/YoutubeDL.py", line 1915, in dl
    return fd.download(name, info)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/downloader/common.py", line 366, in download
    return self.real_download(filename, info_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/downloader/http.py", line 351, in real_download
    establish_connection()
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/downloader/http.py", line 116, in establish_connection
    raise err
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/downloader/http.py", line 110, in establish_connection
    ctx.data = self.ydl.urlopen(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/youtube-dl/2021.12.17/libexec/lib/python3.12/site-packages/youtube_dl/YoutubeDL.py", line 2288, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.7_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

Same error with different flags like:

youtube-dl -v --user-agent "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.103 Mobile Safari/537.36" 'https://www.youtube.com/watch?v=H9FrNLzK_WE'

OR

youtube-dl -v -f mp4 --user-agent "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.103 Mobile Safari/537.36" 'https://www.youtube.com/watch?v=H9FrNLzK_WE'

@dirkf
Copy link
Contributor

dirkf commented Nov 28, 2024

  1. There's no point showing logs for the known problem.
  2. Point 3 above probably applies.
  3. Consider trying the UA that was found to work above.

@gleeglee217
Copy link

I have installed ffmpeg (6/20/2018) in Winds11 "Edit the sys environment variables" in "Environment variables" then "Path" then "edit" then added the last two as pictured. (youtube-dl.exe ver 2024.8.7 nightly build).
Screenshot 2024-11-28 121243

Now I am trying to only get mp3 files from YT and here is a screenshot of what issues I have in Windows Power Shell
win power shell

@dirkf
Copy link
Contributor

dirkf commented Nov 28, 2024

  1. When posting a log, please paste it as text rather than a screenshot and use the verbose option (--verbose/-v).
  2. As you apparently (but we can't be sure, because of the non-verbose log) haven't applied any of the work-arounds suggested above in the issue, the failure that you got was expected and so point 1 of my previous comment applies.
  3. You haven't reached the point where ffmpeg would be used but your PATH setting looks plausible as far as I can recall: if you should have a problem where yt-dl doesn't find ffmpeg you can specify the program or its (binary) directory using an option, and that option could be included in a user or system config file.
  4. Similarly, mp3 extraction is not relevant to the problem.
  5. Review the issue comments and apply the suggested work-arounds.

@Rekrullurker

This comment was marked as off-topic.

@Rekrullurker

This comment was marked as off-topic.

@nicolaasjan

This comment was marked as off-topic.

@Rekrullurker

This comment was marked as resolved.

@nicolaasjan

This comment was marked as off-topic.

@Rekrullurker
Copy link

Thank, that build worked great.

@dirkf
Copy link
Contributor

dirkf commented Dec 11, 2024

I've been using the UserAgent workaround for about a month now. Up until the last couple of days, it was working great. Now it seems to fail about 80-90% of the time, giving me multiple 403 errors. ...

Probably you were seeing the roll-out of the player JS as reported in #32986, with success depending on whether your request went to a server that was still sending the previous player.

@Rekrullurker
Copy link

Oops, I spoke too soon. It worked fine in my two quick tests, as well as a video I downloaded later, now it's back to giving me 403 errors.

@dirkf
Copy link
Contributor

dirkf commented Dec 11, 2024

Are you using the mobile UA option? If so, pls post verbose log.

@Rekrullurker
Copy link

Yes, I am. After some more testing, it seems it only fails on some videos. Here is the log from one such failure;

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', '--user-agent', 'Mozilla/5.0 (Android 14; Mobile; rv:128.0) Gecko/128.0 Firefox/128.0', 'https://www.youtube.com/watch?v=ZbelsTTZ0QE']
[debug] Encodings: locale cp1252, fs mbcs, out cp1252, pref cp1252
[debug] youtube-dl version 2024.12.10
[debug] Lazy loading extractors enabled
[debug] Single file build
[debug] Python 3.4.4 (CPython x86 32bit) - Windows-XP-5.1.2600-SP3 - OpenSSL 1.0.2d 9 Jul 2015
[debug] exe versions: ffmpeg N-105053-gc417616-Reino
[debug] Proxy map: {}
[youtube] ZbelsTTZ0QE: Downloading webpage
[debug] [youtube] Decrypted nsig J2T7YI_FVNuB1rbFlt => Pv42zso-RjFDsg
[debug] [youtube] Decrypted nsig nxJfsEvTaEBBjAFmdI => WmC7NoLmA6NMKg
[youtube] ZbelsTTZ0QE: Downloading API JSON
[debug] Default format spec: bestvideo+bestaudio/best
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[debug] Invoking downloader on 'https://rr1---sn-j5caxoxu-i2oe.googlevideo.com/videoplayback?clen=197680715&mm=31%2C29&expire=1733936581&n=WmC7NoLmA6NMKg&fexp=51326932%2C51331020%2C51335594%2C51347747&initcwndbps=4651250&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398%2C399%2C597%2C598&xpc=EgVo2aDSNQ%3D%3D&svpuc=1&lmt=1705760126895911&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&fvip=3&spc=qtApAWdjprjT_XTFriEtZsm8lM2XNY_MngwQu6j_huq5MxvrU1ugSI3vLzFU6lXmSA&ei=ZXFZZ-PPKqy2kucPmIHVsQM&bui=AQn3pFRXKOA5CW96qDyDVdV3dApfkc7mOlIbyA7j1nTYH8ijcsOLxdF9T36pQPhmbz82eMcPRxZHpmQh&itag=137&source=youtube&mime=video%2Fmp4&rms=au%2Cau&c=MWEB&ms=au%2Crdu&txp=5432434&ip=24.44.111.244&rqh=1&requiressl=yes&vprv=1&mt=1733914628&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&dur=1500.766&sefc=1&mh=HJ&pl=22&ns=zaPT_foz9hIdg3hYUktMjtUQ&sig=AJfQdSswRQIgVQQuKslmNCAToTk32xo0BhhmykeTM9Hc224RFz8FguICIQCT9_lCgewMeljrIwTyxFkRH51YFwLaQhQo_eKtydbDfg%3D%3D&mvi=1&id=o-APJn1Cpo42KU0qexogywzXvkNWrnrhR-PjkDm8NlWR6q&met=1733914981%2C&mn=sn-j5caxoxu-i2oe%2Csn-ab5sznzs&keepalive=yes&lsig=AGluJ3MwRQIhAIJ2A-jh_4ASdk4JS9Yr-iMpNb0L1xPnd6WhAEHpTYqzAiBf7l6LEsMycV_iNln99MBXRFPRB-6s9u5YBbLko703Sw%3D%3D&gir=yes&mv=m'
[dashsegments] Total fragments: 19
[download] Destination: Top 20 Gorgeous Adult & Violent Classic Anime That Are Beyond Awesome - Explored-ZbelsTTZ0QE.f137.mp4
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 1 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 2 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 3 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 4 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 5 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 6 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 7 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 8 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 9 of 10)...
[download] Got server HTTP error: HTTP Error 403: Forbidden. Retrying fragment 1 (attempt 10 of 10)...
ERROR: giving up after 10 fragment retries
File "main.py", line 19, in
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl_init_.py", line 477, in main
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl_init_.py", line 467, in _real_main
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 2254, in download
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 868, in extract_info
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 875, in wrapper
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 982, in __extract_info
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 1016, in process_ie_result
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 1860, in process_video_result
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 138, in wrapper
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 2152, in process_info
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 2088, in dl
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\downloader\common.py", line 380, in download
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\downloader\dash.py", line 78, in real_download
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\downloader\common.py", line 175, in report_error
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 678, in report_error
File "C:\Users\nico\Desktop\youtube-dl_source\youtube_dl\YoutubeDL.py", line 630, in trouble

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests