From 5cc335f5952640fbe93b720d6921f2b51e2a304f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Dec 2025 00:54:28 +0100 Subject: [PATCH] Prepare V0.2 --- zotify/config.py | 19 ++++++------------- zotify/track.py | 3 ++- zotify/utils.py | 25 +++++++++++++++++++------ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/zotify/config.py b/zotify/config.py index 24be4a1..f7b25ac 100644 --- a/zotify/config.py +++ b/zotify/config.py @@ -51,8 +51,8 @@ CONFIG_VALUES = { SONG_ARCHIVE: { 'default': '', 'type': str, 'arg': '--song-archive' }, ROOT_PATH: { 'default': '', 'type': str, 'arg': '--root-path' }, ROOT_PODCAST_PATH: { 'default': '', 'type': str, 'arg': '--root-podcast-path' }, - SPLIT_ALBUM_DISCS: { 'default': 'False', 'type': bool, 'arg': '--split-album-discs' }, - DOWNLOAD_LYRICS: { 'default': 'True', 'type': bool, 'arg': '--download-lyrics' }, + SPLIT_ALBUM_DISCS: { 'default': 'True', 'type': bool, 'arg': '--split-album-discs' }, + DOWNLOAD_LYRICS: { 'default': 'False', 'type': bool, 'arg': '--download-lyrics' }, LYRICS_LOCATION: { 'default': '', 'type': str, 'arg': '--lyrics-location' }, LYRICS_FILENAME: { 'default': '{artist}_{song_name}', 'type': str, 'arg': '--lyrics-filename' }, ALWAYS_CHECK_LYRICS: { 'default': 'False', 'type': bool, 'arg': '--always-check-lyrics' }, @@ -62,7 +62,7 @@ CONFIG_VALUES = { MD_SAVE_GENRES: { 'default': 'False', 'type': bool, 'arg': '--md-save-genres' }, MD_ALLGENRES: { 'default': 'False', 'type': bool, 'arg': '--md-allgenres' }, MD_GENREDELIMITER: { 'default': ',', 'type': str, 'arg': '--md-genredelimiter' }, - DOWNLOAD_FORMAT: { 'default': 'ogg', 'type': str, 'arg': '--download-format' }, + DOWNLOAD_FORMAT: { 'default': 'mp3', 'type': str, 'arg': '--download-format' }, DOWNLOAD_QUALITY: { 'default': 'auto', 'type': str, 'arg': '--download-quality' }, TRANSCODE_BITRATE: { 'default': 'auto', 'type': str, 'arg': '--transcode-bitrate' }, SKIP_EXISTING: { 'default': 'True', 'type': bool, 'arg': '--skip-existing' }, @@ -73,7 +73,7 @@ CONFIG_VALUES = { CHUNK_SIZE: { 'default': '20000', 'type': int, 'arg': '--chunk-size' }, DOWNLOAD_REAL_TIME: { 'default': 'False', 'type': bool, 'arg': '--download-real-time' }, LANGUAGE: { 'default': 'en', 'type': str, 'arg': '--language' }, - PRINT_SPLASH: { 'default': 'False', 'type': bool, 'arg': '--print-splash' }, + PRINT_SPLASH: { 'default': 'True', 'type': bool, 'arg': '--print-splash' }, PRINT_SKIPS: { 'default': 'True', 'type': bool, 'arg': '--print-skips' }, PRINT_DOWNLOAD_PROGRESS: { 'default': 'True', 'type': bool, 'arg': '--print-download-progress' }, PRINT_ERRORS: { 'default': 'True', 'type': bool, 'arg': '--print-errors' }, @@ -86,9 +86,9 @@ CONFIG_VALUES = { } OUTPUT_DEFAULT_PLAYLIST = '{playlist}/{artist} - {song_name}.{ext}' -OUTPUT_DEFAULT_PLAYLIST_EXT = '{playlist}/{playlist_num} - {artist} - {song_name}.{ext}' +OUTPUT_DEFAULT_PLAYLIST_EXT = '{playlist}/{artist} - {song_name}.{ext}' OUTPUT_DEFAULT_LIKED_SONGS = 'Liked Songs/{artist} - {song_name}.{ext}' -OUTPUT_DEFAULT_SINGLE = '{artist}/{album}/{artist} - {song_name}.{ext}' +OUTPUT_DEFAULT_SINGLE = '{artist} - {song_name}.{ext}' OUTPUT_DEFAULT_ALBUM = '{artist}/{album}/{album_num} - {artist} - {song_name}.{ext}' @@ -111,7 +111,6 @@ class Config: true_config_file_path = Path(config_fp).expanduser() - # Load config from zconfig.json Path(PurePath(true_config_file_path).parent).mkdir(parents=True, exist_ok=True) if not Path(true_config_file_path).exists(): with open(true_config_file_path, 'w', encoding='utf-8') as config_file: @@ -123,23 +122,17 @@ class Config: if key in jsonvalues: cls.Values[key] = cls.parse_arg_value(key, jsonvalues[key]) - # Add default values for missing keys - for key in CONFIG_VALUES: if key not in cls.Values: cls.Values[key] = cls.parse_arg_value(key, CONFIG_VALUES[key]['default']) - # Override config from commandline arguments - # Prefer using the argparse-derived dest name from the configured '--long-option' for key in CONFIG_VALUES: arg_flag = CONFIG_VALUES[key]['arg'] dest_name = arg_flag.lstrip('-').replace('-', '_') if isinstance(arg_flag, str) else None args_ns = vars(args) - # 1) Use dest_name if present (e.g., '--unique-file' -> 'unique_file') if dest_name and dest_name in args_ns and args_ns[dest_name] is not None: cls.Values[key] = cls.parse_arg_value(key, args_ns[dest_name]) continue - # 2) Fallback to legacy behavior: key.lower() (e.g., 'LYRICS_FILENAME' -> 'lyrics_filename') if key.lower() in args_ns and args_ns[key.lower()] is not None: cls.Values[key] = cls.parse_arg_value(key, args_ns[key.lower()]) diff --git a/zotify/track.py b/zotify/track.py index 085b957..32734da 100644 --- a/zotify/track.py +++ b/zotify/track.py @@ -272,7 +272,8 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba if not check_id and check_name: c = len([file for file in Path(filedir).iterdir() if re.search(f'^{filename}_', str(file))]) + 1 - stem = PurePath(filename).stem # correct base name without extension + #SpotiClub : Fix phantom files when colliding with existing names (-_.mp3) + stem = PurePath(filename).stem ext = PurePath(filename).suffix filename = PurePath(filedir).joinpath(f'{stem}_{c}{ext}') diff --git a/zotify/utils.py b/zotify/utils.py index 505746c..7f30e88 100644 --- a/zotify/utils.py +++ b/zotify/utils.py @@ -110,12 +110,25 @@ def split_input(selection) -> List[str]: def splash() -> str: """ Displays splash screen """ return """ -███████╗ ██████╗ ████████╗██╗███████╗██╗ ██╗ -╚══███╔╝██╔═══██╗╚══██╔══╝██║██╔════╝╚██╗ ██╔╝ - ███╔╝ ██║ ██║ ██║ ██║█████╗ ╚████╔╝ - ███╔╝ ██║ ██║ ██║ ██║██╔══╝ ╚██╔╝ -███████╗╚██████╔╝ ██║ ██║██║ ██║ -╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ++================================================================+ +| | ███████╗ ██████╗ ████████╗██╗███████╗██╗ ██╗ | | +| | ╚══███╔╝██╔═══██╗╚══██╔══╝██║██╔════╝╚██╗ ██╔╝ | | +| | ███╔╝ ██║ ██║ ██║ ██║█████╗ ╚████╔╝ | | +| | ███╔╝ ██║ ██║ ██║ ██║██╔══╝ ╚██╔╝ | | +| | ███████╗╚██████╔╝ ██║ ██║██║ ██║ | | +| | ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ | | +| ____ _ _ _ __ | +| | _ \ __ _| |_ ___| |__ ___ __| | / _| ___ _ __ | +| | |_) / _` | __/ __| '_ \ / _ \/ _` | | |_ / _ \| '__| | +| | __| (_| | || (__| | | | __| (_| | | _| (_) | | | +| |_| \__,_|\__\___|_| |_|\___|\__,_| |_| \___/|_| | +| ____ _ _ ____ _ _ _ ____ ___ | +|/ ___| _ __ ___ | |_(_)/ ___| |_ _| |__ / \ | _ |_ _|| +|\___ \| '_ \ / _ \| __| | | | | | | | '_ \ / _ \ | |_) | | | +| ___) | |_) | (_) | |_| | |___| | |_| | |_) | / ___ \| __/| | | +||____/| .__/ \___/ \__|_|\____|_|\__,_|_.__/ /_/ \_|_| |___|| +| |_| | ++================================================================+ """