Implemented barebones charts tab

This commit is contained in:
RemixDev 2020-05-03 15:52:42 +02:00
parent 0e516352b1
commit 30ceca014a
2 changed files with 21 additions and 0 deletions

16
app.py
View file

@ -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):

View file

@ -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)