diff --git a/youtube_dl_gui/OptionsHandler.py b/youtube_dl_gui/OptionsHandler.py index dc4a70d..bdb2e87 100644 --- a/youtube_dl_gui/OptionsHandler.py +++ b/youtube_dl_gui/OptionsHandler.py @@ -2,7 +2,10 @@ import json +from data import __appname__ + from .Utils import ( + get_user_config_path, get_HOME, file_exist, os_type, @@ -11,8 +14,7 @@ from .Utils import ( ) SETTINGS_FILENAME = 'settings.json' -LINUX_FILES_PATH = get_HOME() + '/.youtube-dl-gui' -WINDOWS_FILES_PATH = get_HOME() + '\\youtube-dl-gui' +CONFIG_PATH = fix_path(get_user_config_path()) + __appname__.lower() class OptionsHandler(): @@ -73,9 +75,7 @@ class OptionsHandler(): } def get_config_path(self): - if os_type == 'nt': - return WINDOWS_FILES_PATH - return LINUX_FILES_PATH + return CONFIG_PATH def set_settings_path(self): self.settings_abs_path = fix_path(self.get_config_path()) + SETTINGS_FILENAME diff --git a/youtube_dl_gui/Utils.py b/youtube_dl_gui/Utils.py index c188aa8..7eaaba9 100644 --- a/youtube_dl_gui/Utils.py +++ b/youtube_dl_gui/Utils.py @@ -86,6 +86,13 @@ def check_path(path): if not file_exist(path): makedir(path) +def get_user_config_path(): + if os_type == 'nt': + path = os.getenv('APPDATA') + else: + path = fix_path(get_HOME()) + '.config' + return path + def shutdown_sys(password=''): if os_type == 'nt': subprocess.call(['shutdown', '/s', '/t', '1'])