Made deezer login session dependent and added login check

This commit is contained in:
RemixDev 2020-04-12 21:22:06 +02:00
parent 9e4ed4f045
commit f2b7e72021
2 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,3 @@
from deemix.api.deezer import Deezer
import deemix.utils.localpaths as localpaths
from deemix.app.queuemanager import addToQueue, removeFromQueue, getQueue, cancelAllDownloads
from deemix.app.settings import initSettings
@ -6,16 +5,15 @@ from os import system as execute
import os.path as path
from os import mkdir, rmdir
dz = Deezer()
settings = {}
def login(arl):
def login(dz, arl):
if not dz.logged_in:
return dz.login_via_arl(arl)
else:
return 2
def getUser():
def getUser(dz):
return dz.user
def initialize():
@ -29,14 +27,14 @@ def shutdown(socket=None):
if socket:
socket.emit("toast", {'msg': "Server is closed."})
def mainSearch(term):
def mainSearch(dz, term):
return dz.search_main_gw(term)
def search(term, type, start, nb):
def search(dz, term, type, start, nb):
return dz.search_gw(term, type, start, nb)
def addToQueue_link(url, bitrate=None, socket=None):
addToQueue(dz, url, settings, bitrate, socket)
def addToQueue_link(dz, url, bitrate=None, socket=None):
return addToQueue(dz, url, settings, bitrate, socket)
def removeFromQueue_link(uuid, socket=None):
removeFromQueue(uuid, socket)

View File

@ -153,6 +153,8 @@ def generateQueueItem(dz, url, settings, bitrate=None, albumAPI=None, socket=Non
def addToQueue(dz, url, settings, bitrate=None, socket=None):
global currentItem, currentJob, queueList, queue
if not dz.logged_in:
return "Not logged in"
queueItem = generateQueueItem(dz, url, settings, bitrate, socket=socket)
if type(queueItem) is list:
for x in queueItem:
@ -169,18 +171,19 @@ def addToQueue(dz, url, settings, bitrate=None, socket=None):
if 'error' in queueItem:
if socket:
socket.emit("toast", {'msg': queueItem['error']})
return None
return False
if queueItem['uuid'] in list(queueList.keys()):
print("Already in queue!")
if socket:
socket.emit("toast", {'msg': f"{queueItem['title']} is already in queue!"})
return None
return False
if socket:
socket.emit("addedToQueue", queueItem)
socket.emit("toast", {'msg': f"{queueItem['title']} added to queue"})
queue.append(queueItem['uuid'])
queueList[queueItem['uuid']] = queueItem
nextItem(dz, socket)
return True
def nextItem(dz, socket=None):
global currentItem, currentJob, queueList, queue