Skip to content

Commit

Permalink
show a better error message when encountering issue #109
Browse files Browse the repository at this point in the history
  • Loading branch information
apastel committed Feb 23, 2025
1 parent 2c3bb88 commit c86fc1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ytmusic_deleter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def delete_uploads(ctx: click.Context, **kwargs):
remaining_count = albums_total - albums_deleted
if (ctx.params["add_to_library"]) and remaining_count > 0:
logging.info(
f"\tRemaining {remaining_count} albums (or songs) did not have a match in YouTube Music's online catalog."
f"\tRemaining {remaining_count} albums (or songs) could not be added to your library."
)
logging.info("\tRe-run without the 'Add to library' option to delete the rest.")
return (albums_deleted, albums_total)
Expand Down Expand Up @@ -195,8 +195,10 @@ def remove_library_items(library_items):
logging.debug(f"Removing album using id: {id}")
response = yt_auth.rate_playlist(id, INDIFFERENT)
elif item.get("feedbackTokens") and isinstance(item.get("feedbackTokens"), dict):
print(yt_auth.get_album(item["album"]["id"]))
logging.debug("This is a song, removing item using feedbackTokens")
response = yt_auth.edit_song_library_status([item.get("feedbackTokens").get("remove")])
remove_token = item.get("feedbackTokens").get("remove")
response = yt_auth.edit_song_library_status([remove_token])
else:
logging.error(
f"""
Expand Down
7 changes: 6 additions & 1 deletion ytmusic_deleter/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def scorer(query, choice):
)

catalog_album = yt_auth.get_album(match["browseId"])
success = yt_auth.rate_playlist(catalog_album["audioPlaylistId"], const.LIKE)
audio_playlist_id = catalog_album["audioPlaylistId"]
if not audio_playlist_id:
# https://github.com/apastel/ytmusic-deleter/issues/109
logging.error("\tAlbum is missing 'audioPlaylistId'. Cannot add to library.")
return None
success = yt_auth.rate_playlist(audio_playlist_id, const.LIKE)
if success:
logging.info("\tAdded album to library.")
return match
Expand Down

0 comments on commit c86fc1c

Please sign in to comment.