diff --git a/config/settings.py b/config/settings.py index 12ecd126..5c1e83db 100644 --- a/config/settings.py +++ b/config/settings.py @@ -202,6 +202,7 @@ class ConfigManager: } }, "listenbrainz": { + "base_url": "", "token": "" }, "acoustid": { diff --git a/core/listenbrainz_client.py b/core/listenbrainz_client.py index 389496f7..bf274e21 100644 --- a/core/listenbrainz_client.py +++ b/core/listenbrainz_client.py @@ -10,7 +10,15 @@ class ListenBrainzClient: """Client for interacting with ListenBrainz API""" def __init__(self): - self.base_url = "https://api.listenbrainz.org/1" + custom_url = config_manager.get("listenbrainz.base_url", "") + if custom_url: + # Strip trailing slashes and ensure /1 API version suffix + custom_url = custom_url.rstrip('/') + if not custom_url.endswith('/1'): + custom_url += '/1' + self.base_url = custom_url + else: + self.base_url = "https://api.listenbrainz.org/1" self.token = config_manager.get("listenbrainz.token", "") self.username = None diff --git a/web_server.py b/web_server.py index 9b982d11..0376bcbd 100644 --- a/web_server.py +++ b/web_server.py @@ -3128,7 +3128,14 @@ def run_service_test(service, test_config): try: # Test ListenBrainz API by validating the token - url = "https://api.listenbrainz.org/1/validate-token" + custom_base = test_config.get('base_url', '').rstrip('/') + if custom_base: + if not custom_base.endswith('/1'): + custom_base += '/1' + lb_api_base = custom_base + else: + lb_api_base = "https://api.listenbrainz.org/1" + url = f"{lb_api_base}/validate-token" headers = { 'Authorization': f'Token {token}' } diff --git a/webui/index.html b/webui/index.html index 9e07ccb1..cb8a4cdb 100644 --- a/webui/index.html +++ b/webui/index.html @@ -3105,6 +3105,11 @@