Made interface messages abstract
This removes the 'toast' interface event as it is a deemix-pyweb specific event
This commit is contained in:
parent
440ba1a61f
commit
85dddb27c9
|
@ -844,8 +844,7 @@ def download(dz, queueItem, interface=None):
|
||||||
download_path = after_download(playlist, settings, queueItem)
|
download_path = after_download(playlist, settings, queueItem)
|
||||||
if interface:
|
if interface:
|
||||||
if 'cancel' in queueItem:
|
if 'cancel' in queueItem:
|
||||||
interface.send('toast', {'msg': "Current item cancelled.", 'icon': 'done', 'dismiss': True,
|
interface.send('currentItemCancelled', queueItem['uuid'])
|
||||||
'id': 'cancelling_' + queueItem['uuid']})
|
|
||||||
interface.send("removedFromQueue", queueItem['uuid'])
|
interface.send("removedFromQueue", queueItem['uuid'])
|
||||||
else:
|
else:
|
||||||
interface.send("finishDownload", queueItem['uuid'])
|
interface.send("finishDownload", queueItem['uuid'])
|
||||||
|
|
|
@ -195,17 +195,13 @@ def generateQueueItem(dz, sp, url, settings, bitrate=None, albumAPI=None, interf
|
||||||
elif type == "artist":
|
elif type == "artist":
|
||||||
artistAPI = dz.get_artist(id)
|
artistAPI = dz.get_artist(id)
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("toast",
|
interface.send("startAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']})
|
||||||
{'msg': f"Adding {artistAPI['name']} albums to queue", 'icon': 'loading', 'dismiss': False,
|
|
||||||
'id': 'artist_' + str(artistAPI['id'])})
|
|
||||||
artistAPITracks = dz.get_artist_albums(id)
|
artistAPITracks = dz.get_artist_albums(id)
|
||||||
albumList = []
|
albumList = []
|
||||||
for album in artistAPITracks['data']:
|
for album in artistAPITracks['data']:
|
||||||
albumList.append(generateQueueItem(dz, sp, album['link'], settings, bitrate))
|
albumList.append(generateQueueItem(dz, sp, album['link'], settings, bitrate))
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("toast",
|
interface.send("finishAddingArtist", {'name': artistAPI['name'], 'id': artistAPI['id']})
|
||||||
{'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":
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -238,16 +234,13 @@ def generateQueueItem(dz, sp, url, settings, bitrate=None, albumAPI=None, interf
|
||||||
result['error'] = "Spotify Features is not setted up correctly."
|
result['error'] = "Spotify Features is not setted up correctly."
|
||||||
return result
|
return result
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("toast",
|
interface.send("startConvertingSpotifyPlaylist", str(id))
|
||||||
{'msg': f"Converting spotify tracks to deezer tracks", 'icon': 'loading', 'dismiss': False,
|
|
||||||
'id': 'spotifyplaylist_' + str(id)})
|
|
||||||
playlist = sp.convert_spotify_playlist(dz, id, settings)
|
playlist = sp.convert_spotify_playlist(dz, id, settings)
|
||||||
playlist['bitrate'] = bitrate
|
playlist['bitrate'] = bitrate
|
||||||
playlist['uuid'] = f"{playlist['type']}_{id}_{bitrate}"
|
playlist['uuid'] = f"{playlist['type']}_{id}_{bitrate}"
|
||||||
result = playlist
|
result = playlist
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("toast", {'msg': f"Spotify playlist converted", 'icon': 'done', 'dismiss': True,
|
interface.send("finishConvertingSpotifyPlaylist", str(id))
|
||||||
'id': 'spotifyplaylist_' + str(id)})
|
|
||||||
else:
|
else:
|
||||||
logger.warn("URL not supported yet")
|
logger.warn("URL not supported yet")
|
||||||
result['error'] = "URL not supported yet"
|
result['error'] = "URL not supported yet"
|
||||||
|
@ -277,17 +270,15 @@ def addToQueue(dz, sp, url, settings, bitrate=None, interface=None):
|
||||||
if 'error' in queueItem:
|
if 'error' in queueItem:
|
||||||
logger.error(f"[{url}] {queueItem['error']}")
|
logger.error(f"[{url}] {queueItem['error']}")
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("toast", {'msg': queueItem['error'], 'icon': 'error'})
|
interface.send("errorMessage", queueItem['error'])
|
||||||
return False
|
return False
|
||||||
if queueItem['uuid'] in list(queueList.keys()):
|
if queueItem['uuid'] in list(queueList.keys()):
|
||||||
logger.warn(f"[{queueItem['uuid']}] Already in queue, will not be added again.")
|
logger.warn(f"[{queueItem['uuid']}] Already in queue, will not be added again.")
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("toast",
|
interface.send("alreadyInQueue", {'uuid': queueItem['uuid'], 'title': queueItem['title']})
|
||||||
{'msg': f"{queueItem['title']} is already in queue!", 'icon': 'playlist_add_check'})
|
|
||||||
return False
|
return False
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("addedToQueue", slimQueueItem(queueItem))
|
interface.send("addedToQueue", slimQueueItem(queueItem))
|
||||||
interface.send("toast", {'msg': f"{queueItem['title']} added to queue", 'icon': 'playlist_add'})
|
|
||||||
logger.info(f"[{queueItem['uuid']}] Added to queue.")
|
logger.info(f"[{queueItem['uuid']}] Added to queue.")
|
||||||
queue.append(queueItem['uuid'])
|
queue.append(queueItem['uuid'])
|
||||||
queueList[queueItem['uuid']] = queueItem
|
queueList[queueItem['uuid']] = queueItem
|
||||||
|
@ -339,8 +330,7 @@ def removeFromQueue(uuid, interface=None):
|
||||||
global currentItem, queueList, queue, queueComplete
|
global currentItem, queueList, queue, queueComplete
|
||||||
if uuid == currentItem:
|
if uuid == currentItem:
|
||||||
if interface:
|
if interface:
|
||||||
interface.send('toast', {'msg': "Cancelling current item.", 'icon': 'loading', 'dismiss': False,
|
interface.send("cancellingCurrentItem", currentItem)
|
||||||
'id': 'cancelling_' + uuid})
|
|
||||||
queueList[uuid]['cancel'] = True
|
queueList[uuid]['cancel'] = True
|
||||||
elif uuid in queue:
|
elif uuid in queue:
|
||||||
queue.remove(uuid)
|
queue.remove(uuid)
|
||||||
|
@ -360,8 +350,7 @@ def cancelAllDownloads(interface=None):
|
||||||
queueComplete = []
|
queueComplete = []
|
||||||
if currentItem != "":
|
if currentItem != "":
|
||||||
if interface:
|
if interface:
|
||||||
interface.send('toast', {'msg': "Cancelling current item.", 'icon': 'loading', 'dismiss': False,
|
interface.send("cancellingCurrentItem", currentItem)
|
||||||
'id': 'cancelling_' + currentItem})
|
|
||||||
queueList[currentItem]['cancel'] = True
|
queueList[currentItem]['cancel'] = True
|
||||||
for uuid in list(queueList.keys()):
|
for uuid in list(queueList.keys()):
|
||||||
if uuid != currentItem:
|
if uuid != currentItem:
|
||||||
|
|
Loading…
Reference in New Issue