youtube-dl
youtube-dl copied to clipboard
[YandexMusic] downloads music in High Quality (320 Kbit/s)
Before submitting a pull request make sure you have:
- [x] Searched the bugtracker for similar pull requests
- [x] Read adding new extractor tutorial
- [x] Read youtube-dl coding conventions and adjusted the code to meet them
- [x] Covered the code with tests (note that PRs without tests will be REJECTED)
- [x] Checked the code with flake8
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)
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.
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:
- Download some modern file
- Run spectrum analyzer on it. For example, Audacity. Menus: Analyze -> Plot Spectrum
- 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).
I think, this proof is quite sufficient.
Experiment can be reproduced on song https://music.yandex.ru/album/1891713/track/17190963
Or just run ffprobe or mediainfo on the audio file.
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