mirror of
https://gitlab.com/RemixDev/deemix-gui-pyweb.git
synced 2024-12-28 18:36:07 +00:00
Added Spotify credentials to settings tab
Reworked how spotify features work so now it doesn't require restart on config change
This commit is contained in:
parent
0d79904de8
commit
84c00d9d05
24
app.py
24
app.py
|
@ -1,16 +1,20 @@
|
|||
import deemix.utils.localpaths as localpaths
|
||||
from deemix.app.queuemanager import addToQueue, removeFromQueue, getQueue, cancelAllDownloads, removeFinishedDownloads
|
||||
from deemix.app.settings import initSettings, getSettings, saveSettings
|
||||
from deemix.app.spotify import SpotifyHelper
|
||||
from os import system as execute
|
||||
|
||||
settings = {}
|
||||
spotifyHelper = None
|
||||
|
||||
def getUser(dz):
|
||||
return dz.user
|
||||
|
||||
def initialize():
|
||||
global settings
|
||||
global spotifyHelper
|
||||
settings = initSettings()
|
||||
spotifyHelper = SpotifyHelper()
|
||||
|
||||
def shutdown(interface=None):
|
||||
getQueue()
|
||||
|
@ -18,14 +22,16 @@ def shutdown(interface=None):
|
|||
if interface:
|
||||
interface.send("toast", {'msg': "Server is closed."})
|
||||
|
||||
# Search functions
|
||||
def mainSearch(dz, term):
|
||||
return dz.search_main_gw(term)
|
||||
|
||||
def search(dz, term, type, start, nb):
|
||||
return dz.search_gw(term, type, start, nb)
|
||||
|
||||
# Queue functions
|
||||
def addToQueue_link(dz, url, bitrate=None, interface=None):
|
||||
return addToQueue(dz, url, settings, bitrate, interface)
|
||||
return addToQueue(dz, spotifyHelper, url, settings, bitrate, interface)
|
||||
|
||||
def removeFromQueue_link(uuid, interface=None):
|
||||
removeFromQueue(uuid, interface)
|
||||
|
@ -36,16 +42,20 @@ def cancelAllDownloads_link(interface=None):
|
|||
def removeFinishedDownloads_link(interface=None):
|
||||
removeFinishedDownloads(interface)
|
||||
|
||||
def getSettings_link():
|
||||
return getSettings()
|
||||
|
||||
def getSettings_link():
|
||||
return getSettings()
|
||||
|
||||
def getQueue_link():
|
||||
return getQueue()
|
||||
|
||||
# Settings functions
|
||||
def getSettings_link():
|
||||
return getSettings()
|
||||
|
||||
def saveSettings_link(newSettings):
|
||||
global settings
|
||||
settings = newSettings
|
||||
return saveSettings(newSettings)
|
||||
|
||||
def getSpotifyCredentials():
|
||||
return spotifyHelper.getCredentials()
|
||||
|
||||
def setSpotifyCredentials(newCredentials):
|
||||
return spotifyHelper.setCredentials(newCredentials)
|
||||
|
|
|
@ -55,7 +55,9 @@ def closing():
|
|||
@socketio.on('connect')
|
||||
def on_connect():
|
||||
session['dz'] = Deezer()
|
||||
emit('init_settings', app.getSettings_link())
|
||||
settings = app.getSettings_link()
|
||||
spotifyCredentials = app.getSpotifyCredentials()
|
||||
emit('init_settings', (settings, spotifyCredentials))
|
||||
queue, queueComplete, queueList, currentItem = app.getQueue_link()
|
||||
emit('init_downloadQueue', {'queue': queue, 'queueComplete': queueComplete, 'queueList': queueList, 'currentItem': currentItem})
|
||||
|
||||
|
@ -113,9 +115,10 @@ def cancelAllDownloads():
|
|||
app.cancelAllDownloads_link(interface=socket_interface)
|
||||
|
||||
@socketio.on('saveSettings')
|
||||
def saveSettings(settings):
|
||||
def saveSettings(settings, spotifyCredentials):
|
||||
app.saveSettings_link(settings)
|
||||
socket_interface.send('updateSettings', settings)
|
||||
app.setSpotifyCredentials(spotifyCredentials)
|
||||
socketio.emit('updateSettings', (settings, spotifyCredentials))
|
||||
|
||||
def run_server(port):
|
||||
print("Starting server at http://127.0.0.1:"+str(port))
|
||||
|
|
Loading…
Reference in a new issue