Skip to content

Commit

Permalink
Merge pull request #3048 from samuelnilsson/subsonic
Browse files Browse the repository at this point in the history
Subsonicupdate plugin: Added context path and fixed bug in port configuration
  • Loading branch information
sampsyo committed Oct 11, 2018
2 parents 27f0b57 + a928dbc commit 1828114
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions beetsplug/subsonicupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
port: 4040 (default)
user: <your username>
pass: <your password>
contextpath: /subsonic
"""
from __future__ import division, absolute_import, print_function

Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions docs/plugins/subsonicupdate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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: ``/``

0 comments on commit 1828114

Please sign in to comment.