From 8fcf858a2b3d4f41d6bd265a3a2c5f6e5deda166 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 26 Apr 2020 14:27:54 +0200 Subject: [PATCH] Started implementing Link Analyzer's tab --- app.py | 9 +++++++++ server.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/app.py b/app.py index 78ca179..06cab9c 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,5 @@ from deemix.app.queuemanager import addToQueue, removeFromQueue, getQueue, cancelAllDownloads, removeFinishedDownloads +from deemix.utils.misc import getTypeFromLink, getIDFromLink from deemix.app.settings import initSettings, getSettings, saveSettings from deemix.app.spotify import SpotifyHelper @@ -53,6 +54,14 @@ def removeFinishedDownloads_link(interface=None): def getQueue_link(): return getQueue() +def analyzeLink(dz, link): + type = getTypeFromLink(link) + relID = getIDFromLink(link, type) + if type in ["track", "album"]: + data = getattr(dz, 'get_' + type)(relID) + else: + data = {} + return (type, data) # Settings functions def getSettings_link(): diff --git a/server.py b/server.py index 30cd1d8..54c76d9 100644 --- a/server.py +++ b/server.py @@ -169,6 +169,10 @@ def getTracklist(data): releaseAPI['tracks'] = tracks emit('show_' + data['type'], releaseAPI) +@socketio.on('analyzeLink') +def analyzeLink(link): + (type, data) = app.analyzeLink(session['dz'], link) + emit('analyze_'+type, data) def run_server(port): print("Starting server at http://127.0.0.1:" + str(port))