From ba6078e34de4e05373f42e922bb391f9c5db1491 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Fri, 10 Apr 2020 23:21:09 +0200 Subject: [PATCH] Added scrollbar to download list --- deemix/app/downloader.py | 8 ++++++-- deemix/app/queuemanager.py | 27 ++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/deemix/app/downloader.py b/deemix/app/downloader.py index e2b2592..e4843ae 100644 --- a/deemix/app/downloader.py +++ b/deemix/app/downloader.py @@ -7,9 +7,10 @@ from deemix.utils.spotifyHelper import get_trackid_spotify, get_albumid_spotify import os.path from os import makedirs, remove from requests import get -from requests.exceptions import HTTPError +from requests.exceptions import HTTPError, ConnectionError from tempfile import gettempdir from concurrent.futures import ThreadPoolExecutor +from time import sleep import re TEMPDIR = os.path.join(gettempdir(), 'deezloader-imgs') @@ -30,8 +31,11 @@ def downloadImage(url, path): if not os.path.isfile(path): with open(path, 'wb') as f: try: - f.write(get(url, headers={'User-Agent': USER_AGENT_HEADER}).content) + f.write(get(url, headers={'User-Agent': USER_AGENT_HEADER}, timeout=30).content) return path + except ConnectionError: + sleep(2) + return downloadImage(url, path) except HTTPError: print("Couldn't download Image") remove(path) diff --git a/deemix/app/queuemanager.py b/deemix/app/queuemanager.py index 76b3a7c..606a564 100644 --- a/deemix/app/queuemanager.py +++ b/deemix/app/queuemanager.py @@ -145,22 +145,31 @@ def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None): def addToQueue(dz, url, settings, bitrate=None, socket=None): global currentItem, currentJob, queueList, queue queueItem = generateQueueItem(dz, url, settings, bitrate) - if 'error' in queueItem: - if socket: - socket.emit("message", queueItem['error']) - return None - if queueItem['uuid'] in list(queueList.keys()): - print("Already in queue!") - if socket: - socket.emit("message", "Already in queue!") - return None if type(queueItem) is list: for x in queueItem: + if 'error' in x: + if socket: + socket.emit("message", x['error']) + return None + if x['uuid'] in list(queueList.keys()): + print("Already in queue!") + if socket: + socket.emit("message", "Already in queue!") + return None if socket: socket.emit("addedToQueue", x) queue.append(x['uuid']) queueList[x['uuid']] = x else: + if 'error' in queueItem: + if socket: + socket.emit("message", queueItem['error']) + return None + if queueItem['uuid'] in list(queueList.keys()): + print("Already in queue!") + if socket: + socket.emit("message", "Already in queue!") + return None if socket: socket.emit("addedToQueue", queueItem) queue.append(queueItem['uuid'])