Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XDG Base Directory for storing data #204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,20 @@ def log_ignored_line(line_number, message):
data_dir = os.path.normpath('./data')
else:
print("Running in non-portable mode")
settings_dir = os.path.expanduser(os.path.normpath("~/.youtube-local"))
data_dir = os.path.expanduser(os.path.normpath("~/.youtube-local/data"))
settings_dir = os.path.expanduser(os.path.normpath('~/.local/share/youtube-local'))
old_settings_dir = os.path.expanduser(os.path.normpath('~/.youtube-local'))

# use XDG_DATA_HOME variable if defined
if os.getenv('XDG_DATA_HOME'):
settings_dir = os.path.normpath(
os.path.join(os.getenv('XDG_DATA_HOME'), 'youtube-local'))

# use old ~/.youtube-local directory if settings.txt is found
if not os.path.exists(os.path.join(settings_dir, 'settings.txt')):
if os.path.exists(os.path.join(old_settings_dir, 'settings.txt')):
settings_dir = old_settings_dir

data_dir = os.path.join(settings_dir, 'data')
if not os.path.exists(settings_dir):
os.makedirs(settings_dir)

Expand Down