mirror of
https://gitlab.com/RemixDev/deemix-gui-pyweb.git
synced 2024-12-28 18:36:07 +00:00
v6
This commit is contained in:
parent
5720433ae8
commit
a13065e1c8
18
app.py
18
app.py
|
@ -4,8 +4,11 @@ from deemix.utils.misc import getTypeFromLink, getIDFromLink
|
|||
from deemix.app.settings import initSettings, getSettings, getDefaultSettings, saveSettings
|
||||
from deemix.app.spotify import SpotifyHelper
|
||||
|
||||
from spotifyadvanced import SpotifyAdvanced
|
||||
|
||||
settings = {}
|
||||
spotifyHelper = None
|
||||
spotifyAdvanced = None
|
||||
chartsList = []
|
||||
|
||||
|
||||
|
@ -16,7 +19,22 @@ def initialize():
|
|||
settings = initSettings()
|
||||
defaultSettings = getDefaultSettings()
|
||||
spotifyHelper = SpotifyHelper()
|
||||
global spotifyAdvanced
|
||||
spotifyAdvanced = SpotifyAdvanced()
|
||||
|
||||
def initSpotifyAdvanced():
|
||||
user = spotifyAdvanced.getUsername()
|
||||
if user == "" or not spotifyAdvanced.spotifyAdvancedEnabled:
|
||||
return []
|
||||
result = spotifyAdvanced.get_user_playlists(user)
|
||||
#print(result)
|
||||
return result
|
||||
|
||||
def getTracklistFromSpotifyPlaylists(playlistIds):
|
||||
return spotifyAdvanced.getTracklistFromSpotifyPlaylists(playlistIds)
|
||||
|
||||
def mergeSpotifyPlaylists(playlistIds):
|
||||
return spotifyAdvanced.mergeSpotifyPlaylists(playlistIds)
|
||||
|
||||
def shutdown(interface=None):
|
||||
getQueue()
|
||||
|
|
32
server.py
32
server.py
|
@ -1,4 +1,5 @@
|
|||
#!/usr/env/bin python3
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
from os import path
|
||||
|
@ -11,6 +12,8 @@ from deemix.api.deezer import Deezer
|
|||
from deemix.app.MessageInterface import MessageInterface
|
||||
from deemix.utils import localpaths
|
||||
|
||||
import spotifyadvanced
|
||||
|
||||
# Workaround for MIME type error in certain Windows installs
|
||||
# https://github.com/pallets/flask/issues/1045#issuecomment-42202749
|
||||
import mimetypes
|
||||
|
@ -97,6 +100,7 @@ def on_connect():
|
|||
{'queue': queue, 'queueComplete': queueComplete, 'queueList': queueList, 'currentItem': currentItem})
|
||||
emit('init_home', session['dz'].get_charts())
|
||||
emit('init_charts', app.get_charts(session['dz']))
|
||||
emit('init_spotify', app.initSpotifyAdvanced())
|
||||
|
||||
|
||||
@socketio.on('login')
|
||||
|
@ -115,7 +119,6 @@ def login(arl, force=False):
|
|||
emit('logged_in', {'status': result, 'arl': arl, 'user': session['dz'].user})
|
||||
emit('init_favorites', app.getUserFavorites(session['dz']))
|
||||
|
||||
|
||||
@socketio.on('logout')
|
||||
def logout():
|
||||
status = 0
|
||||
|
@ -211,6 +214,33 @@ def analyzeLink(link):
|
|||
(type, data) = app.analyzeLink(session['dz'], link)
|
||||
emit('analyze_'+type, data)
|
||||
|
||||
@socketio.on('getTracklistFromSpotifyPlaylists')
|
||||
def getTracklistFromSpotifyPlaylists(data):
|
||||
playlistAPI = app.getTracklistFromSpotifyPlaylists(data['playlists'])
|
||||
for i in range(len(playlistAPI['tracks'])):
|
||||
playlistAPI['tracks'][i] = playlistAPI['tracks'][i]['track']
|
||||
playlistAPI['tracks'][i]['selected'] = False
|
||||
filename = "debug_getTracklistFromSpotifyPlaylists_playlistAPI_server"
|
||||
with open(filename+".json", 'w') as outfile:
|
||||
json.dump(playlistAPI, outfile, indent=4)
|
||||
emit('getTracklistFromSpotifyPlaylists_done', playlistAPI)
|
||||
|
||||
@socketio.on('mergeSpotifyPlaylists')
|
||||
def mergeSpotifyPlaylists(data):
|
||||
result = app.mergeSpotifyPlaylists(data['playlists'])
|
||||
# returns ERROR 1 or
|
||||
# returns uri of new created playlist
|
||||
filename = "debug_mergeSpotifyPlaylists_result"
|
||||
with open(filename+".json", 'w') as outfile:
|
||||
json.dump(result, outfile, indent=4)
|
||||
|
||||
if result != "ERROR 1":
|
||||
emit('mergeSpotifyPlaylists_done', result) # <--- sollte die neue playlists anzeigen in result steht die playlist URI
|
||||
emit('init_spotify', app.initSpotify()) # analog zu updateUserSpotifyPlaylists
|
||||
#emit('updated_userSpotifyPlaylists', app.updateUserSpotifyPlaylists(spotifyUser))
|
||||
else:
|
||||
emit('mergeSpotifyPlaylists_error', result)
|
||||
|
||||
@socketio.on('getChartTracks')
|
||||
def getChartTracks(id):
|
||||
emit('setChartTracks', session['dz'].get_playlist_tracks(id)['data'])
|
||||
|
|
Loading…
Reference in a new issue