Merge branch 'master' of github.com:flyingrub/scdl
commit
63045813ce
|
@ -9,19 +9,21 @@ CLIENT_ID = 'a3e059563d7fd3372b49b37f00a00bcf'
|
||||||
ALT_CLIENT_ID = '2t9loNQH90kzJcsFCODdigxfp325aq4z'
|
ALT_CLIENT_ID = '2t9loNQH90kzJcsFCODdigxfp325aq4z'
|
||||||
ALT2_CLIENT_ID = 'NONE'
|
ALT2_CLIENT_ID = 'NONE'
|
||||||
|
|
||||||
dir_path_to_conf = os.path.join(os.path.expanduser('~'), '.config/scdl')
|
default_config = """[scdl]
|
||||||
if 'XDG_CONFIG_HOME' in os.environ:
|
|
||||||
dir_path_to_conf = os.environ['XDG_CONFIG_HOME']
|
|
||||||
|
|
||||||
file_path_to_conf = os.path.join(dir_path_to_conf, 'scdl.cfg')
|
|
||||||
text = """[scdl]
|
|
||||||
auth_token =
|
auth_token =
|
||||||
path = .
|
path = .
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not os.path.exists(dir_path_to_conf):
|
if 'XDG_CONFIG_HOME' in os.environ:
|
||||||
os.makedirs(dir_path_to_conf)
|
config_dir = os.path.join(os.environ['XDG_CONFIG_HOME'], 'scdl')
|
||||||
|
else:
|
||||||
|
config_dir = os.path.join(os.path.expanduser('~'), '.config', 'scdl')
|
||||||
|
|
||||||
if not os.path.exists(file_path_to_conf):
|
config_file = os.path.join(config_dir, 'scdl.cfg')
|
||||||
with open(file_path_to_conf, 'w') as f:
|
|
||||||
f.write(text)
|
if not os.path.exists(config_file):
|
||||||
|
if not os.path.exists(config_dir):
|
||||||
|
os.makedirs(config_dir)
|
||||||
|
|
||||||
|
with open(config_file, 'w') as f:
|
||||||
|
f.write(default_config)
|
||||||
|
|
15
scdl/scdl.py
15
scdl/scdl.py
|
@ -204,7 +204,16 @@ def get_config():
|
||||||
"""
|
"""
|
||||||
global token
|
global token
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(os.path.join(os.path.expanduser('~'), '.config/scdl/scdl.cfg'), "utf8")
|
|
||||||
|
if 'XDG_CONFIG_HOME' in os.environ:
|
||||||
|
config_file = os.path.join(
|
||||||
|
os.environ['XDG_CONFIG_HOME'], 'scdl', 'scdl.cfg',
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
config_file = os.path.join(
|
||||||
|
os.path.expanduser('~'), '.config', 'scdl', 'scdl.cfg',
|
||||||
|
)
|
||||||
|
config.read(config_file, 'utf8')
|
||||||
try:
|
try:
|
||||||
token = config['scdl']['auth_token']
|
token = config['scdl']['auth_token']
|
||||||
path = config['scdl']['path']
|
path = config['scdl']['path']
|
||||||
|
@ -454,7 +463,7 @@ def download_original_file(track, title):
|
||||||
if r.status_code == 401:
|
if r.status_code == 401:
|
||||||
logger.info('The original file has no download left.')
|
logger.info('The original file has no download left.')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if r.status_code == 404:
|
if r.status_code == 404:
|
||||||
logger.info('Could not get name from stream - using basic name')
|
logger.info('Could not get name from stream - using basic name')
|
||||||
return None
|
return None
|
||||||
|
@ -494,7 +503,7 @@ def download_original_file(track, title):
|
||||||
newfilename = filename[:-4] + ".flac"
|
newfilename = filename[:-4] + ".flac"
|
||||||
new = shlex.quote(newfilename)
|
new = shlex.quote(newfilename)
|
||||||
old = shlex.quote(filename)
|
old = shlex.quote(filename)
|
||||||
|
|
||||||
commands = ['ffmpeg', '-i', old, new, '-loglevel', 'fatal']
|
commands = ['ffmpeg', '-i', old, new, '-loglevel', 'fatal']
|
||||||
logger.debug("Commands: {}".format(commands))
|
logger.debug("Commands: {}".format(commands))
|
||||||
subprocess.call(commands)
|
subprocess.call(commands)
|
||||||
|
|
Loading…
Reference in New Issue