improve research by artist
This commit is contained in:
parent
89093e7064
commit
eff25672d9
2 changed files with 31 additions and 1 deletions
|
@ -148,6 +148,7 @@ class SubidyLibraryProvider(backend.LibraryProvider):
|
|||
tracks=self.subsonic_api.get_songs_as_tracks(album.get("id"))
|
||||
)
|
||||
|
||||
|
||||
def get_distinct(self, field, query):
|
||||
search_result = self.search(query)
|
||||
if not search_result:
|
||||
|
@ -173,7 +174,7 @@ class SubidyLibraryProvider(backend.LibraryProvider):
|
|||
query.get("artist")[0], query.get("album")[0]
|
||||
)
|
||||
if "artist" in query:
|
||||
return self.subsonic_api.find_as_search_result(
|
||||
return self.subsonic_api.find_artist_as_search_result(
|
||||
query.get("artist")[0]
|
||||
)
|
||||
if "any" in query:
|
||||
|
|
|
@ -93,6 +93,7 @@ class SubsonicApi:
|
|||
def get_censored_song_stream_uri(self, song_id):
|
||||
return self.get_subsonic_uri("stream", dict(id=song_id), True)
|
||||
|
||||
|
||||
def find_raw(
|
||||
self,
|
||||
query,
|
||||
|
@ -121,6 +122,34 @@ class SubsonicApi:
|
|||
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()
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def find_as_search_result(
|
||||
self,
|
||||
query,
|
||||
|
|
Loading…
Add table
Reference in a new issue