From fcc3c564c1ef8cd888e553e90339ea8bb2229fb4 Mon Sep 17 00:00:00 2001 From: ryansereno Date: Tue, 28 Nov 2023 09:28:33 -0500 Subject: [PATCH 1/3] compile archive file by default --- zotify/track.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zotify/track.py b/zotify/track.py index bb2af89..9280a14 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -274,7 +274,7 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba Printer.print(PrintChannel.DOWNLOADS, f'### Downloaded "{song_name}" to "{Path(filename).relative_to(Zotify.CONFIG.get_root_path())}" in {fmt_seconds(time_downloaded - time_start)} (plus {fmt_seconds(time_finished - time_downloaded)} converting) ###' + "\n") # add song id to archive file - if Zotify.CONFIG.get_skip_previously_downloaded(): + if not check_all_time: add_to_archive(scraped_song_id, PurePath(filename).name, artists[0], name) # add song id to download directory's .song_ids file if not check_id: From 0e9cb3b78dd22bae4544799b5fe2034ae84c85c3 Mon Sep 17 00:00:00 2001 From: ryansereno Date: Wed, 13 Dec 2023 21:42:16 -0500 Subject: [PATCH 2/3] sort playlist tracks by date-added --- zotify/playlist.py | 4 +++- zotify/utils.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zotify/playlist.py b/zotify/playlist.py index 53c1941..682688e 100644 --- a/zotify/playlist.py +++ b/zotify/playlist.py @@ -1,7 +1,7 @@ from zotify.const import ITEMS, ID, TRACK, NAME from zotify.termoutput import Printer from zotify.track import download_track -from zotify.utils import split_input +from zotify.utils import split_input, strptime_utc from zotify.zotify import Zotify MY_PLAYLISTS_URL = 'https://api.spotify.com/v1/me/playlists' @@ -37,6 +37,8 @@ def get_playlist_songs(playlist_id): if len(resp[ITEMS]) < limit: break + songs.sort(key=lambda s: strptime_utc(s['added_at']), reverse=True) + return songs diff --git a/zotify/utils.py b/zotify/utils.py index df8a661..a6129aa 100644 --- a/zotify/utils.py +++ b/zotify/utils.py @@ -282,3 +282,7 @@ def fmt_seconds(secs: float) -> str: return f'{m}'.zfill(2) + ':' + f'{s}'.zfill(2) else: return f'{h}'.zfill(2) + ':' + f'{m}'.zfill(2) + ':' + f'{s}'.zfill(2) + +def strptime_utc(dtstr): + return datetime.datetime.strptime(dtstr[:-1], '%Y-%m-%dT%H:%M:%S').replace(tzinfo=datetime.timezone.utc) + From 5111aad95595beb865164e2fbd90d468a7845c0d Mon Sep 17 00:00:00 2001 From: ryansereno Date: Wed, 13 Dec 2023 21:46:13 -0500 Subject: [PATCH 3/3] reverted --- zotify/track.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zotify/track.py b/zotify/track.py index 9280a14..bb2af89 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -274,7 +274,7 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba Printer.print(PrintChannel.DOWNLOADS, f'### Downloaded "{song_name}" to "{Path(filename).relative_to(Zotify.CONFIG.get_root_path())}" in {fmt_seconds(time_downloaded - time_start)} (plus {fmt_seconds(time_finished - time_downloaded)} converting) ###' + "\n") # add song id to archive file - if not check_all_time: + if Zotify.CONFIG.get_skip_previously_downloaded(): add_to_archive(scraped_song_id, PurePath(filename).name, artists[0], name) # add song id to download directory's .song_ids file if not check_id: