From ba647bc300df0cd6621fc6646ebbbabfb83bb725 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sat, 21 Mar 2020 12:56:55 +0100 Subject: [PATCH] Added %folder% variable to executeCommand --- deemix/app/downloader.py | 5 ++++- deemix/app/main.py | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index 148c472..913d7df 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -364,7 +364,8 @@ def download_track(dz, id, settings, overwriteBitrate=False): trackAPI = dz.get_track_gw(id) trackAPI['FILENAME_TEMPLATE'] = settings['tracknameTemplate'] trackAPI['SINGLE_TRACK'] = True - downloadTrackObj(dz, trackAPI, settings, overwriteBitrate) + result = downloadTrackObj(dz, trackAPI, settings, overwriteBitrate) + return result['extrasPath'] def download_album(dz, id, settings, overwriteBitrate=False): albumAPI = dz.get_album(id) @@ -404,6 +405,7 @@ def download_album(dz, id, settings, overwriteBitrate=False): with open(os.path.join(extrasPath, 'playlist.m3u8'), 'w') as f: for line in playlist: f.write(line+"\n") + return extrasPath def download_artist(dz, id, settings, overwriteBitrate=False): artistAPI = dz.get_artist_albums(id) @@ -439,3 +441,4 @@ def download_playlist(dz, id, settings, overwriteBitrate=False): with open(os.path.join(extrasPath, 'playlist.m3u8'), 'w') as f: for line in playlist: f.write(line+"\n") + return extrasPath diff --git a/deemix/app/main.py b/deemix/app/main.py index cdf2cc8..b55a55c 100644 --- a/deemix/app/main.py +++ b/deemix/app/main.py @@ -10,18 +10,19 @@ def downloadLink(url, settings, bitrate=None): forcedBitrate = getBitrateInt(bitrate) type = getTypeFromLink(url) id = getIDFromLink(url, type) + folder = settings['downloadLocation'] if type == None or id == None: print("URL not recognized") if type == "track": - download_track(dz, id, settings, forcedBitrate) + folder = download_track(dz, id, settings, forcedBitrate) elif type == "album": - download_album(dz, id, settings, forcedBitrate) + folder = download_album(dz, id, settings, forcedBitrate) elif type == "playlist": - download_playlist(dz, id, settings, forcedBitrate) + folder = download_playlist(dz, id, settings, forcedBitrate) elif type == "artist": download_artist(dz, id, settings, forcedBitrate) else: print("URL not supported yet") return None if settings['executeCommand'] != "": - execute(settings['executeCommand']) + execute(settings['executeCommand'].replace("%folder%", folder))