Added clear and cancel queue buttons
This commit is contained in:
parent
3facf299f1
commit
c75e6a8e9e
|
@ -688,7 +688,7 @@ def after_download(tracks, settings, queueItem):
|
||||||
f.write(line+"\n")
|
f.write(line+"\n")
|
||||||
if settings['executeCommand'] != "":
|
if settings['executeCommand'] != "":
|
||||||
execute(settings['executeCommand'].replace("%folder%", extrasPath))
|
execute(settings['executeCommand'].replace("%folder%", extrasPath))
|
||||||
return track['extrasPath']
|
return extrasPath
|
||||||
|
|
||||||
def after_download_single(track, settings, queueItem):
|
def after_download_single(track, settings, queueItem):
|
||||||
if 'cancel' in track:
|
if 'cancel' in track:
|
||||||
|
|
|
@ -5,8 +5,8 @@ from deemix.app.downloader import download
|
||||||
|
|
||||||
queue = []
|
queue = []
|
||||||
queueList = {}
|
queueList = {}
|
||||||
|
queueComplete = []
|
||||||
currentItem = ""
|
currentItem = ""
|
||||||
currentJob = None
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
queueItem base structure
|
queueItem base structure
|
||||||
|
@ -142,7 +142,7 @@ def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None, socket=Non
|
||||||
print("Spotify Features is not setted up correctly.")
|
print("Spotify Features is not setted up correctly.")
|
||||||
result['error'] = "Spotify Features is not setted up correctly."
|
result['error'] = "Spotify Features is not setted up correctly."
|
||||||
elif album_id != 0:
|
elif album_id != 0:
|
||||||
return generateQueueItem(dz, f'https://www.deezer.com/album/{track_id}', settings, bitrate)
|
return generateQueueItem(dz, f'https://www.deezer.com/album/{album_id}', settings, bitrate)
|
||||||
else:
|
else:
|
||||||
print("Album not found on deezer!")
|
print("Album not found on deezer!")
|
||||||
result['error'] = "Album not found on deezer!"
|
result['error'] = "Album not found on deezer!"
|
||||||
|
@ -152,7 +152,7 @@ def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None, socket=Non
|
||||||
return result
|
return result
|
||||||
|
|
||||||
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, queueList, queue
|
||||||
if not dz.logged_in:
|
if not dz.logged_in:
|
||||||
return "Not logged in"
|
return "Not logged in"
|
||||||
queueItem = generateQueueItem(dz, url, settings, bitrate, socket=socket)
|
queueItem = generateQueueItem(dz, url, settings, bitrate, socket=socket)
|
||||||
|
@ -170,23 +170,23 @@ def addToQueue(dz, url, settings, bitrate=None, socket=None):
|
||||||
else:
|
else:
|
||||||
if 'error' in queueItem:
|
if 'error' in queueItem:
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("toast", {'msg': queueItem['error']})
|
socket.emit("toast", {'msg': queueItem['error'], 'icon': 'error'})
|
||||||
return False
|
return False
|
||||||
if queueItem['uuid'] in list(queueList.keys()):
|
if queueItem['uuid'] in list(queueList.keys()):
|
||||||
print("Already in queue!")
|
print("Already in queue!")
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("toast", {'msg': f"{queueItem['title']} is already in queue!"})
|
socket.emit("toast", {'msg': f"{queueItem['title']} is already in queue!", 'icon': 'playlist_add_check'})
|
||||||
return False
|
return False
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("addedToQueue", queueItem)
|
socket.emit("addedToQueue", queueItem)
|
||||||
socket.emit("toast", {'msg': f"{queueItem['title']} added to queue"})
|
socket.emit("toast", {'msg': f"{queueItem['title']} added to queue", 'icon': 'playlist_add'})
|
||||||
queue.append(queueItem['uuid'])
|
queue.append(queueItem['uuid'])
|
||||||
queueList[queueItem['uuid']] = queueItem
|
queueList[queueItem['uuid']] = queueItem
|
||||||
nextItem(dz, socket)
|
nextItem(dz, socket)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def nextItem(dz, socket=None):
|
def nextItem(dz, socket=None):
|
||||||
global currentItem, currentJob, queueList, queue
|
global currentItem, queueList, queue
|
||||||
if currentItem != "":
|
if currentItem != "":
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
|
@ -200,15 +200,20 @@ def nextItem(dz, socket=None):
|
||||||
callbackQueueDone(result)
|
callbackQueueDone(result)
|
||||||
|
|
||||||
def callbackQueueDone(result):
|
def callbackQueueDone(result):
|
||||||
global currentItem, currentJob, queueList, queue
|
global currentItem, queueList, queueComplete
|
||||||
del queueList[currentItem]
|
if 'cancel' in queueList[currentItem]:
|
||||||
|
del queueList[currentItem]
|
||||||
|
else:
|
||||||
|
queueComplete.append(currentItem)
|
||||||
currentItem = ""
|
currentItem = ""
|
||||||
nextItem(result['dz'], result['socket'])
|
nextItem(result['dz'], result['socket'])
|
||||||
|
|
||||||
def getQueue():
|
def getQueue():
|
||||||
return (queue, queueList, currentItem)
|
global currentItem, queueList, queue, queueComplete
|
||||||
|
return (queue, queueComplete, queueList, currentItem)
|
||||||
|
|
||||||
def removeFromQueue(uuid, socket=None):
|
def removeFromQueue(uuid, socket=None):
|
||||||
|
global currentItem, queueList, queue, queueComplete
|
||||||
if uuid == currentItem:
|
if uuid == currentItem:
|
||||||
queueList[uuid]['cancel'] = True
|
queueList[uuid]['cancel'] = True
|
||||||
elif uuid in queue:
|
elif uuid in queue:
|
||||||
|
@ -216,9 +221,16 @@ def removeFromQueue(uuid, socket=None):
|
||||||
del queueList[uuid]
|
del queueList[uuid]
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("removedFromQueue", uuid)
|
socket.emit("removedFromQueue", uuid)
|
||||||
|
elif uuid in queueComplete:
|
||||||
|
queueComplete.remove(uuid)
|
||||||
|
del queueList[uuid]
|
||||||
|
if socket:
|
||||||
|
socket.emit("removedFromQueue", uuid)
|
||||||
|
|
||||||
def cancelAllDownloads(socket=None):
|
def cancelAllDownloads(socket=None):
|
||||||
|
global currentItem, queueList, queue, queueComplete
|
||||||
queue = []
|
queue = []
|
||||||
|
queueComplete = []
|
||||||
if currentItem != "":
|
if currentItem != "":
|
||||||
queueList[currentItem]['cancel'] = True
|
queueList[currentItem]['cancel'] = True
|
||||||
for uuid in list(queueList.keys()):
|
for uuid in list(queueList.keys()):
|
||||||
|
@ -226,3 +238,11 @@ def cancelAllDownloads(socket=None):
|
||||||
del queueList[uuid]
|
del queueList[uuid]
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("removedAllDownloads")
|
socket.emit("removedAllDownloads")
|
||||||
|
|
||||||
|
def removeFinishedDownloads(socket=None):
|
||||||
|
global queueList, queueComplete
|
||||||
|
for uuid in queueComplete:
|
||||||
|
del queueList[uuid]
|
||||||
|
queueComplete = []
|
||||||
|
if socket:
|
||||||
|
socket.emit("removedFinishedDownloads")
|
||||||
|
|
Loading…
Reference in New Issue