From 9f55681103c75911545e7406117f370b74be54b5 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 12 Apr 2020 09:50:49 +0200 Subject: [PATCH] Added generic error exception to error log --- deemix/app/downloader.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index c0c3540..6ce4102 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -566,6 +566,20 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None socket.emit("updateQueue", {'uuid': queueItem['uuid'], 'downloaded': True}) return result +def downloadTrackObj_wrap(dz, track, settings, bitrate, queueItem, socket): + try: + result = downloadTrackObj(dz, track, settings, bitrate, queueItem, socket=socket) + except Exception as e: + result = {'error': { + 'message': str(e)}, + 'data': { + 'id': track['SNG_ID'], + 'title': track['SNG_TITLE'] + (" "+track['VERSION'] if 'VERSION' in track and track['VERSION'] else ""), + 'mainArtist': {'name': track['ART_NAME']} + } + } + return result + def download(dz, queueItem, socket=None): global downloadPercentage, lastPercentage settings = queueItem['settings'] @@ -573,14 +587,24 @@ def download(dz, queueItem, socket=None): downloadPercentage = 0 lastPercentage = 0 if 'single' in queueItem: - result = downloadTrackObj(dz, queueItem['single'], settings, bitrate, queueItem, socket=socket) + try: + result = downloadTrackObj(dz, queueItem['single'], settings, bitrate, queueItem, socket=socket) + except Exception as e: + result = {'error': { + 'message': str(e)}, + 'data': { + 'id': track['SNG_ID'], + 'title': track['SNG_TITLE'] + (" "+track['VERSION'] if 'VERSION' in track and track['VERSION'] else ""), + 'mainArtist': {'name': track['ART_NAME']} + } + } download_path = after_download_single(result, settings) elif 'collection' in queueItem: print("Downloading collection") playlist = [None] * len(queueItem['collection']) with ThreadPoolExecutor(settings['queueConcurrency']) as executor: for pos, track in enumerate(queueItem['collection'], start=0): - playlist[pos] = executor.submit(downloadTrackObj, dz, track, settings, bitrate, queueItem, socket=socket) + playlist[pos] = executor.submit(downloadTrackObj_wrap, dz, track, settings, bitrate, queueItem, socket=socket) download_path = after_download(playlist, settings) if socket: if 'cancel' in queueItem: