aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-29 22:25:17 -0600
committerParker <contact@pkrm.dev>2024-11-29 22:25:17 -0600
commit319fdc62f2bb944c441cb39057ff5b60e829fe51 (patch)
treec207848befabb0645a4b0739545876c2dacb91a3 /code
parentebe1d8fe5399b70368fc8d3055dd9201ee632fc5 (diff)
Check for IndexError in case artworkUrl doesn't exist
Diffstat (limited to 'code')
-rw-r--r--code/utils/custom_sources.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/code/utils/custom_sources.py b/code/utils/custom_sources.py
index 50f0228..ed00c66 100644
--- a/code/utils/custom_sources.py
+++ b/code/utils/custom_sources.py
@@ -126,6 +126,10 @@ class SpotifySource(Source):
for track in metadata["tracks"][
"items"
]: # Loop through each track in the playlist.
+ try:
+ artwork_url = track["track"]["album"]["images"][0]["url"]
+ except IndexError:
+ artwork_url = None
tracks.append(
CustomAudioTrack(
{ # Create an instance of our CustomAudioTrack.
@@ -139,9 +143,7 @@ class SpotifySource(Source):
"title": track["track"]["name"],
"uri": track["track"]["external_urls"]["spotify"],
"duration": track["track"]["duration_ms"],
- "artworkUrl": track["track"]["album"]["images"][0][
- "url"
- ],
+ "artworkUrl": artwork_url,
},
requster=user,
)