Prepare V0.2

This commit is contained in:
unknown
2025-12-18 00:54:28 +01:00
parent e9b8050ffc
commit 5cc335f595
3 changed files with 27 additions and 20 deletions

View File

@@ -51,8 +51,8 @@ CONFIG_VALUES = {
SONG_ARCHIVE: { 'default': '', 'type': str, 'arg': '--song-archive' }, SONG_ARCHIVE: { 'default': '', 'type': str, 'arg': '--song-archive' },
ROOT_PATH: { 'default': '', 'type': str, 'arg': '--root-path' }, ROOT_PATH: { 'default': '', 'type': str, 'arg': '--root-path' },
ROOT_PODCAST_PATH: { 'default': '', 'type': str, 'arg': '--root-podcast-path' }, ROOT_PODCAST_PATH: { 'default': '', 'type': str, 'arg': '--root-podcast-path' },
SPLIT_ALBUM_DISCS: { 'default': 'False', 'type': bool, 'arg': '--split-album-discs' }, SPLIT_ALBUM_DISCS: { 'default': 'True', 'type': bool, 'arg': '--split-album-discs' },
DOWNLOAD_LYRICS: { 'default': 'True', 'type': bool, 'arg': '--download-lyrics' }, DOWNLOAD_LYRICS: { 'default': 'False', 'type': bool, 'arg': '--download-lyrics' },
LYRICS_LOCATION: { 'default': '', 'type': str, 'arg': '--lyrics-location' }, LYRICS_LOCATION: { 'default': '', 'type': str, 'arg': '--lyrics-location' },
LYRICS_FILENAME: { 'default': '{artist}_{song_name}', 'type': str, 'arg': '--lyrics-filename' }, LYRICS_FILENAME: { 'default': '{artist}_{song_name}', 'type': str, 'arg': '--lyrics-filename' },
ALWAYS_CHECK_LYRICS: { 'default': 'False', 'type': bool, 'arg': '--always-check-lyrics' }, 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_SAVE_GENRES: { 'default': 'False', 'type': bool, 'arg': '--md-save-genres' },
MD_ALLGENRES: { 'default': 'False', 'type': bool, 'arg': '--md-allgenres' }, MD_ALLGENRES: { 'default': 'False', 'type': bool, 'arg': '--md-allgenres' },
MD_GENREDELIMITER: { 'default': ',', 'type': str, 'arg': '--md-genredelimiter' }, 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' }, DOWNLOAD_QUALITY: { 'default': 'auto', 'type': str, 'arg': '--download-quality' },
TRANSCODE_BITRATE: { 'default': 'auto', 'type': str, 'arg': '--transcode-bitrate' }, TRANSCODE_BITRATE: { 'default': 'auto', 'type': str, 'arg': '--transcode-bitrate' },
SKIP_EXISTING: { 'default': 'True', 'type': bool, 'arg': '--skip-existing' }, SKIP_EXISTING: { 'default': 'True', 'type': bool, 'arg': '--skip-existing' },
@@ -73,7 +73,7 @@ CONFIG_VALUES = {
CHUNK_SIZE: { 'default': '20000', 'type': int, 'arg': '--chunk-size' }, CHUNK_SIZE: { 'default': '20000', 'type': int, 'arg': '--chunk-size' },
DOWNLOAD_REAL_TIME: { 'default': 'False', 'type': bool, 'arg': '--download-real-time' }, DOWNLOAD_REAL_TIME: { 'default': 'False', 'type': bool, 'arg': '--download-real-time' },
LANGUAGE: { 'default': 'en', 'type': str, 'arg': '--language' }, 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_SKIPS: { 'default': 'True', 'type': bool, 'arg': '--print-skips' },
PRINT_DOWNLOAD_PROGRESS: { 'default': 'True', 'type': bool, 'arg': '--print-download-progress' }, PRINT_DOWNLOAD_PROGRESS: { 'default': 'True', 'type': bool, 'arg': '--print-download-progress' },
PRINT_ERRORS: { 'default': 'True', 'type': bool, 'arg': '--print-errors' }, 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 = '{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_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}' 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() 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) Path(PurePath(true_config_file_path).parent).mkdir(parents=True, exist_ok=True)
if not Path(true_config_file_path).exists(): if not Path(true_config_file_path).exists():
with open(true_config_file_path, 'w', encoding='utf-8') as config_file: with open(true_config_file_path, 'w', encoding='utf-8') as config_file:
@@ -123,23 +122,17 @@ class Config:
if key in jsonvalues: if key in jsonvalues:
cls.Values[key] = cls.parse_arg_value(key, jsonvalues[key]) cls.Values[key] = cls.parse_arg_value(key, jsonvalues[key])
# Add default values for missing keys
for key in CONFIG_VALUES: for key in CONFIG_VALUES:
if key not in cls.Values: if key not in cls.Values:
cls.Values[key] = cls.parse_arg_value(key, CONFIG_VALUES[key]['default']) 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: for key in CONFIG_VALUES:
arg_flag = CONFIG_VALUES[key]['arg'] arg_flag = CONFIG_VALUES[key]['arg']
dest_name = arg_flag.lstrip('-').replace('-', '_') if isinstance(arg_flag, str) else None dest_name = arg_flag.lstrip('-').replace('-', '_') if isinstance(arg_flag, str) else None
args_ns = vars(args) 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: 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]) cls.Values[key] = cls.parse_arg_value(key, args_ns[dest_name])
continue 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: 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()]) cls.Values[key] = cls.parse_arg_value(key, args_ns[key.lower()])

