mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix album search
This commit is contained in:
@@ -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")
|
@search_bp.route("/search/loadmore")
|
||||||
def search_load_more():
|
def search_load_more():
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -97,12 +97,7 @@ class SearchAlbums:
|
|||||||
Gets all albums with a given title.
|
Gets all albums with a given title.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
albums = []
|
albums = [a.title.lower() for a in self.albums]
|
||||||
|
|
||||||
for album in self.albums:
|
|
||||||
title = album.title.lower()
|
|
||||||
if title not in albums:
|
|
||||||
albums.append(title)
|
|
||||||
|
|
||||||
results = process.extract(
|
results = process.extract(
|
||||||
self.query,
|
self.query,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<router-link
|
<router-link
|
||||||
:to="{
|
:to="{
|
||||||
name: 'AlbumView',
|
name: 'AlbumView',
|
||||||
params: { album: album.title, artist: album.artist },
|
params: { hash: album.hash },
|
||||||
}"
|
}"
|
||||||
class="result-item"
|
class="result-item"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const getAlbumArtists = async (hash: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getAlbumBio = 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",
|
url: state.settings.uri + "/album/bio",
|
||||||
props: {
|
props: {
|
||||||
hash: hash,
|
hash: hash,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export interface AlbumInfo {
|
|||||||
is_compilation: boolean;
|
is_compilation: boolean;
|
||||||
is_soundtrack: boolean;
|
is_soundtrack: boolean;
|
||||||
is_single: boolean;
|
is_single: boolean;
|
||||||
|
hash: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Artist {
|
export interface Artist {
|
||||||
|
|||||||
Reference in New Issue
Block a user