mirror of
https://gitlab.com/RemixDev/deemix-gui-pyweb.git
synced 2024-12-28 02:16:16 +00:00
Moved getTracklist logic from server to app
This commit is contained in:
parent
4f1d17f7c7
commit
3e9e6eefd3
28
app.py
28
app.py
|
@ -154,6 +154,34 @@ class deemix:
|
|||
def getDownloadFolder(self):
|
||||
return self.set.settings['downloadLocation']
|
||||
|
||||
def getTracklist(self, dz, data):
|
||||
if data['type'] == 'artist':
|
||||
artistAPI = dz.get_artist(data['id'])
|
||||
artistAPI['releases'] = dz.get_artist_discography_gw(data['id'], 100)
|
||||
return artistAPI
|
||||
elif data['type'] == 'spotifyplaylist':
|
||||
playlistAPI = self.getSpotifyPlaylistTracklist(data['id'])
|
||||
for i in range(len(playlistAPI['tracks'])):
|
||||
playlistAPI['tracks'][i] = playlistAPI['tracks'][i]['track']
|
||||
playlistAPI['tracks'][i]['selected'] = False
|
||||
return playlistAPI
|
||||
else:
|
||||
releaseAPI = getattr(dz, 'get_' + data['type'])(data['id'])
|
||||
releaseTracksAPI = getattr(dz, 'get_' + data['type'] + '_tracks')(data['id'])['data']
|
||||
tracks = []
|
||||
showdiscs = False
|
||||
if data['type'] == 'album' and len(releaseTracksAPI) and releaseTracksAPI[-1]['disk_number'] != 1:
|
||||
current_disk = 0
|
||||
showdiscs = True
|
||||
for track in releaseTracksAPI:
|
||||
if showdiscs and int(track['disk_number']) != current_disk:
|
||||
current_disk = int(track['disk_number'])
|
||||
tracks.append({'type': 'disc_separator', 'number': current_disk})
|
||||
track['selected'] = False
|
||||
tracks.append(track)
|
||||
releaseAPI['tracks'] = tracks
|
||||
return releaseAPI
|
||||
|
||||
def getUserFavorites(self, dz):
|
||||
result = {}
|
||||
if dz.logged_in:
|
||||
|
|
29
server.py
29
server.py
|
@ -5,10 +5,8 @@ import sys
|
|||
from os import path
|
||||
import json
|
||||
|
||||
import eventlet
|
||||
from eventlet import tpool
|
||||
from eventlet.green import subprocess
|
||||
requests = eventlet.import_patched('requests')
|
||||
|
||||
from flask import Flask, render_template, request, session, redirect, copy_current_request_context
|
||||
from flask_socketio import SocketIO, emit
|
||||
|
@ -250,32 +248,7 @@ def saveSettings(settings, spotifyCredentials, spotifyUser):
|
|||
|
||||
@socketio.on('getTracklist')
|
||||
def getTracklist(data):
|
||||
if data['type'] == 'artist':
|
||||
artistAPI = session['dz'].get_artist(data['id'])
|
||||
artistAPI['releases'] = session['dz'].get_artist_discography_gw(data['id'], 100)
|
||||
emit('show_artist', artistAPI)
|
||||
elif data['type'] == 'spotifyplaylist':
|
||||
playlistAPI = app.getSpotifyPlaylistTracklist(data['id'])
|
||||
for i in range(len(playlistAPI['tracks'])):
|
||||
playlistAPI['tracks'][i] = playlistAPI['tracks'][i]['track']
|
||||
playlistAPI['tracks'][i]['selected'] = False
|
||||
emit('show_spotifyplaylist', playlistAPI)
|
||||
else:
|
||||
releaseAPI = getattr(session['dz'], 'get_' + data['type'])(data['id'])
|
||||
releaseTracksAPI = getattr(session['dz'], 'get_' + data['type'] + '_tracks')(data['id'])['data']
|
||||
tracks = []
|
||||
showdiscs = False
|
||||
if data['type'] == 'album' and len(releaseTracksAPI) and releaseTracksAPI[-1]['disk_number'] != 1:
|
||||
current_disk = 0
|
||||
showdiscs = True
|
||||
for track in releaseTracksAPI:
|
||||
if showdiscs and int(track['disk_number']) != current_disk:
|
||||
current_disk = int(track['disk_number'])
|
||||
tracks.append({'type': 'disc_separator', 'number': current_disk})
|
||||
track['selected'] = False
|
||||
tracks.append(track)
|
||||
releaseAPI['tracks'] = tracks
|
||||
emit('show_' + data['type'], releaseAPI)
|
||||
emit('show_'+data['type'], app.getTracklist(session['dz'], data))
|
||||
|
||||
@socketio.on('analyzeLink')
|
||||
def analyzeLink(link):
|
||||
|
|
Loading…
Reference in a new issue