From daad5e00d8ff02c5a90fc6cf9b7fc081982f3343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sun, 28 Nov 2021 15:12:34 +0100 Subject: [PATCH] Skip songs with id==None (eg locally added song) --- zspotify/app.py | 7 +++++-- zspotify/podcast.py | 2 +- zspotify/track.py | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/zspotify/app.py b/zspotify/app.py index 3bf32fa..2a5c35b 100644 --- a/zspotify/app.py +++ b/zspotify/app.py @@ -49,7 +49,7 @@ def client(args) -> None: if args.liked_songs: for song in get_saved_tracks(): if not song[TRACK][NAME]: - Printer.print(PrintChannel.ERRORS, '### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###' + "\n") + Printer.print(PrintChannel.SKIPS, '### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###' + "\n") else: download_track('liked', song[TRACK][ID]) @@ -83,7 +83,10 @@ def download_from_urls(urls: list[str]) -> bool: playlist_songs = get_playlist_songs(playlist_id) name, _ = get_playlist_info(playlist_id) for song in playlist_songs: - download_track('playlist', song[TRACK][ID], extra_keys={'playlist': name}) + if not song[TRACK][NAME]: + Printer.print(PrintChannel.SKIPS, '### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###' + "\n") + else: + download_track('playlist', song[TRACK][ID], extra_keys={'playlist': name}) elif episode_id is not None: download = True download_episode(episode_id) diff --git a/zspotify/podcast.py b/zspotify/podcast.py index 8337e01..0519314 100644 --- a/zspotify/podcast.py +++ b/zspotify/podcast.py @@ -70,7 +70,7 @@ def download_episode(episode_id) -> None: extra_paths = podcast_name + '/' if podcast_name is None: - Printer.print(PrintChannel.ERRORS, '### SKIPPING: (EPISODE NOT FOUND) ###') + Printer.print(PrintChannel.SKIPS, '### SKIPPING: (EPISODE NOT FOUND) ###') else: filename = podcast_name + ' - ' + episode_name diff --git a/zspotify/track.py b/zspotify/track.py index 5593af2..022e7f2 100644 --- a/zspotify/track.py +++ b/zspotify/track.py @@ -126,6 +126,7 @@ def download_track(mode: str, track_id: str, extra_keys={}, disable_progressbar= except Exception as e: Printer.print(PrintChannel.ERRORS, '### SKIPPING SONG - FAILED TO QUERY METADATA ###') + Printer.print(PrintChannel.ERRORS, 'Track_ID: ' + str(track_id) + "\n") Printer.print(PrintChannel.ERRORS, str(e) + "\n") Printer.print(PrintChannel.ERRORS, "".join(traceback.TracebackException.from_exception(e).format()) + "\n") else: @@ -191,6 +192,7 @@ def download_track(mode: str, track_id: str, extra_keys={}, disable_progressbar= time.sleep(ZSpotify.CONFIG.get_anti_ban_wait_time()) except Exception as e: Printer.print(PrintChannel.ERRORS, '### SKIPPING: ' + song_name + ' (GENERAL DOWNLOAD ERROR) ###') + Printer.print(PrintChannel.ERRORS, 'Track_ID: ' + str(track_id) + "\n") Printer.print(PrintChannel.ERRORS, str(e) + "\n") Printer.print(PrintChannel.ERRORS, "".join(traceback.TracebackException.from_exception(e).format()) + "\n") if os.path.exists(filename_temp):