mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2024-11-26 09:53:17 +01:00
Merge pull request #115 from el-gringo-alto/generate_settings
Generate settings when running for the first time
This commit is contained in:
commit
3b00dee972
@ -95,3 +95,15 @@ OVERRIDE_AUTO_WAIT = 'OVERRIDE_AUTO_WAIT'
|
|||||||
CHUNK_SIZE = 'CHUNK_SIZE'
|
CHUNK_SIZE = 'CHUNK_SIZE'
|
||||||
|
|
||||||
SPLIT_ALBUM_DISCS = 'SPLIT_ALBUM_DISCS'
|
SPLIT_ALBUM_DISCS = 'SPLIT_ALBUM_DISCS'
|
||||||
|
|
||||||
|
CONFIG_DEFAULT_SETTINGS = {
|
||||||
|
'ROOT_PATH': '../ZSpotify Music/',
|
||||||
|
'ROOT_PODCAST_PATH': '../ZSpotify Podcasts/',
|
||||||
|
'SKIP_EXISTING_FILES': True,
|
||||||
|
'DOWNLOAD_FORMAT': 'mp3',
|
||||||
|
'FORCE_PREMIUM': False,
|
||||||
|
'ANTI_BAN_WAIT_TIME': 1,
|
||||||
|
'OVERRIDE_AUTO_WAIT': False,
|
||||||
|
'CHUNK_SIZE': 50000,
|
||||||
|
'SPLIT_ALBUM_DISCS': False
|
||||||
|
}
|
||||||
|
@ -18,7 +18,7 @@ from librespot.core import Session
|
|||||||
|
|
||||||
from const import CREDENTIALS_JSON, TYPE, \
|
from const import CREDENTIALS_JSON, TYPE, \
|
||||||
PREMIUM, USER_READ_EMAIL, AUTHORIZATION, OFFSET, LIMIT, CONFIG_FILE_PATH, FORCE_PREMIUM, \
|
PREMIUM, USER_READ_EMAIL, AUTHORIZATION, OFFSET, LIMIT, CONFIG_FILE_PATH, FORCE_PREMIUM, \
|
||||||
PLAYLIST_READ_PRIVATE
|
PLAYLIST_READ_PRIVATE, CONFIG_DEFAULT_SETTINGS
|
||||||
from utils import MusicFormat
|
from utils import MusicFormat
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,13 @@ class ZSpotify:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load_config(cls) -> None:
|
def load_config(cls) -> None:
|
||||||
app_dir = os.path.dirname(__file__)
|
app_dir = os.path.dirname(__file__)
|
||||||
with open(os.path.join(app_dir, CONFIG_FILE_PATH), encoding='utf-8') as config_file:
|
true_config_file_path = os.path.join(app_dir, CONFIG_FILE_PATH)
|
||||||
|
if not os.path.exists(true_config_file_path):
|
||||||
|
with open(true_config_file_path, 'w', encoding='utf-8') as config_file:
|
||||||
|
json.dump(CONFIG_DEFAULT_SETTINGS, config_file, indent=4)
|
||||||
|
cls.CONFIG = CONFIG_DEFAULT_SETTINGS
|
||||||
|
else:
|
||||||
|
with open(true_config_file_path, encoding='utf-8') as config_file:
|
||||||
cls.CONFIG = json.load(config_file)
|
cls.CONFIG = json.load(config_file)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user