mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-23 00:54:31 +01:00
Fix yandex music extractor
Add track version (such as remix or edit) to title; avoid duplicates and http 414 error when downloading large playlists.
This commit is contained in:
parent
90634acfcf
commit
9bed0af915
@ -98,6 +98,7 @@ class YandexMusicTrackIE(YandexMusicBaseIE):
|
|||||||
'http://music.yandex.ru/handlers/track.jsx?track=%s:%s' % (track_id, album_id),
|
'http://music.yandex.ru/handlers/track.jsx?track=%s:%s' % (track_id, album_id),
|
||||||
track_id, 'Downloading track JSON')['track']
|
track_id, 'Downloading track JSON')['track']
|
||||||
track_title = track['title']
|
track_title = track['title']
|
||||||
|
if 'version' in track: track_title += ' (%s)' % track['version']
|
||||||
|
|
||||||
download_data = self._download_json(
|
download_data = self._download_json(
|
||||||
'https://music.yandex.ru/api/v2.1/handlers/track/%s:%s/web-album_track-track-track-main/download/m' % (track_id, album_id),
|
'https://music.yandex.ru/api/v2.1/handlers/track/%s:%s/web-album_track-track-track-main/download/m' % (track_id, album_id),
|
||||||
@ -288,22 +289,24 @@ class YandexMusicPlaylistIE(YandexMusicPlaylistBaseIE):
|
|||||||
for track in tracks if track.get('id')])
|
for track in tracks if track.get('id')])
|
||||||
missing_track_ids = [
|
missing_track_ids = [
|
||||||
track_id for track_id in track_ids
|
track_id for track_id in track_ids
|
||||||
if track_id not in present_track_ids]
|
if track_id.split(':')[0] not in present_track_ids]
|
||||||
missing_tracks = self._download_json(
|
missing_tracks = []
|
||||||
'https://music.yandex.%s/handlers/track-entries.jsx' % tld,
|
for i in range(0, len(missing_track_ids), 500):
|
||||||
playlist_id, 'Downloading missing tracks JSON',
|
missing_tracks += self._download_json(
|
||||||
fatal=False,
|
'https://music.yandex.%s/handlers/track-entries.jsx' % tld,
|
||||||
headers={
|
playlist_id, 'Downloading missing tracks JSON',
|
||||||
'Referer': url,
|
fatal=False,
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
headers={
|
||||||
},
|
'Referer': url,
|
||||||
query={
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
'entries': ','.join(missing_track_ids),
|
},
|
||||||
'lang': tld,
|
query={
|
||||||
'external-domain': 'music.yandex.%s' % tld,
|
'entries': ','.join(missing_track_ids[i:i+500]),
|
||||||
'overembed': 'false',
|
'lang': tld,
|
||||||
'strict': 'true',
|
'external-domain': 'music.yandex.%s' % tld,
|
||||||
})
|
'overembed': 'false',
|
||||||
|
'strict': 'true',
|
||||||
|
})
|
||||||
if missing_tracks:
|
if missing_tracks:
|
||||||
tracks.extend(missing_tracks)
|
tracks.extend(missing_tracks)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user