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

[YandexMusic] downloads music in High Quality (320 Kbit/s)

Open smusatov opened this issue 2 years ago • 3 comments

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • [x] I am the original author of this code and I am willing to release it under Unlicense
  • [ ] I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • [ ] Bug fix
  • [x] Improvement
  • [ ] New extractor
  • [ ] New feature

Description of your pull request and other information

Improved the Yandex Music extractor: if cookies with authorization from a premium account are specified, then the extracted URL refers to High Quality (320 kbps)

smusatov avatar Aug 11 '22 04:08 smusatov

As we can't easily test this enhancement, please post logs showing this working: ideally one showing what happens with the existing code and one showing what happens with the PR code.

dirkf avatar Aug 11 '22 18:08 dirkf

May I suggest test case? High quality in terms of Yandex means lower mp3 compression and higher bitrate. So, these are steps to prove that after this improvement downloaded file has higher quality:

  1. Download some modern file
  2. Run spectrum analyzer on it. For example, Audacity. Menus: Analyze -> Plot Spectrum
  3. Compare maximum frequency It is typical for higher-rate compression to cut higher-rate frequencies So, we can tell that audio analyzed on firs image has higher compression rate that second one (see "cursor" field for edge frequency value). image image

I think, this proof is quite sufficient.

Experiment can be reproduced on song https://music.yandex.ru/album/1891713/track/17190963

ursval avatar Feb 25 '23 16:02 ursval

Or just run ffprobe or mediainfo on the audio file.

dirkf avatar Feb 25 '23 17:02 dirkf

I think this should be accepted.

Without this patch:

python3 -m youtube_dl -F --cookies ~/music.yandex.ru_cookies.txt https://music.yandex.ru/album/1891713/track/17190963
[yandexmusic:track] 17190963: Downloading track JSON
[yandexmusic:track] 17190963: Downloading track location url JSON
[yandexmusic:track] 17190963: Downloading track location JSON
[info] Available formats for 17190963:
format code  extension  resolution note
0            mp3        unknown    mp3  @192k, 0.00B

With this patch:

python3 -m youtube_dl -F --cookies ~/music.yandex.ru_cookies.txt https://music.yandex.ru/album/1891713/track/17190963 
[yandexmusic:track] 17190963: Downloading track JSON
[yandexmusic:track] 17190963: Downloading track location url JSON
[yandexmusic:track] 17190963: Downloading track location JSON
[info] Available formats for 17190963:
format code  extension  resolution note
0            mp3        unknown    mp3  @320k, 0.00B

With patch, without cookies

python3 -m youtube_dl -F https://music.yandex.ru/album/1891713/track/17190963
[yandexmusic:track] 17190963: Downloading track JSON
[yandexmusic:track] 17190963: Downloading track location url JSON
[yandexmusic:track] 17190963: Downloading track location JSON
[info] Available formats for 17190963:
format code  extension  resolution note
0            mp3        unknown    mp3  @128k, 0.00B

ffprobe

ffprobe -i "The Doors - People Are Strange-17190963.mp3" 
Input #0, mp3, from 'The Doors - People Are Strange-17190963.mp3':
  Duration: 00:02:12.73, start: 0.000000, bitrate: 320 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s

unkernet avatar Jun 16 '23 09:06 unkernet