2020-09-27 21:44:37 +00:00
|
|
|
from pathlib import Path
|
2020-04-17 10:31:47 +00:00
|
|
|
import sys
|
2020-10-29 12:00:58 +00:00
|
|
|
import os
|
2020-02-20 14:42:12 +00:00
|
|
|
|
2020-09-27 21:44:37 +00:00
|
|
|
homedata = Path.home()
|
2020-10-29 12:00:58 +00:00
|
|
|
userdata = ""
|
|
|
|
musicdata = ""
|
|
|
|
|
2020-02-20 14:42:12 +00:00
|
|
|
|
2020-12-02 16:57:17 +00:00
|
|
|
if os.getenv("DEEMIX_DATA_DIR"):
|
|
|
|
userdata = Path(os.getenv("DEEMIX_DATA_DIR"))
|
|
|
|
elif os.getenv("XDG_CONFIG_HOME"):
|
2020-10-29 12:00:58 +00:00
|
|
|
userdata = Path(os.getenv("XDG_CONFIG_HOME")) / 'deemix'
|
|
|
|
elif os.getenv("APPDATA"):
|
|
|
|
userdata = Path(os.getenv("APPDATA")) / "deemix"
|
2020-02-20 14:42:12 +00:00
|
|
|
elif sys.platform.startswith('darwin'):
|
2020-09-27 21:44:37 +00:00
|
|
|
userdata = homedata / 'Library' / 'Application Support' / 'deemix'
|
2020-02-20 14:42:12 +00:00
|
|
|
else:
|
2020-09-27 21:44:37 +00:00
|
|
|
userdata = homedata / '.config' / 'deemix'
|
2020-02-20 14:42:12 +00:00
|
|
|
|
2020-12-02 16:57:17 +00:00
|
|
|
if os.getenv("DEEMIX_MUSIC_DIR"):
|
|
|
|
musicdata = Path(os.getenv("DEEMIX_MUSIC_DIR"))
|
|
|
|
elif os.getenv("XDG_MUSIC_DIR"):
|
2020-10-29 12:00:58 +00:00
|
|
|
musicdata = Path(os.getenv("XDG_MUSIC_DIR")) / "deemix Music"
|
|
|
|
elif os.name == 'nt':
|
|
|
|
import winreg
|
|
|
|
sub_key = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
|
|
|
|
music_guid = '{4BD8D571-6D19-48D3-BE97-422220080E43}'
|
|
|
|
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, sub_key) as key:
|
2020-10-30 14:38:21 +00:00
|
|
|
location = None
|
|
|
|
try: location = winreg.QueryValueEx(key, music_guid)[0]
|
|
|
|
except: pass
|
|
|
|
try: location = winreg.QueryValueEx(key, 'My Music')[0]
|
|
|
|
except: pass
|
|
|
|
if not location: location = homedata / "Music"
|
2020-10-29 12:00:58 +00:00
|
|
|
musicdata = Path(location) / "deemix Music"
|
|
|
|
else:
|
|
|
|
musicdata = homedata / "Music" / "deemix Music"
|
|
|
|
|
2020-02-20 14:42:12 +00:00
|
|
|
def getConfigFolder():
|
2020-04-17 10:31:47 +00:00
|
|
|
return userdata
|
2020-10-29 12:00:58 +00:00
|
|
|
|
|
|
|
def getMusicFolder():
|
|
|
|
return musicdata
|