Merge branch 'CROSP-master'

master
flyingrub 2020-01-14 21:00:20 +01:00
commit 1d0776ccac
1 changed files with 21 additions and 18 deletions

View File

@ -74,6 +74,7 @@ from scdl import __version__, CLIENT_ID, ALT_CLIENT_ID
from scdl import client, utils
from datetime import datetime
import subprocess
logging.basicConfig(level=logging.INFO, format='%(message)s')
logging.getLogger('requests').setLevel(logging.WARNING)
@ -201,7 +202,7 @@ def get_config():
"""
global token
config = configparser.ConfigParser()
config.read(os.path.join(os.path.expanduser('~'), '.config/scdl/scdl.cfg'))
config.read(os.path.join(os.path.expanduser('~'), '.config/scdl/scdl.cfg'), "utf8")
try:
token = config['scdl']['auth_token']
path = config['scdl']['path']
@ -484,7 +485,7 @@ def download_original_file(track, title):
new = shlex.quote(newfilename)
old = shlex.quote(filename)
logger.debug("ffmpeg -i {0} {1} -loglevel fatal".format(old, new))
os.system("ffmpeg -i {0} {1} -loglevel fatal".format(old, new))
subprocess.call("ffmpeg -i {0} {1} -loglevel fatal".format(old, new))
os.remove(filename)
filename = newfilename
@ -514,10 +515,10 @@ def download_hls_mp3(track, title):
# Get the requests stream
url = get_track_m3u8(track)
os.system(
res = subprocess.call(
"ffmpeg -i {0} -c copy {1} -loglevel fatal".format(
shlex.quote(url),
shlex.quote(filename)
'"' + url + '"',
'"' + filename + '"'
)
)
return filename
@ -558,7 +559,6 @@ def download_track(track, playlist_name=None, playlist_file=None):
if arguments['--remove']:
fileToKeep.append(filename)
if filename.endswith('.mp3') or filename.endswith('.flac'):
try:
set_metadata(track, filename, playlist_name)
@ -576,12 +576,14 @@ def download_track(track, playlist_name=None, playlist_file=None):
logger.info('{0} Downloaded.\n'.format(filename))
record_download_archive(track)
return filename
def can_convert(filename):
ext = os.path.splitext(filename)[1]
return 'wav' in ext or 'aif' in ext
def already_downloaded(track, title, filename):
"""
Returns True if the file has already been downloaded
@ -724,5 +726,6 @@ def signal_handler(signal, frame):
logger.info('\nGood bye!')
sys.exit(0)
if __name__ == '__main__':
main()