Skip to content

Commit 1075d27

Browse files
committed
Attempt to resolve corner case of songs having None for an album
1 parent ad371fa commit 1075d27

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ytmusic_deleter/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ def remove_library():
179179
except Exception:
180180
logging.exception("Failed to get library singles.")
181181
library_songs = []
182-
# Filter for unique album IDs so that for each song, we can just remove the album its a part of
183-
filtered_songs = list({v["album"]["id"]: v for v in library_songs}.values())
182+
# Filter out songs where album is None (possible rare occurrence seen here: https://github.com/apastel/ytmusic-deleter/issues/12)
183+
filtered_songs = list(filter(lambda song: song["album"], library_songs))
184+
# Filter for unique album IDs so that for each song, we can just remove the album it's a part of
185+
filtered_songs = list({v["album"]["id"]: v for v in filtered_songs}.values())
184186
progress_bar = manager.counter(total=len(filtered_songs), desc="Singles Processed", unit="singles")
185187
albums_removed += remove_library_albums_by_song(filtered_songs, progress_bar)
186188
logging.info(

0 commit comments

Comments
 (0)