Merge branch 'own_artists' into 'master'

Add option to show only artists from own libraries

Closes #10

See merge request funkwhale/mopidy!6
main
Agate 2020-06-19 13:27:41 +02:00
commit 3b26b1df5f
2 changed files with 21 additions and 0 deletions

View File

@ -161,6 +161,7 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
[
new_folder("Recent", "artists:recent"),
new_folder("By name", "artists:by-name"),
new_folder("Own Content", "artists:scope-me"),
],
False,
)
@ -207,6 +208,23 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
]
return artists, True
if root == "scope-me":
if end:
# list albums
return (
self.browse_albums(uri_prefix=albums_uri_prefix, remaining=end),
True
)
payload = self.backend.client.list_artists(
{"ordering": "name", "page_size": 50, "scope": "me"}
)
uri_prefix = "funkwhale:directory:artists:scope-me"
artists = [
convert_to_artist(row, uri_prefix=uri_prefix, ref=True)
for row in self.backend.client.load_all(payload)
]
return artists, True
return [], False
def search(self, query=None, uris=None, exact=False):

View File

@ -157,6 +157,9 @@ def test_browse_artists_root(library):
models.Ref.directory(
uri="funkwhale:directory:artists:by-name", name="By name"
),
models.Ref.directory(
uri="funkwhale:directory:artists:scope-me", name="Own Content"
),
],
False,
)