From bef84395ed8c6299c6fe84542a572478ef80b4f8 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 16 Aug 2021 19:15:24 -0700 Subject: [PATCH] Add option to show or hide track artists when browsing artists --- mopidy_funkwhale/__init__.py | 3 +++ mopidy_funkwhale/client.py | 5 +++++ mopidy_funkwhale/ext.conf | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/mopidy_funkwhale/__init__.py b/mopidy_funkwhale/__init__.py index 97c8ca7..389067c 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["show_track_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..a9813bb 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.show_track_artists = self.config["funkwhale"].get("show_track_artists", False) + @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 not self.show_track_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..f02f40f 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 + +# Show all artists when browsing, even those without albums (e.g. per-track +# credits or collaborations). Set this to false to only show album artists +show_track_artists = false \ No newline at end of file