mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 03:54:21 +01:00
set TrackInfo.index in track_for_id
This commit is contained in:
parent
f61aacf04b
commit
b4d54b0950
1 changed files with 19 additions and 5 deletions
|
|
@ -229,14 +229,28 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
:return: TrackInfo object for track
|
||||
:rtype: beets.autotag.hooks.TrackInfo
|
||||
"""
|
||||
spotify_id = self._get_spotify_id('track', track_id)
|
||||
if spotify_id is None:
|
||||
spotify_id_track = self._get_spotify_id('track', track_id)
|
||||
if spotify_id_track is None:
|
||||
return None
|
||||
|
||||
response = self._handle_response(
|
||||
requests.get, self.track_url + spotify_id
|
||||
response_track = self._handle_response(
|
||||
requests.get, self.track_url + spotify_id_track
|
||||
)
|
||||
return self._get_track(response.json())
|
||||
response_data_track = response_track.json()
|
||||
track = self._get_track(response_data_track)
|
||||
|
||||
# get album tracks set index/position on entire release
|
||||
spotify_id_album = response_track['album']['id']
|
||||
response_album = self._handle_response(
|
||||
requests.get, self.album_url + spotify_id_album
|
||||
)
|
||||
response_data_album = response_album.json()
|
||||
for i, track_data in enumerate(response_data_album['tracks']['items']):
|
||||
if track_data['id'] == spotify_id_track:
|
||||
track.index = i + 1
|
||||
break
|
||||
|
||||
return track
|
||||
|
||||
def _get_artist(self, artists):
|
||||
"""Returns an artist string (all artists) and an artist_id (the main
|
||||
|
|
|
|||
Loading…
Reference in a new issue