mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 18:12:19 +01:00
Merge pull request #2662 from natezb/master
Fix kodiupdate URL and add better error reporting
This commit is contained in:
commit
d87c73efb3
2 changed files with 19 additions and 6 deletions
|
|
@ -28,12 +28,13 @@ from __future__ import division, absolute_import, print_function
|
|||
import requests
|
||||
from beets import config
|
||||
from beets.plugins import BeetsPlugin
|
||||
import six
|
||||
|
||||
|
||||
def update_kodi(host, port, user, password):
|
||||
"""Sends request to the Kodi api to start a library refresh.
|
||||
"""
|
||||
url = "http://{0}:{1}/jsonrpc/".format(host, port)
|
||||
url = "http://{0}:{1}/jsonrpc".format(host, port)
|
||||
|
||||
"""Content-Type: application/json is mandatory
|
||||
according to the kodi jsonrpc documentation"""
|
||||
|
|
@ -72,16 +73,26 @@ class KodiUpdate(BeetsPlugin):
|
|||
def update(self, lib):
|
||||
"""When the client exists try to send refresh request to Kodi server.
|
||||
"""
|
||||
self._log.info(u'Updating Kodi library...')
|
||||
self._log.info(u'Requesting a Kodi library update...')
|
||||
|
||||
# Try to send update request.
|
||||
try:
|
||||
update_kodi(
|
||||
r = update_kodi(
|
||||
config['kodi']['host'].get(),
|
||||
config['kodi']['port'].get(),
|
||||
config['kodi']['user'].get(),
|
||||
config['kodi']['pwd'].get())
|
||||
self._log.info(u'... started.')
|
||||
r.raise_for_status()
|
||||
|
||||
except requests.exceptions.RequestException:
|
||||
self._log.warning(u'Update failed.')
|
||||
except requests.exceptions.RequestException as e:
|
||||
self._log.warning(u'Kodi update failed: {0}',
|
||||
six.text_type(e))
|
||||
return
|
||||
|
||||
json = r.json()
|
||||
if json.get('result') != 'OK':
|
||||
self._log.warning(u'Kodi update failed: JSON response was {0!r}',
|
||||
json)
|
||||
return
|
||||
|
||||
self._log.info(u'Kodi update triggered')
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ Fixes:
|
|||
* :doc:`/plugins/edit`: Fix a bug when editing items during a ``-L``
|
||||
re-import. Previously, diffs against against unrelated items could be
|
||||
shown or beets could crash with a traceback. :bug:`2659`
|
||||
* :doc:`/plugins/kodiupdate`: Fix server URL and add better error reporting.
|
||||
:bug:`2662`
|
||||
|
||||
For developers:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue