Repository: yt-dlp
Issue: yt-dlp extracts incorrect URL for some tracks in a playlist on music.youtube.com, URL leads to unavailable version of the track
Labels: duplicate,site-enhancement,site:youtube

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a new site support request
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that none of provided URLs [violate any copyrights](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#is-the-website-primarily-used-for-piracy) or contain any [DRM](https://en.wikipedia.org/wiki/Digital_rights_management) to the best of my knowledge
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [ ] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and am willing to share it if required

### Region

United States

### Example URLs

https://music.youtube.com/playlist?list=PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k
https://music.youtube.com/watch?v=vy2el0kqwLQ ("Lone Digger", playable, URL when clicked into from playlist directly)
https://music.youtube.com/watch?v=L2Yog_3hvj4 ("Lone Digger", not playable, URL extracted by yt-dlp when downloading playlist)


### Provide a description that is worded well enough to be understood

Attempting to download tracks from an unlisted (non-private) playlist on music.youtube.com.
All tracks on the playlist are publicly available to all users on music.youtube.com.

- For some tracks, yt-dlp extracts an unavailable URL for the track from the playlist which differs from the playable URL of the track, when the track is clicked into from the playlist and played individually
- yt-dlp is able to download the track if the available URL for that track is provided, but cannot download the track from the playlist
- yt-dlp can download other tracks from the playlist without issue
  - No identifiable pattern for tracks which yt-dlp cannot download from the playlist vs ones that it can
- For each track that cannot be downloaded, the error 'Video unavailable. This video is not available' is given, which indicates the video is not available on youtube.com, but the video is available on youtube.com
- Track downloads without issue from youtube.com; issue is only present when downloaded from music.youtube.com


yt-dlp is extracting a URL to a version of the video that is unavailable, despite the video being available on youtube.com. I can't find a way to manually get to the same URL yt-dlp is getting - every version of the song I try to access has an available video, and downloads without issue if I provide the direct URL.

EXAMPLE:

- URL for the track on music.youtube.com:
  - https://music.youtube.com/watch?v=vy2el0kqwLQ
  - Downloads without issue
  - URL can be reached manually when track is clicked from the playlist on music.youtube.com
- URL for the track on youtube.com:
  - https://www.youtube.com/watch?v=vy2el0kqwLQ
  - Downloads without issue
  - URL can be reached manually when track is clicked from the playlist on youtube.com
- URL for the video version of the track on music.youtube.com:
  - https://music.youtube.com/watch?v=UbQgXeY_zi4
  - Downloads without issue
  - URL can be reached manually when video is clicked from the playlist on music.youtube.com
- URL for the video version of the track on youtube.com:
  - https://www.youtube.com/watch?v=UbQgXeY_zi4
  - Downloads without issue
  - URL can be reached manually when video is clicked from the playlist on youtube.com
- URL yt-dlp extracts from the playlist on youtube.com:
  - https://www.youtube.com/watch?v=vy2el0kqwLQ&list=LL
  - Downloads without issue
  - URL can be reached manually when track is clicked from the playlist on youtube.com
- URL yt-dlp extracts from the playlist on music.youtube.com:
  - https://music.youtube.com/watch?v=L2Yog_3hvj4
  - Unavailable, cannot be played or downloaded
  - URL cannot be reached manually

REQUEST: add support for music.youtube.com to download playlist tracks directly.

Current workaround: gather the correct URL for each track yt-dlp was unable to download from the playlist and download them individually.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

Code snippet showing four failed downloads and two successful downloads from the playlist.
For each failed download, the track is playable from the playlist, and yt-dlp has extracted an unplayable URL rather than the track's actual playable URL.

```shell
PS C:\Users\andre\Music> ./yt-dlp.exe -vU --break-on-existing --cookies-from-browser "chrome" -x --audio-format "m4a" "https://music.youtube.com/playlist?list=PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k"
[debug] Command-line config: ['-vU', '--break-on-existing', '--cookies-from-browser', 'chrome', '-x', '--audio-format', 'm4a', 'https://music.youtube.com/playlist?list=PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.08.06 from yt-dlp/yt-dlp [4d9231208] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.22631-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg N-116133-g03175b587c-20240704 (setts), ffprobe N-116133-g03175b587c-20240704, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.07.04, curl_cffi-0.5.10, mutagen-1.47.0, requests-2.32.3, sqlite3-3.35.5, urllib3-2.2.2, websockets-12.0
[debug] Proxy map: {}
Extracting cookies from chrome
[debug] Extracting cookies from: "C:\Users\andre\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies"
[debug] Found local state file at "C:\Users\andre\AppData\Local\Google\Chrome\User Data\Local State"
Extracted 3420 cookies from chrome
[debug] cookie version breakdown: {'v10': 3514, 'other': 0, 'unencrypted': 83}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1830 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.08.06 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.08.06 from yt-dlp/yt-dlp)
[youtube:tab] Extracting URL: https://music.youtube.com/playlist?list=PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k
WARNING: [youtube:tab] YouTube Music is not directly supported. Redirecting to https://www.youtube.com/playlist?list=PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k
[youtube:tab] PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k: Downloading webpage
[debug] [youtube:tab] Extracted SAPISID cookie
[youtube:tab] PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k: Redownloading playlist API JSON with unavailable videos
[download] Downloading playlist: Beats that move you
[youtube:tab] PLuHwpDXpuFhV14KMiVcYs0SUwM85wxS3k page 1: Downloading API JSON
[youtube:tab] Playlist Beats that move you: Downloading 182 items of 252
[download] Downloading item 1 of 182
[youtube] Extracting URL: https://music.youtube.com/watch?v=L2Yog_3hvj4
[youtube] L2Yog_3hvj4: Downloading webpage
[debug] [youtube] Extracted SAPISID cookie
[youtube] L2Yog_3hvj4: Downloading ios player API JSON
[youtube] L2Yog_3hvj4: Downloading web creator player API JSON
[youtube] L2Yog_3hvj4: Downloading ios music player API JSON
[youtube] L2Yog_3hvj4: Downloading web music client config
[youtube] L2Yog_3hvj4: Downloading player 28fd7348
[youtube] L2Yog_3hvj4: Downloading web music player API JSON
ERROR: [youtube] L2Yog_3hvj4: Video unavailable. This video is not available
  File "yt_dlp\extractor\common.py", line 740, in extract
  File "yt_dlp\extractor\youtube.py", line 4358, in _real_extract
  File "yt_dlp\extractor\common.py", line 1263, in raise_no_formats

[download] Downloading item 2 of 182
[youtube] Extracting URL: https://music.youtube.com/watch?v=egMW50X8XEY
[youtube] egMW50X8XEY: Downloading webpage
[youtube] egMW50X8XEY: Downloading ios player API JSON
[youtube] egMW50X8XEY: Downloading web creator player API JSON
[youtube] egMW50X8XEY: Downloading ios music player API JSON
[youtube] egMW50X8XEY: Downloading web music client config
[youtube] egMW50X8XEY: Downloading web music player API JSON
ERROR: [youtube] egMW50X8XEY: Video unavailable. This video is not available
  File "yt_dlp\extractor\common.py", line 740, in extract
  File "yt_dlp\extractor\youtube.py", line 4358, in _real_extract
  File "yt_dlp\extractor\common.py", line 1263, in raise_no_formats

[download] Downloading item 3 of 182
[youtube] Extracting URL: https://music.youtube.com/watch?v=i59WmqD4gdo
[youtube] i59WmqD4gdo: Downloading webpage
[youtube] i59WmqD4gdo: Downloading ios player API JSON
[youtube] i59WmqD4gdo: Downloading web creator player API JSON
[youtube] i59WmqD4gdo: Downloading ios music player API JSON
[youtube] i59WmqD4gdo: Downloading web music client config
[youtube] i59WmqD4gdo: Downloading web music player API JSON
ERROR: [youtube] i59WmqD4gdo: Video unavailable. This video is not available
  File "yt_dlp\extractor\common.py", line 740, in extract
  File "yt_dlp\extractor\youtube.py", line 4358, in _real_extract
  File "yt_dlp\extractor\common.py", line 1263, in raise_no_formats

[download] Downloading item 4 of 182
[youtube] Extracting URL: https://music.youtube.com/watch?v=oHb1MAgPQik
[youtube] oHb1MAgPQik: Downloading webpage
[youtube] oHb1MAgPQik: Downloading ios player API JSON
[youtube] oHb1MAgPQik: Downloading web creator player API JSON
[youtube] oHb1MAgPQik: Downloading ios music player API JSON
[youtube] oHb1MAgPQik: Downloading web music client config
[youtube] oHb1MAgPQik: Downloading web music player API JSON
ERROR: [youtube] oHb1MAgPQik: Video unavailable. This video is not available
  File "yt_dlp\extractor\common.py", line 740, in extract
  File "yt_dlp\extractor\youtube.py", line 4358, in _real_extract
  File "yt_dlp\extractor\common.py", line 1263, in raise_no_formats

[download] Downloading item 5 of 182
[youtube] Extracting URL: https://music.youtube.com/watch?v=vFXU76lPENs
[youtube] vFXU76lPENs: Downloading webpage
[youtube] vFXU76lPENs: Downloading ios player API JSON
[youtube] vFXU76lPENs: Downloading web creator player API JSON
[youtube] vFXU76lPENs: Downloading ios music player API JSON
[youtube] vFXU76lPENs: Downloading web music client config
[youtube] vFXU76lPENs: Downloading web music player API JSON
[debug] [youtube] Extracting signature function js_28fd7348_105
[debug] Loading youtube-sigfuncs.js_28fd7348_105 from cache
[debug] Loading youtube-nsig.28fd7348 from cache
[debug] [youtube] Decrypted nsig ISyumJTA4YXG9eIFN => z6d4oFyTU21DnQ
[debug] Loading youtube-nsig.28fd7348 from cache
[debug] [youtube] Decrypted nsig a5GTfMsPeeFK8fNI_ => euCZreFEhawvDw
[debug] Loading youtube-nsig.28fd7348 from cache
[debug] [youtube] Decrypted nsig uvnMrjcXO3ZvJIqXE => _Yv9--4jWTxFpw
[youtube] vFXU76lPENs: Downloading m3u8 information
[youtube] vFXU76lPENs: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] vFXU76lPENs: Downloading 1 format(s): 774
[debug] Invoking http downloader on "https://rr5---sn-nx5s7nee.googlevideo.com/videoplayback?expire=1723167633&ei=MR-1ZtClLIGZsfIPvdnEuA8&ip=2601%3A602%3A8f7f%3A4821%3A4126%3A5f49%3Ae557%3Aa9cb&id=o-AMB7g4iuDEZpOeLUWL4Bgx1DaavihfmCI-DzYYPsI_ze&itag=774&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=9I&mm=31%2C29&mn=sn-nx5s7nee%2Csn-nx57ynsk&ms=au%2Crdu&mv=m&mvi=5&pl=38&ctier=A&pfa=5&gcr=us&initcwndbps=1743750&hightc=yes&siu=1&bui=AXc671Jzfo6qsKeG9kd0B2H9bEjaPEkKMJKECtwdIzwGJ8L9abW5B2u_5ERTjnynAANz_dVa5Q&spc=Mv1m9tP1d6LRqGxu8lNhmHQd1CYgKa0sBfqwLG4CiQn3zY9PCNI9Df7rNZMq39w&vprv=1&svpuc=1&mime=audio%2Fwebm&ns=v8KgIWo163hzbV5ZLuXpclkQ&rqh=1&gir=yes&clen=8701457&dur=268.181&lmt=1714893595761364&mt=1723145838&fvip=2&keepalive=yes&c=WEB_REMIX&sefc=1&txp=2318224&n=_Yv9--4jWTxFpw&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cctier%2Cpfa%2Cgcr%2Chightc%2Csiu%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AGtxev0wRgIhALEm2xwLBmWZzw1M3LxueIimAB5FGOcrocWp2QQxt-aBAiEA9BELFe22vP3hBvt3QyBLsmJ54tRp381BAjW_pAjmRFw%3D&sig=AJfQdSswRQIgUIYldHuwzcT2lwwhrjtqwxG7MzV-Z5AGNY-V68JfGAQCIQDyr_g82Z4lB49ETSWEBH20PkZvClQBb_yFec7VR7E6OA%3D%3D"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: My People [vFXU76lPENs].webm
[download] 100% of    8.30MiB in 00:00:00 at 19.71MiB/s
[debug] ffmpeg command line: ffprobe -show_streams "file:My People [vFXU76lPENs].webm"
[ExtractAudio] Destination: My People [vFXU76lPENs].m4a
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i "file:My People [vFXU76lPENs].webm" -vn -acodec aac -q:a 2.05 -movflags +faststart "file:My People [vFXU76lPENs].m4a"
Deleting original file My People [vFXU76lPENs].webm (pass -k to keep)
[download] Downloading item 6 of 182
[youtube] Extracting URL: https://music.youtube.com/watch?v=p3g2xZK3iJI
[youtube] p3g2xZK3iJI: Downloading webpage
[youtube] p3g2xZK3iJI: Downloading ios player API JSON
[youtube] p3g2xZK3iJI: Downloading web creator player API JSON
[youtube] p3g2xZK3iJI: Downloading ios music player API JSON
[youtube] p3g2xZK3iJI: Downloading web music client config
[youtube] p3g2xZK3iJI: Downloading web music player API JSON
[debug] Loading youtube-nsig.28fd7348 from cache
[debug] [youtube] Decrypted nsig -GjlkwOyGcR29IK0J => Gm42bALCaPuq6A
[debug] Loading youtube-nsig.28fd7348 from cache
[debug] [youtube] Decrypted nsig l6_UWueYc51Rd-J_W => U7DE90tBtvRMpg
[debug] [youtube] Extracting signature function js_28fd7348_101
[debug] Loading youtube-sigfuncs.js_28fd7348_101 from cache
[debug] Loading youtube-nsig.28fd7348 from cache
[debug] [youtube] Decrypted nsig OJonZ4LjBhL-hzSjL => 0j6HLxrvCUtS4g
[youtube] p3g2xZK3iJI: Downloading m3u8 information
[youtube] p3g2xZK3iJI: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] p3g2xZK3iJI: Downloading 1 format(s): 774
[debug] Invoking http downloader on "https://rr3---sn-nx5s7n7s.googlevideo.com/videoplayback?expire=1723167645&ei=PR-1Zq2eK9z4sfIPlMHcwAk&ip=2601%3A602%3A8f7f%3A4821%3A4126%3A5f49%3Ae557%3Aa9cb&id=o-AN54wbV5Q-x5E16pd-tw_TttNd3uJtXw4oi1WqyN8qM6&itag=774&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=at&mm=31%2C29&mn=sn-nx5s7n7s%2Csn-nx57ynlk&ms=au%2Crdu&mv=m&mvi=3&pl=38&ctier=A&pfa=5&gcr=us&initcwndbps=1822500&hightc=yes&siu=1&bui=AXc671LRmUZ3zviCdAc4JbO7GeGku4BmxnXut4QPiyKBevu8znyJWJyaIiM0pfVCL2xmH2tQXA&spc=Mv1m9lK1Ll9MW0pvhDkUea6MWkVR2043qEqjeugsgPQuh4PnucV8dRwuWSiKYaA&vprv=1&svpuc=1&mime=audio%2Fwebm&ns=8L-CttdWlDZf4d0YDkZQkjwQ&rqh=1&gir=yes&clen=8751403&dur=275.081&lmt=1714853724124839&mt=1723145593&fvip=5&keepalive=yes&c=WEB_REMIX&sefc=1&txp=2318224&n=0j6HLxrvCUtS4g&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cctier%2Cpfa%2Cgcr%2Chightc%2Csiu%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AGtxev0wRgIhAITcWm6g-MAlAx-4xYEFwDl__RCrtQirFkgFHg8sHF47AiEA9pzpNHTKjR7OTEphu4Bzk2GITIeouKZwG_5iVRgm2bA%3D&sig=AJfQdSswRQIgeW6-3aWnP4v7ANccCPKAtlC9GVHuyTgMEMPYWP9062ICIQCQetujDBceROv5ciR-vswzTgmDxeueajlfs0lrwvviqg%3D%3D"
[download] Destination: A New Sky [p3g2xZK3iJI].webm
[download] 100% of    8.35MiB in 00:00:00 at 19.05MiB/s
[debug] ffmpeg command line: ffprobe -show_streams "file:A New Sky [p3g2xZK3iJI].webm"
[ExtractAudio] Destination: A New Sky [p3g2xZK3iJI].m4a
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i "file:A New Sky [p3g2xZK3iJI].webm" -vn -acodec aac -q:a 2.05 -movflags +faststart "file:A New Sky [p3g2xZK3iJI].m4a"
Deleting original file A New Sky [p3g2xZK3iJI].webm (pass -k to keep)
```
(output continues, truncated for relevancy)