diff --git a/mopidy_funkwhale/__init__.py b/mopidy_funkwhale/__init__.py index 97c8ca7..70eb1b6 100644 --- a/mopidy_funkwhale/__init__.py +++ b/mopidy_funkwhale/__init__.py @@ -37,6 +37,9 @@ class Extension(mopidy.ext.Extension): schema["password"] = mopidy.config.Secret(optional=True) schema["cache_duration"] = mopidy.config.Integer(optional=True) schema["verify_cert"] = mopidy.config.Boolean(optional=True) + + schema["exclude_compilation_artists"] = mopidy.config.Boolean(optional=True) + return schema def validate_config(self, config): diff --git a/mopidy_funkwhale/client.py b/mopidy_funkwhale/client.py index dac6a26..9f1b949 100644 --- a/mopidy_funkwhale/client.py +++ b/mopidy_funkwhale/client.py @@ -97,6 +97,8 @@ class APIClient(object): self.username = self.config["funkwhale"]["username"] self.session.verify = config["funkwhale"].get("verify_cert", True) + self.exclude_compilation_artists = self.config["funkwhale"].get("exclude_compilation_artists", True) + @property def use_oauth(self): return self.config["funkwhale"]["client_id"] and self.oauth_token @@ -132,6 +134,9 @@ class APIClient(object): return response.json() def list_artists(self, filters): + if self.exclude_compilation_artists: + filters = {"has_albums": "true", **filters} + response = self.session.get("artists/", params=filters) response.raise_for_status() return response.json() diff --git a/mopidy_funkwhale/ext.conf b/mopidy_funkwhale/ext.conf index 22d05a5..beac33c 100644 --- a/mopidy_funkwhale/ext.conf +++ b/mopidy_funkwhale/ext.conf @@ -27,3 +27,7 @@ cache_duration = 600 # Control HTTPS certificate verification. Set it to false if you're using a self-signed certificate verify_cert = true + +# Hide artists that only have track credits when browsing artists. +# Set this to false to show all artists. +exclude_compilation_artists = true \ No newline at end of file diff --git a/mopidy_funkwhale/library.py b/mopidy_funkwhale/library.py index f961db0..89d3c93 100644 --- a/mopidy_funkwhale/library.py +++ b/mopidy_funkwhale/library.py @@ -371,7 +371,7 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider): client = self.backend.client config = { "track": lambda id: [client.get_track(id)], - "album": lambda id: client.list_tracks({"album": id})["results"], + "album": lambda id: client.list_tracks({"album": id, "ordering": "position"})["results"], "artist": lambda id: client.list_tracks({"artist": id})["results"], }