diff options
author | Sergey M․ <dstftw@gmail.com> | 2016-05-04 22:33:29 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2016-05-04 22:33:29 +0600 |
commit | 15fc0658f75403e76f9cb29dd4ce5d1e514d4bf4 (patch) | |
tree | 8dbbb5c76b739f2e099465817aadd38f42d657c2 | |
parent | e960c3c223acadb2fac81fb68595d902cf21e349 (diff) |
[yandexmusic:playlist] Modernize
-rw-r--r-- | youtube_dl/extractor/yandexmusic.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/youtube_dl/extractor/yandexmusic.py b/youtube_dl/extractor/yandexmusic.py index 22050add3..0dda901a8 100644 --- a/youtube_dl/extractor/yandexmusic.py +++ b/youtube_dl/extractor/yandexmusic.py @@ -231,20 +231,21 @@ class YandexMusicPlaylistIE(YandexMusicPlaylistBaseIE): if len(tracks) < len(track_ids): present_track_ids = set([compat_str(track['id']) for track in tracks if track.get('id')]) missing_track_ids = set(map(compat_str, track_ids)) - set(present_track_ids) - request = sanitized_Request( - 'https://music.yandex.ru/handlers/track-entries.jsx', - urlencode_postdata({ + missing_tracks = self._download_json( + 'https://music.yandex.%s/handlers/track-entries.jsx' % tld, + playlist_id, 'Downloading missing tracks JSON', + fatal=False, + headers={ + 'Referer': url, + 'X-Requested-With': 'XMLHttpRequest', + }, + query={ 'entries': ','.join(missing_track_ids), 'lang': tld, 'external-domain': 'music.yandex.%s' % tld, 'overembed': 'false', 'strict': 'true', - })) - request.add_header('Referer', url) - request.add_header('X-Requested-With', 'XMLHttpRequest') - - missing_tracks = self._download_json( - request, playlist_id, 'Downloading missing tracks JSON', fatal=False) + }) if missing_tracks: tracks.extend(missing_tracks) |