diff options
Diffstat (limited to 'zspotify-paths.patch')
-rw-r--r-- | zspotify-paths.patch | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/zspotify-paths.patch b/zspotify-paths.patch new file mode 100644 index 000000000000..6888bb1f5534 --- /dev/null +++ b/zspotify-paths.patch @@ -0,0 +1,102 @@ +--- a/zspotify/config.py ++++ b/zspotify/config.py +@@ -2,7 +2,7 @@ import json + import os + from typing import Any + +-CONFIG_FILE_PATH = '../zs_config.json' ++CONFIG_FILE_PATH = '~/.local/share/zspotify/zs_config.json' + + ROOT_PATH = 'ROOT_PATH' + ROOT_PODCAST_PATH = 'ROOT_PODCAST_PATH' +@@ -34,8 +34,8 @@ PRINT_WARNINGS = 'PRINT_WARNINGS' + RETRY_ATTEMPTS = 'RETRY_ATTEMPTS' + + CONFIG_VALUES = { +- ROOT_PATH: { 'default': '../ZSpotify Music/', 'type': str, 'arg': '--root-path' }, +- ROOT_PODCAST_PATH: { 'default': '../ZSpotify Podcasts/', 'type': str, 'arg': '--root-podcast-path' }, ++ ROOT_PATH: { 'default': './', 'type': str, 'arg': '--root-path' }, ++ ROOT_PODCAST_PATH: { 'default': './', 'type': str, 'arg': '--root-podcast-path' }, + SKIP_EXISTING_FILES: { 'default': 'True', 'type': bool, 'arg': '--skip-existing-files' }, + SKIP_PREVIOUSLY_DOWNLOADED: { 'default': 'False', 'type': bool, 'arg': '--skip-previously-downloaded' }, + RETRY_ATTEMPTS: { 'default': '5', 'type': int, 'arg': '--retry-attemps' }, +@@ -43,14 +43,14 @@ CONFIG_VALUES = { + FORCE_PREMIUM: { 'default': 'False', 'type': bool, 'arg': '--force-premium' }, + ANTI_BAN_WAIT_TIME: { 'default': '1', 'type': int, 'arg': '--anti-ban-wait-time' }, + OVERRIDE_AUTO_WAIT: { 'default': 'False', 'type': bool, 'arg': '--override-auto-wait' }, +- CHUNK_SIZE: { 'default': '50000', 'type': int, 'arg': '--chunk-size' }, ++ CHUNK_SIZE: { 'default': 50000, 'type': int, 'arg': '--chunk-size' }, + SPLIT_ALBUM_DISCS: { 'default': 'False', 'type': bool, 'arg': '--split-album-discs' }, + DOWNLOAD_REAL_TIME: { 'default': 'False', 'type': bool, 'arg': '--download-real-time' }, + LANGUAGE: { 'default': 'en', 'type': str, 'arg': '--language' }, + BITRATE: { 'default': '', 'type': str, 'arg': '--bitrate' }, + SONG_ARCHIVE: { 'default': '.song_archive', 'type': str, 'arg': '--song-archive' }, +- CREDENTIALS_LOCATION: { 'default': 'credentials.json', 'type': str, 'arg': '--credentials-location' }, +- OUTPUT: { 'default': '', 'type': str, 'arg': '--output' }, ++ CREDENTIALS_LOCATION: { 'default': '~/.local/share/zspotify/credentials.json', 'type': str, 'arg': '--credentials-location' }, ++ OUTPUT: { 'default': '{artist} - {song_name}.ogg','type': str, 'arg': '--output' }, + PRINT_SPLASH: { 'default': 'False', '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' }, +@@ -82,11 +82,12 @@ class Config: + if args.config_location: + config_fp = args.config_location + +- true_config_file_path = os.path.join(app_dir, config_fp) ++ true_config_file_path = os.path.expanduser(config_fp) + + # Load config from zs_config.json + + if not os.path.exists(true_config_file_path): ++ os.makedirs(os.path.dirname(true_config_file_path), exist_ok=True) + with open(true_config_file_path, 'w', encoding='utf-8') as config_file: + json.dump(cls.get_default_json(), config_file, indent=4) + cls.Values = cls.get_default_json() +@@ -142,11 +143,11 @@ class Config: + + @classmethod + def get_root_path(cls) -> str: +- return os.path.join(os.path.dirname(__file__), cls.get(ROOT_PATH)) ++ return os.path.expanduser(cls.get(ROOT_PATH)) + + @classmethod + def get_root_podcast_path(cls) -> str: +- return os.path.join(os.path.dirname(__file__), cls.get(ROOT_PODCAST_PATH)) ++ return os.path.expanduser(cls.get(ROOT_PODCAST_PATH)) + + @classmethod + def get_skip_existing_files(cls) -> bool: +@@ -194,17 +195,17 @@ class Config: + + @classmethod + def get_song_archive(cls) -> str: +- return os.path.join(cls.get_root_path(), cls.get(SONG_ARCHIVE)) ++ return os.path.expanduser(cls.get(SONG_ARCHIVE)) + + @classmethod + def get_credentials_location(cls) -> str: +- return os.path.join(os.getcwd(), cls.get(CREDENTIALS_LOCATION)) ++ return os.path.expanduser(cls.get(CREDENTIALS_LOCATION)) + + @classmethod + def get_temp_download_dir(cls) -> str: + if cls.get(TEMP_DOWNLOAD_DIR) == '': + return '' +- return os.path.join(cls.get_root_path(), cls.get(TEMP_DOWNLOAD_DIR)) ++ return os.path.expanduser(cls.get(TEMP_DOWNLOAD_DIR)) + + @classmethod + def get_all_genres(cls) -> bool: +--- a/zspotify/zspotify.py ++++ b/zspotify/zspotify.py +@@ -28,7 +28,9 @@ class ZSpotify: + + if os.path.isfile(cred_location): + try: +- cls.SESSION = Session.Builder().stored_file(cred_location).create() ++ Session.Configuration.stored_credentials_file = cred_location ++ Session.Configuration.Builder.stored_credentials_file = cred_location ++ cls.SESSION = Session.Builder().stored_file().create() + return + except RuntimeError: + pass |