From 2f78ee3883c606c8b960efadbc38dd92994772d1 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Mon, 27 Jun 2022 19:53:36 +0300 Subject: [PATCH] fix album search --- server/app/api/search.py | 30 ----------------------------- server/app/lib/searchlib.py | 7 +------ src/components/shared/AlbumCard.vue | 2 +- src/composables/pages/album.ts | 2 +- src/interfaces.ts | 1 + 5 files changed, 4 insertions(+), 38 deletions(-) diff --git a/server/app/api/search.py b/server/app/api/search.py index cb90f543..b2bd82b4 100644 --- a/server/app/api/search.py +++ b/server/app/api/search.py @@ -186,36 +186,6 @@ def get_top_results(): } -@search_bp.route("/search") -def search(): - """ - Returns a list of songs, albums and artists that match the search query. - """ - query = request.args.get("q") or "Mexican girl" - - albums = searchlib.SearchAlbums(query)() - artists_dicts = searchlib.SearchArtists(query)() - - tracks = searchlib.SearchTracks(query)() - top_artist = artists_dicts[0]["name"] - - _tracks = searchlib.GetTopArtistTracks(top_artist)() - tracks = [*tracks, *[t for t in _tracks if t not in tracks]] - - SEARCH_RESULTS.clear() - SEARCH_RESULTS["tracks"] = tracks - SEARCH_RESULTS["albums"] = albums - SEARCH_RESULTS["artists"] = artists_dicts - - return { - "data": [ - {"tracks": tracks[:5], "more": len(tracks) > 5}, - {"albums": albums[:6], "more": len(albums) > 6}, - {"artists": artists_dicts[:6], "more": len(artists_dicts) > 6}, - ] - } - - @search_bp.route("/search/loadmore") def search_load_more(): """ diff --git a/server/app/lib/searchlib.py b/server/app/lib/searchlib.py index 4f543b15..e3cb77dc 100644 --- a/server/app/lib/searchlib.py +++ b/server/app/lib/searchlib.py @@ -97,12 +97,7 @@ class SearchAlbums: Gets all albums with a given title. """ - albums = [] - - for album in self.albums: - title = album.title.lower() - if title not in albums: - albums.append(title) + albums = [a.title.lower() for a in self.albums] results = process.extract( self.query, diff --git a/src/components/shared/AlbumCard.vue b/src/components/shared/AlbumCard.vue index 20646af3..5b9730e8 100644 --- a/src/components/shared/AlbumCard.vue +++ b/src/components/shared/AlbumCard.vue @@ -2,7 +2,7 @@ diff --git a/src/composables/pages/album.ts b/src/composables/pages/album.ts index 0118aea2..436bb16a 100644 --- a/src/composables/pages/album.ts +++ b/src/composables/pages/album.ts @@ -48,7 +48,7 @@ const getAlbumArtists = async (hash: string) => { }; const getAlbumBio = async (hash: string) => { - const { data, status } = await useAxios({ + const { data, status, error } = await useAxios({ url: state.settings.uri + "/album/bio", props: { hash: hash, diff --git a/src/interfaces.ts b/src/interfaces.ts index 71016d6d..8ec95b51 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -36,6 +36,7 @@ export interface AlbumInfo { is_compilation: boolean; is_soundtrack: boolean; is_single: boolean; + hash: string } export interface Artist {