mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 04:23:01 +00:00
fix album search
This commit is contained in:
committed by
Mungai Geoffrey
parent
26b7cd376d
commit
2f78ee3883
@@ -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():
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user