1
0
Fork 0
mirror of https://gitlab.com/dstftw/youtube-dl.git synced 2020-11-16 09:42:26 +00:00

[yandexmusic:playlist] Modernize

This commit is contained in:
Sergey M․ 2016-05-04 22:33:29 +06:00
parent e960c3c223
commit 15fc0658f7
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -231,20 +231,21 @@ class YandexMusicPlaylistIE(YandexMusicPlaylistBaseIE):
if len(tracks) < len(track_ids): if len(tracks) < len(track_ids):
present_track_ids = set([compat_str(track['id']) for track in tracks if track.get('id')]) 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) missing_track_ids = set(map(compat_str, track_ids)) - set(present_track_ids)
request = sanitized_Request( missing_tracks = self._download_json(
'https://music.yandex.ru/handlers/track-entries.jsx', 'https://music.yandex.%s/handlers/track-entries.jsx' % tld,
urlencode_postdata({ playlist_id, 'Downloading missing tracks JSON',
fatal=False,
headers={
'Referer': url,
'X-Requested-With': 'XMLHttpRequest',
},
query={
'entries': ','.join(missing_track_ids), 'entries': ','.join(missing_track_ids),
'lang': tld, 'lang': tld,
'external-domain': 'music.yandex.%s' % tld, 'external-domain': 'music.yandex.%s' % tld,
'overembed': 'false', 'overembed': 'false',
'strict': 'true', '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: if missing_tracks:
tracks.extend(missing_tracks) tracks.extend(missing_tracks)