Added scrollbar to download list

This commit is contained in:
RemixDev 2020-04-10 23:21:09 +02:00
parent 83a221c4b7
commit ba6078e34d
2 changed files with 24 additions and 11 deletions

View File

@ -7,9 +7,10 @@ from deemix.utils.spotifyHelper import get_trackid_spotify, get_albumid_spotify
import os.path import os.path
from os import makedirs, remove from os import makedirs, remove
from requests import get from requests import get
from requests.exceptions import HTTPError from requests.exceptions import HTTPError, ConnectionError
from tempfile import gettempdir from tempfile import gettempdir
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from time import sleep
import re import re
TEMPDIR = os.path.join(gettempdir(), 'deezloader-imgs') TEMPDIR = os.path.join(gettempdir(), 'deezloader-imgs')
@ -30,8 +31,11 @@ def downloadImage(url, path):
if not os.path.isfile(path): if not os.path.isfile(path):
with open(path, 'wb') as f: with open(path, 'wb') as f:
try: 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 return path
except ConnectionError:
sleep(2)
return downloadImage(url, path)
except HTTPError: except HTTPError:
print("Couldn't download Image") print("Couldn't download Image")
remove(path) remove(path)

View File

@ -145,22 +145,31 @@ def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None):
def addToQueue(dz, url, settings, bitrate=None, socket=None): def addToQueue(dz, url, settings, bitrate=None, socket=None):
global currentItem, currentJob, queueList, queue global currentItem, currentJob, queueList, queue
queueItem = generateQueueItem(dz, url, settings, bitrate) 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: if type(queueItem) is list:
for x in queueItem: 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: if socket:
socket.emit("addedToQueue", x) socket.emit("addedToQueue", x)
queue.append(x['uuid']) queue.append(x['uuid'])
queueList[x['uuid']] = x queueList[x['uuid']] = x
else: 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: if socket:
socket.emit("addedToQueue", queueItem) socket.emit("addedToQueue", queueItem)
queue.append(queueItem['uuid']) queue.append(queueItem['uuid'])