From bef84395ed8c6299c6fe84542a572478ef80b4f8 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 16 Aug 2021 19:15:24 -0700 Subject: [PATCH 1/3] 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 From 0cb540ef6ce74a4edf3a10ad2e1e3fcd3224529f Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 16 Aug 2021 19:25:49 -0700 Subject: [PATCH 2/3] Fix album track ordering in lookup results --- mopidy_funkwhale/library.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy_funkwhale/library.py b/mopidy_funkwhale/library.py index 00da9cc..c78b27f 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"], } From 9b00b87d11ae1e034c96ad90c963cc5f98c2f96b Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 16 Aug 2021 19:58:21 -0700 Subject: [PATCH 3/3] Rename exclude_compilation_artists setting to match the same option in funkwhale --- mopidy_funkwhale/__init__.py | 2 +- mopidy_funkwhale/client.py | 4 ++-- mopidy_funkwhale/ext.conf | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mopidy_funkwhale/__init__.py b/mopidy_funkwhale/__init__.py index 389067c..70eb1b6 100644 --- a/mopidy_funkwhale/__init__.py +++ b/mopidy_funkwhale/__init__.py @@ -38,7 +38,7 @@ class Extension(mopidy.ext.Extension): 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) + schema["exclude_compilation_artists"] = mopidy.config.Boolean(optional=True) return schema diff --git a/mopidy_funkwhale/client.py b/mopidy_funkwhale/client.py index a9813bb..9f1b949 100644 --- a/mopidy_funkwhale/client.py +++ b/mopidy_funkwhale/client.py @@ -97,7 +97,7 @@ 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) + self.exclude_compilation_artists = self.config["funkwhale"].get("exclude_compilation_artists", True) @property def use_oauth(self): @@ -134,7 +134,7 @@ class APIClient(object): return response.json() def list_artists(self, filters): - if not self.show_track_artists: + if self.exclude_compilation_artists: filters = {"has_albums": "true", **filters} response = self.session.get("artists/", params=filters) diff --git a/mopidy_funkwhale/ext.conf b/mopidy_funkwhale/ext.conf index f02f40f..beac33c 100644 --- a/mopidy_funkwhale/ext.conf +++ b/mopidy_funkwhale/ext.conf @@ -28,6 +28,6 @@ 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 +# 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