Merge branch '15-album-artists-and-album-track-ordering' into 'master'
Hide compilation artists and fix album track ordering (#15) Closes #15 See merge request funkwhale/mopidy!14main
commit
3f4120f29c
|
@ -37,6 +37,9 @@ class Extension(mopidy.ext.Extension):
|
||||||
schema["password"] = mopidy.config.Secret(optional=True)
|
schema["password"] = mopidy.config.Secret(optional=True)
|
||||||
schema["cache_duration"] = mopidy.config.Integer(optional=True)
|
schema["cache_duration"] = mopidy.config.Integer(optional=True)
|
||||||
schema["verify_cert"] = mopidy.config.Boolean(optional=True)
|
schema["verify_cert"] = mopidy.config.Boolean(optional=True)
|
||||||
|
|
||||||
|
schema["exclude_compilation_artists"] = mopidy.config.Boolean(optional=True)
|
||||||
|
|
||||||
return schema
|
return schema
|
||||||
|
|
||||||
def validate_config(self, config):
|
def validate_config(self, config):
|
||||||
|
|
|
@ -97,6 +97,8 @@ class APIClient(object):
|
||||||
self.username = self.config["funkwhale"]["username"]
|
self.username = self.config["funkwhale"]["username"]
|
||||||
self.session.verify = config["funkwhale"].get("verify_cert", True)
|
self.session.verify = config["funkwhale"].get("verify_cert", True)
|
||||||
|
|
||||||
|
self.exclude_compilation_artists = self.config["funkwhale"].get("exclude_compilation_artists", True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def use_oauth(self):
|
def use_oauth(self):
|
||||||
return self.config["funkwhale"]["client_id"] and self.oauth_token
|
return self.config["funkwhale"]["client_id"] and self.oauth_token
|
||||||
|
@ -132,6 +134,9 @@ class APIClient(object):
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def list_artists(self, filters):
|
def list_artists(self, filters):
|
||||||
|
if self.exclude_compilation_artists:
|
||||||
|
filters = {"has_albums": "true", **filters}
|
||||||
|
|
||||||
response = self.session.get("artists/", params=filters)
|
response = self.session.get("artists/", params=filters)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
|
@ -27,3 +27,7 @@ cache_duration = 600
|
||||||
|
|
||||||
# Control HTTPS certificate verification. Set it to false if you're using a self-signed certificate
|
# Control HTTPS certificate verification. Set it to false if you're using a self-signed certificate
|
||||||
verify_cert = true
|
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
|
|
@ -371,7 +371,7 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
|
||||||
client = self.backend.client
|
client = self.backend.client
|
||||||
config = {
|
config = {
|
||||||
"track": lambda id: [client.get_track(id)],
|
"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"],
|
"artist": lambda id: client.list_tracks({"artist": id})["results"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue