Update client.py
This commit is contained in:
parent
6eb472d774
commit
c3e0012762
|
|
@ -74,21 +74,20 @@ class Client:
|
||||||
return Track(data)
|
return Track(data)
|
||||||
elif spotify_type == "album":
|
elif spotify_type == "album":
|
||||||
return Album(data)
|
return Album(data)
|
||||||
|
else:
|
||||||
|
tracks = [Track(track["track"]) for track in data["tracks"]["items"]]
|
||||||
|
next_page_url = data["tracks"]["next"]
|
||||||
|
|
||||||
# processing a playlist result
|
while next_page_url is not None:
|
||||||
tracks = [Track(track["track"]) for track in data["tracks"]["items"]]
|
async with self.session.get(next_page_url, headers=self._bearer_headers) as resp:
|
||||||
next_page_url = data["tracks"]["next"]
|
if resp.status != 200:
|
||||||
|
raise SpotifyRequestException(
|
||||||
|
f"Error while fetching results: {resp.status} {resp.reason}"
|
||||||
|
)
|
||||||
|
|
||||||
while next_page_url is not None:
|
next_data: dict = await resp.json()
|
||||||
async with self.session.get(next_page_url, headers=self._bearer_headers) as resp:
|
|
||||||
if resp.status != 200:
|
|
||||||
raise SpotifyRequestException(
|
|
||||||
f"Error while fetching results: {resp.status} {resp.reason}"
|
|
||||||
)
|
|
||||||
|
|
||||||
next_data: dict = await resp.json()
|
tracks += [Track(track["track"]) for track in next_data["items"]]
|
||||||
|
next_page_url = next_data["next"]
|
||||||
|
|
||||||
tracks += [Track(track["track"]) for track in next_data["items"]]
|
return Playlist(data, tracks)
|
||||||
next_page_url = next_data["next"]
|
|
||||||
|
|
||||||
return Playlist(data, tracks)
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue