Added toast messages
This commit is contained in:
parent
fedacde6a1
commit
e36de601fe
|
@ -565,6 +565,8 @@ def download(dz, queueItem, socket=None):
|
||||||
for pos, track in enumerate(queueItem['collection'], start=0):
|
for pos, track in enumerate(queueItem['collection'], start=0):
|
||||||
playlist[pos] = executor.submit(downloadTrackObj, dz, track, settings, bitrate, queueItem['uuid'], socket=socket)
|
playlist[pos] = executor.submit(downloadTrackObj, dz, track, settings, bitrate, queueItem['uuid'], socket=socket)
|
||||||
download_path = after_download(playlist, settings)
|
download_path = after_download(playlist, settings)
|
||||||
|
if socket:
|
||||||
|
socket.emit("finishDownload", queueItem['uuid'])
|
||||||
return {
|
return {
|
||||||
'dz': dz,
|
'dz': dz,
|
||||||
'socket': socket,
|
'socket': socket,
|
||||||
|
|
|
@ -27,7 +27,7 @@ if its an album/playlist
|
||||||
collection
|
collection
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None):
|
def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None, socket=None):
|
||||||
forcedBitrate = getBitrateInt(bitrate)
|
forcedBitrate = getBitrateInt(bitrate)
|
||||||
bitrate = forcedBitrate if forcedBitrate else settings['maxBitrate']
|
bitrate = forcedBitrate if forcedBitrate else settings['maxBitrate']
|
||||||
type = getTypeFromLink(url)
|
type = getTypeFromLink(url)
|
||||||
|
@ -115,10 +115,15 @@ def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None):
|
||||||
result['collection'].append(trackAPI)
|
result['collection'].append(trackAPI)
|
||||||
|
|
||||||
elif type == "artist":
|
elif type == "artist":
|
||||||
artistAPI = dz.get_artist_albums(id)
|
artistAPI = dz.get_artist(id)
|
||||||
|
if socket:
|
||||||
|
socket.emit("toast", {'msg': f"Adding {artistAPI['name']} albums to queue", 'icon': 'loading', 'dismiss': False, 'id': 'artist_'+str(artistAPI['id'])})
|
||||||
|
artistAPITracks = dz.get_artist_albums(id)
|
||||||
albumList = []
|
albumList = []
|
||||||
for album in artistAPI['data']:
|
for album in artistAPITracks['data']:
|
||||||
albumList.append(generateQueueItem(dz, album['link'], settings, bitrate))
|
albumList.append(generateQueueItem(dz, album['link'], settings, bitrate))
|
||||||
|
if socket:
|
||||||
|
socket.emit("updateToast", {'msg': f"Added {artistAPI['name']} albums to queue", 'icon': 'done', 'dismiss': True, 'id': 'artist_'+str(artistAPI['id'])})
|
||||||
return albumList
|
return albumList
|
||||||
elif type == "spotifytrack":
|
elif type == "spotifytrack":
|
||||||
track_id = get_trackid_spotify(dz, id, settings['fallbackSearch'])
|
track_id = get_trackid_spotify(dz, id, settings['fallbackSearch'])
|
||||||
|
@ -148,18 +153,14 @@ 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, socket=socket)
|
||||||
if type(queueItem) is list:
|
if type(queueItem) is list:
|
||||||
for x in queueItem:
|
for x in queueItem:
|
||||||
if 'error' in x:
|
if 'error' in x:
|
||||||
if socket:
|
continue
|
||||||
socket.emit("message", x['error'])
|
|
||||||
return None
|
|
||||||
if x['uuid'] in list(queueList.keys()):
|
if x['uuid'] in list(queueList.keys()):
|
||||||
print("Already in queue!")
|
print("Already in queue!")
|
||||||
if socket:
|
continue
|
||||||
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'])
|
||||||
|
@ -167,15 +168,16 @@ 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("message", queueItem['error'])
|
socket.emit("toast", {'msg': queueItem['error']})
|
||||||
return None
|
return None
|
||||||
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("message", "Already in queue!")
|
socket.emit("toast", {'msg': f"{queueItem['title']} is already in queue!"})
|
||||||
return None
|
return None
|
||||||
if socket:
|
if socket:
|
||||||
socket.emit("addedToQueue", queueItem)
|
socket.emit("addedToQueue", queueItem)
|
||||||
|
socket.emit("toast", {'msg': f"{queueItem['title']} added to queue"})
|
||||||
queue.append(queueItem['uuid'])
|
queue.append(queueItem['uuid'])
|
||||||
queueList[queueItem['uuid']] = queueItem
|
queueList[queueItem['uuid']] = queueItem
|
||||||
nextItem(dz, socket)
|
nextItem(dz, socket)
|
||||||
|
|
Loading…
Reference in New Issue