From 1db90b31e6c760a9eae8c338802096ea4f7474ad Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 8 Apr 2020 18:43:35 +0200 Subject: [PATCH] Continued work on the UI --- deemix/api/deezer.py | 9 +++++++++ deemix/app/main.py | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/deemix/api/deezer.py b/deemix/api/deezer.py index 3140775..3c80c8a 100755 --- a/deemix/api/deezer.py +++ b/deemix/api/deezer.py @@ -202,6 +202,15 @@ class Deezer: tracks_array.append(track) return tracks_array + def search_gw(self, term): + results = self.gw_api_call('deezer.pageSearch', {"query": term, "start": 0, "nb": 40, "suggest": True, "artist_suggest": True, "top_tracks": True})['results'] + order = [] + for x in results['ORDER']: + if x in ['TOP_RESULT', 'TRACK', 'ALBUM', 'ARTIST', 'PLAYLIST']: + order.append(x) + results['ORDER'] = order + return results + def get_lyrics_gw(self, sng_id): return self.gw_api_call('song.getLyrics', {'sng_id': sng_id})["results"] diff --git a/deemix/app/main.py b/deemix/app/main.py index 6ce66c6..45a6efe 100644 --- a/deemix/app/main.py +++ b/deemix/app/main.py @@ -37,13 +37,16 @@ def initialize(): login() return True -def search(term): +def search(term, type): + result = dz.search(term, type) + print(result) + return result + +def mainSearch(term): if isValidLink(term): downloadLink(term) return {"message": "Downloaded!"} - result = dz.search(term, "track") - print(result) - return result + return dz.search_gw(term) def downloadLink(url, bitrate=None): global settings