yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
88.85k stars 6.88k forks source link

[yandexmusic] Unable to download JSON metadata: HTTP Error 451: Unavailable For Legal Reasons #7060

Closed etkosko closed 1 year ago

etkosko commented 1 year ago

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

Checklist

Region

No response

Provide a description that is worded well enough to be understood

I have a music bot that opens music via discord, but my bot cannot read the json of the music from yandex music or other platforms

c:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules@distube\yt-dlp\dist\index.js:111 throw new import_distube.DisTubeError("YTDLP_ERROR", ${e2.stderr || e2}); ^ DisTubeError [YTDLP_ERROR]: ERROR: [yandexmusic:track] 70033669: Unable to download JSON metadata: HTTP Error 451: Unavailable For Legal Reasons (caused by <HTTPError 451: 'Unavailable For Legal Reasons'>); please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U at c:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules@distube\yt-dlp\dist\index.js:111:13 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async YtDlpPlugin.resolve (c:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules@distube\yt-dlp\dist\index.js:103:18) at async DisTube.play (c:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules\distube\dist\index.js:2279:14) { errorCode: 'YTDLP_ERROR' }

Provide verbose output that clearly demonstrates the problem

Complete Verbose Output

PS C:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules\@distube\yt-dlp\bin> .\yt-dlp.exe  https://music.yandex.com/album/5568718/track/34976783?lang=en    
[yandexmusic:track] Extracting URL: https://music.yandex.com/album/5568718/track/34976783?lang=en 
[yandexmusic:track] 34976783: Downloading track JSON 
[yandexmusic:track] 34976783: Downloading track location url JSON 
ERROR: [yandexmusic:track] 34976783: Unable to download JSON metadata: HTTP Error 451: Unavailable For Legal Reasons (caused by <HTTPError 451: 'Unavailable For Legal Reasons'>); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
PS C:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules\@distube\yt-dlp\bin> .\yt-dlp.exe https://music.yandex.com/album/5568718/track/34976783?lang=en -vU
[debug] Command-line config: ['https://music.yandex.com/album/5568718/track/34976783?lang=en', '-vU']
[debug] Encodings: locale cp1254, fs utf-8, pref cp1254, out utf-8, error utf-8, screen utf-8 
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (win_exe) 
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021) 
[debug] exe versions: none
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4 
[debug] Proxy map: {} 
[debug] Loaded 1786 extractors 
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest 
Available version: stable@2023.03.04, Current version: stable@2023.03.04 
Current Build Hash: 5590c57bd0433ed239a2deaaf92e2ad6f37fe50f53664c821575cafe106a9421 
yt-dlp is up to date (stable@2023.03.04)
[yandexmusic:track] Extracting URL: https://music.yandex.com/album/5568718/track/34976783?lang=en 
[yandexmusic:track] 34976783: Downloading track JSON 
[yandexmusic:track] 34976783: Downloading track location url JSON 
ERROR: [yandexmusic:track] 34976783: Unable to download JSON metadata: HTTP Error 451: Unavailable For Legal Reasons (caused by <HTTPError 451: 'Unavailable For Legal Reasons'>); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "yt_dlp\extractor\common.py", line 694, in extract 
  File "yt_dlp\extractor\yandexmusic.py", line 116, in _real_extract
  File "yt_dlp\extractor\yandexmusic.py", line 44, in _download_json
  File "yt_dlp\extractor\common.py", line 1048, in download_content
  File "yt_dlp\extractor\common.py", line 1012, in download_handle
  File "yt_dlp\extractor\yandexmusic.py", line 38, in _download_webpage_handle
  File "yt_dlp\extractor\common.py", line 882, in _download_webpage_handle
  File "yt_dlp\extractor\common.py", line 839, in _request_webpage

  File "yt_dlp\extractor\common.py", line 821, in _request_webpage
  File "yt_dlp\YoutubeDL.py", line 3742, in urlopen
  File "urllib\request.py", line 531, in open
  File "urllib\request.py", line 640, in http_response
  File "urllib\request.py", line 569, in error
  File "urllib\request.py", line 502, in _call_chain
  File "urllib\request.py", line 649, in http_error_default
urllib.error.HTTPError: HTTP Error 451: Unavailable For Legal Reasons

PS C:\Users\mrlah\OneDrive\Masaüstü\Ubuntu\Constructor\node_modules\@distube\yt-dlp\bin>
bashonly commented 1 year ago

I've checked that all provided URLs are playable in a browser with the same IP and same login details

Can you confirm this?

etkosko commented 1 year ago

how can I confirm this ?

bashonly commented 1 year ago

Open the webpage URL in browser on the same machine, from the same IP address, and in a private browsing session (not logged in, since you are not passing cookies to yt-dlp) and see if the media will play

etkosko commented 1 year ago

the media didnt play it gave error "Unfortunately, Yandex Music isn't available in your country yet" (Didn't play in private browsing mode)

bashonly commented 1 year ago

I've checked that all provided URLs are playable in a browser with the same IP and same login details

The reason why this is in the issue checklist is because you can't expect yt-dlp to be able to download a video if you can't play it in your browser

Maybe the error could be caught and the extractor could raise with a more descriptive error message? The HTTP error is already fairly descriptive though

pukkandan commented 1 year ago

Why is this reopened?