View File

@@ -272,7 +272,8 @@ def download_track(mode: str, track_id: str, extra_keys=None, disable_progressba
if not check_id and check_name: if not check_id and check_name:
c = len([file for file in Path(filedir).iterdir() if re.search(f'^{filename}_', str(file))]) + 1 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 ext = PurePath(filename).suffix
filename = PurePath(filedir).joinpath(f'{stem}_{c}{ext}') filename = PurePath(filedir).joinpath(f'{stem}_{c}{ext}')

View File

@@ -110,12 +110,25 @@ def split_input(selection) -> List[str]:
def splash() -> str: def splash() -> str:
""" Displays splash screen """ """ Displays splash screen """
return """ return """
███████╗ ██████╗ ████████╗██╗███████╗██╗ ██╗ +================================================================+
╚══███╔╝██╔═══██╗╚══██╔══╝████╔════╝╚██╗ ██╔╝ | | ███████╗ ██████╗ ████████╗██╗███████╗██╗ ██╗ | |
███╔╝ ██║ ██║ ██║ ██║█████╗ ╚████╔╝ | | ╚══███╔╝██╔═══██╗╚══██╔══╝██║██╔════╝╚██╗ ██╔╝ | |
███╔╝ ██║ ██║ ██║ ██║██╔══╝ ╚██╔╝ | | ███╔╝ ██║ ██║ ██║ ██║█████╗ ╚████╔╝ | |
███████╗╚██████╔╝ ██║ ██║██║ ██║ | | ███╔╝ ██║ ██║ ██║ ██║██╔══╝ ╚██╔╝ | |
╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ | | ███████╗╚██████╔╝ ██║ ██║██║ ██║ | |
| | ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ | |
| ____ _ _ _ __ |
| | _ \ __ _| |_ ___| |__ ___ __| | / _| ___ _ __ |
| | |_) / _` | __/ __| '_ \ / _ \/ _` | | |_ / _ \| '__| |
| | __| (_| | || (__| | | | __| (_| | | _| (_) | | |
| |_| \__,_|\__\___|_| |_|\___|\__,_| |_| \___/|_| |
| ____ _ _ ____ _ _ _ ____ ___ |
|/ ___| _ __ ___ | |_(_)/ ___| |_ _| |__ / \ | _ |_ _||
|\___ \| '_ \ / _ \| __| | | | | | | | '_ \ / _ \ | |_) | | |
| ___) | |_) | (_) | |_| | |___| | |_| | |_) | / ___ \| __/| | |
||____/| .__/ \___/ \__|_|\____|_|\__,_|_.__/ /_/ \_|_| |___||
| |_| |
+================================================================+
""" """