From 30ceca014a2767349cd6289e8411d87d743a9da2 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 3 May 2020 15:52:42 +0200 Subject: [PATCH] Implemented barebones charts tab --- app.py | 16 ++++++++++++++++ server.py | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/app.py b/app.py index 06cab9c..6721618 100644 --- a/app.py +++ b/app.py @@ -5,6 +5,7 @@ from deemix.app.spotify import SpotifyHelper settings = {} spotifyHelper = None +chartsList = [] def getUser(dz): @@ -24,6 +25,21 @@ def shutdown(interface=None): if interface: interface.send("toast", {'msg': "Server is closed."}) +def get_charts(dz): + global chartsList + if len(chartsList) == 0: + temp = dz.get_charts_countries() + countries = [] + for i in range(len(temp)): + countries.append({ + 'title': temp[i]['title'].replace("Top ", ""), + 'id': temp[i]['id'], + 'picture_small': temp[i]['picture_small'], + 'picture_medium': temp[i]['picture_medium'], + 'picture_big': temp[i]['picture_big'] + }) + chartsList = countries + return chartsList # Search functions def mainSearch(dz, term): diff --git a/server.py b/server.py index 86a3104..a8e60b2 100644 --- a/server.py +++ b/server.py @@ -70,6 +70,7 @@ def on_connect(): emit('init_downloadQueue', {'queue': queue, 'queueComplete': queueComplete, 'queueList': queueList, 'currentItem': currentItem}) emit('init_home', session['dz'].get_charts()) + emit('init_charts', app.get_charts(session['dz'])) @socketio.on('login') @@ -175,6 +176,10 @@ def analyzeLink(link): (type, data) = app.analyzeLink(session['dz'], link) emit('analyze_'+type, data) +@socketio.on('getChartTracks') +def getChartTracks(id): + emit('setChartTracks', session['dz'].get_playlist_tracks(id)['data']) + def run_server(port): print("Starting server at http://127.0.0.1:" + str(port)) socketio.run(server, host='0.0.0.0', port=port)