Check for IndexError in case artworkUrl doesn't exist
This commit is contained in:
parent
ebe1d8fe53
commit
319fdc62f2
@ -126,6 +126,10 @@ class SpotifySource(Source):
|
|||||||
for track in metadata["tracks"][
|
for track in metadata["tracks"][
|
||||||
"items"
|
"items"
|
||||||
]: # Loop through each track in the playlist.
|
]: # Loop through each track in the playlist.
|
||||||
|
try:
|
||||||
|
artwork_url = track["track"]["album"]["images"][0]["url"]
|
||||||
|
except IndexError:
|
||||||
|
artwork_url = None
|
||||||
tracks.append(
|
tracks.append(
|
||||||
CustomAudioTrack(
|
CustomAudioTrack(
|
||||||
{ # Create an instance of our CustomAudioTrack.
|
{ # Create an instance of our CustomAudioTrack.
|
||||||
@ -139,9 +143,7 @@ class SpotifySource(Source):
|
|||||||
"title": track["track"]["name"],
|
"title": track["track"]["name"],
|
||||||
"uri": track["track"]["external_urls"]["spotify"],
|
"uri": track["track"]["external_urls"]["spotify"],
|
||||||
"duration": track["track"]["duration_ms"],
|
"duration": track["track"]["duration_ms"],
|
||||||
"artworkUrl": track["track"]["album"]["images"][0][
|
"artworkUrl": artwork_url,
|
||||||
"url"
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
requster=user,
|
requster=user,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user