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
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)

View File

@ -145,6 +145,22 @@ 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 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'])
@ -154,13 +170,6 @@ def addToQueue(dz, url, settings, bitrate=None, socket=None):
if socket:
socket.emit("message", "Already in queue!")
return None
if type(queueItem) is list:
for x in queueItem:
if socket:
socket.emit("addedToQueue", x)
queue.append(x['uuid'])
queueList[x['uuid']] = x
else:
if socket:
socket.emit("addedToQueue", queueItem)
queue.append(queueItem['uuid'])