Use appdirs to figure out user config directory

This commit is contained in:
Ritiek Malhotra
2018-08-19 19:32:22 +05:30
parent 5b4efa05b6
commit dd81f80fda
3 changed files with 8 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
import appdirs
from core import internals, const from core import internals, const
log = const.log log = const.log
@@ -79,7 +80,9 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
if to_merge: if to_merge:
config_file = os.path.join(sys.path[0], 'config.yml') config_dir = os.path.join(appdirs.user_config_dir(), 'spotdl')
os.makedirs(config_dir, exist_ok=True)
config_file = os.path.join(config_dir, 'config.yml')
config = merge(default_conf['spotify-downloader'], get_config(config_file)) config = merge(default_conf['spotify-downloader'], get_config(config_file))
else: else:
config = default_conf['spotify-downloader'] config = default_conf['spotify-downloader']
@@ -175,8 +178,7 @@ def get_arguments(raw_args=None, to_group=True, to_merge=True):
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument( parser.add_argument(
'-c', '--config', default=None, '-c', '--config', default=None,
help='path to config.yml file (otherwise load it from same ' help='path to custom config.yml file')
'directory as spotdl.py)')
parsed = parser.parse_args(raw_args) parsed = parser.parse_args(raw_args)

View File

@@ -9,3 +9,4 @@ titlecase >= 0.10.0
logzero >= 1.3.1 logzero >= 1.3.1
lyricwikia >= 0.1.8 lyricwikia >= 0.1.8
PyYAML >= 3.12 PyYAML >= 3.12
appdirs >= 1.4.3

View File

@@ -35,7 +35,8 @@ setup(
'titlecase >= 0.10.0', 'titlecase >= 0.10.0',
'logzero >= 1.3.1', 'logzero >= 1.3.1',
'lyricwikia >= 0.1.8', 'lyricwikia >= 0.1.8',
'PyYAML >= 3.12' 'PyYAML >= 3.12',
'appdirs >= 1.4.3'
], ],
description='Download songs from YouTube using Spotify song URLs or playlists with albumart and meta-tags.', description='Download songs from YouTube using Spotify song URLs or playlists with albumart and meta-tags.',
long_description=long_description, long_description=long_description,