From a928dbc470af3e2e56328205320746f773c4fe33 Mon Sep 17 00:00:00 2001 From: Samuel Nilsson Date: Wed, 10 Oct 2018 21:22:31 +0200 Subject: [PATCH] Added contextpath configuration to subsonicupdate plugin. Fixed bug in subsonicupdate port configuration. --- beetsplug/subsonicupdate.py | 9 +++++++-- docs/plugins/subsonicupdate.rst | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/beetsplug/subsonicupdate.py b/beetsplug/subsonicupdate.py index 57f3f7f6f1..93c47e2de3 100644 --- a/beetsplug/subsonicupdate.py +++ b/beetsplug/subsonicupdate.py @@ -21,6 +21,7 @@ port: 4040 (default) user: pass: + contextpath: /subsonic """ from __future__ import division, absolute_import, print_function @@ -44,15 +45,17 @@ def __init__(self): 'port': '4040', 'user': 'admin', 'pass': 'admin', + 'contextpath': '/', }) config['subsonic']['pass'].redact = True self.register_listener('import', self.loaded) def loaded(self): host = config['subsonic']['host'].as_str() - port = config['subsonic']['port'].as_str() + port = config['subsonic']['port'].get(int) user = config['subsonic']['user'].as_str() passw = config['subsonic']['pass'].as_str() + contextpath = config['subsonic']['contextpath'].as_str() # To avoid sending plaintext passwords, authentication will be # performed via username, a token, and a 6 random @@ -75,7 +78,9 @@ def loaded(self): 'v': '1.15.0', # Subsonic 6.1 and newer. 'c': 'beets' } - url = "http://{}:{}/rest/startScan".format(host, port) + if contextpath is '/': + contextpath = '' + url = "http://{}:{}{}/rest/startScan".format(host, port, contextpath) response = requests.post(url, params=payload) if response.status_code != 200: diff --git a/docs/plugins/subsonicupdate.rst b/docs/plugins/subsonicupdate.rst index 0f5923c002..daf4a0cfb3 100644 --- a/docs/plugins/subsonicupdate.rst +++ b/docs/plugins/subsonicupdate.rst @@ -17,6 +17,7 @@ which looks like this:: port: 4040 user: username pass: password + contextpath: /subsonic With that all in place, beets will send a Rest API to your Subsonic server every time you import new music. @@ -33,3 +34,4 @@ The available options under the ``subsonic:`` section are: - **port**: The Subsonic server port. Default: ``4040`` - **user**: The Subsonic user. Default: ``admin`` - **pass**: The Subsonic user password. Default: ``admin`` +- **contextpath**: The Subsonic context path. Default: ``/``