deemix-gui-pyweb/app.py

62 lines
1.6 KiB
Python
Raw Normal View History

import deemix.utils.localpaths as localpaths
2020-04-14 14:48:13 +00:00
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()
cancelAllDownloads(interface)
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):
2020-04-19 17:22:21 +00:00
return dz.search(term, type, nb, start)
# Queue functions
def addToQueue_link(dz, url, bitrate=None, interface=None):
return addToQueue(dz, spotifyHelper, url, settings, bitrate, interface)
def removeFromQueue_link(uuid, interface=None):
removeFromQueue(uuid, interface)
def cancelAllDownloads_link(interface=None):
cancelAllDownloads(interface)
2020-04-14 14:48:13 +00:00
def removeFinishedDownloads_link(interface=None):
removeFinishedDownloads(interface)
2020-04-14 14:48:13 +00:00
def getQueue_link():
return getQueue()
# Settings functions
def getSettings_link():
return getSettings()
def saveSettings_link(newSettings):
2020-04-14 17:58:54 +00:00
global settings
settings = newSettings
return saveSettings(newSettings)
def getSpotifyCredentials():
return spotifyHelper.getCredentials()
def setSpotifyCredentials(newCredentials):
return spotifyHelper.setCredentials(newCredentials)