From d132c0ba54996cd0e13646a504bc9ab455292778 Mon Sep 17 00:00:00 2001 From: kermit Date: Fri, 25 Sep 2020 11:56:56 +0100 Subject: [PATCH] Add new albumSearch and newReleases endpoints --- app.py | 6 ++++++ server.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app.py b/app.py index a7c4155..089faef 100644 --- a/app.py +++ b/app.py @@ -137,6 +137,12 @@ class deemix: def search(self, dz, term, type, start, nb): return dz.search(term, type, nb, start) + def searchAlbum(self, dz, term, start, nb): + return dz.search_album_gw(term, start, nb) + + def newReleases(self, dz): + return dz.get_new_releases() + # Queue functions def addToQueue(self, dz, url, bitrate=None, interface=None, ack=None): if ';' in url: diff --git a/server.py b/server.py index c5f558a..5ace503 100644 --- a/server.py +++ b/server.py @@ -266,6 +266,26 @@ def search(data): result['ack'] = data.get('ack') emit('search', result) +@socketio.on('albumSearch') +def albumSearch(data): + if data['term'].strip() != "": + albums = app.searchAlbum(session['dz'], data['term'], data['start'], data['nb']) + output = { + 'data': albums, + 'total': len(albums), + 'ack': data.get('ack') + }; + emit('albumSearch', output) + +@socketio.on('newReleases') +def newReleases(data): + result = app.newReleases(session['dz']) + output = { + 'data': result, + 'total': len(result), + 'ack': data.get('ack') + }; + emit('newReleases', output) @socketio.on('queueRestored') def queueRestored():