modify artist search to retur all artist track
This commit is contained in:
parent
f7090127fe
commit
511a101c2c
2 changed files with 19 additions and 28 deletions
|
@ -148,6 +148,22 @@ class SubidyLibraryProvider(backend.LibraryProvider):
|
|||
tracks=self.subsonic_api.get_songs_as_tracks(album.get("id"))
|
||||
)
|
||||
|
||||
def search_by_artist(self, artist_search):
|
||||
result = self.subsonic_api.find_raw(artist_search)
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
tracks = []
|
||||
for artist in result.get("artist"):
|
||||
albums = self.subsonic_api.get_raw_albums(artist.get("id"))
|
||||
for album in albums:
|
||||
tracks.extend(
|
||||
self.subsonic_api.get_songs_as_tracks(album.get("id"))
|
||||
)
|
||||
return SearchResult(
|
||||
uri=uri.get_search_uri(artist_search), tracks=tracks
|
||||
)
|
||||
|
||||
def get_distinct(self, field, query):
|
||||
search_result = self.search(query)
|
||||
if not search_result:
|
||||
|
@ -173,9 +189,7 @@ class SubidyLibraryProvider(backend.LibraryProvider):
|
|||
query.get("artist")[0], query.get("album")[0]
|
||||
)
|
||||
if "artist" in query:
|
||||
return self.subsonic_api.find_artist_as_search_result(
|
||||
query.get("artist")[0]
|
||||
)
|
||||
return self.search_by_artist(query.get("artist")[0])
|
||||
if "any" in query:
|
||||
return self.subsonic_api.find_as_search_result(query.get("any")[0])
|
||||
return SearchResult(artists=self.subsonic_api.get_artists_as_artists())
|
||||
|
|
|
@ -101,7 +101,7 @@ class SubsonicApi:
|
|||
exclude_songs=False,
|
||||
):
|
||||
try:
|
||||
response = self.connection.search2(
|
||||
response = self.connection.search3(
|
||||
query.encode("utf-8"),
|
||||
MAX_SEARCH_RESULTS if not exclude_artists else 0,
|
||||
0,
|
||||
|
@ -119,30 +119,7 @@ class SubsonicApi:
|
|||
% response.get("status")
|
||||
)
|
||||
return None
|
||||
return response.get("searchResult2")
|
||||
|
||||
def find_artist_as_search_result(self, artist_search):
|
||||
result = self.find_raw(artist_search)
|
||||
if result is None:
|
||||
return None
|
||||
return SearchResult(
|
||||
uri=uri.get_search_uri(artist_search),
|
||||
artists=[
|
||||
self.raw_artist_to_artist(artist)
|
||||
for artist in result.get("artist") or []
|
||||
if artist_search.casefold() in artist.get("name").casefold()
|
||||
],
|
||||
albums=[
|
||||
self.raw_album_to_album(album)
|
||||
for album in result.get("album") or []
|
||||
if artist_search.casefold() in album.get("artist").casefold()
|
||||
],
|
||||
tracks=[
|
||||
self.raw_song_to_track(song)
|
||||
for song in result.get("song") or []
|
||||
if artist_search.casefold() in song.get("artist").casefold()
|
||||
],
|
||||
)
|
||||
return response.get("searchResult3")
|
||||
|
||||
def find_as_search_result(
|
||||
self,
|
||||
|
|
Loading…
Add table
Reference in a new issue