From 7eb9913391413cee5fd28fd407d5385cac8d6d5b Mon Sep 17 00:00:00 2001 From: Nate Bogdanowicz Date: Sun, 20 Aug 2017 13:14:48 -0700 Subject: [PATCH 1/3] Fix kodi url --- beetsplug/kodiupdate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beetsplug/kodiupdate.py b/beetsplug/kodiupdate.py index 78f120d89..4713151b3 100644 --- a/beetsplug/kodiupdate.py +++ b/beetsplug/kodiupdate.py @@ -33,7 +33,7 @@ from beets.plugins import BeetsPlugin 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""" From f5dbb7b0c5406857b67099f8511a5231b423ff6b Mon Sep 17 00:00:00 2001 From: Nate Bogdanowicz Date: Sun, 20 Aug 2017 14:46:15 -0700 Subject: [PATCH 2/3] Make error handling and logging more detailed --- beetsplug/kodiupdate.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/beetsplug/kodiupdate.py b/beetsplug/kodiupdate.py index 4713151b3..ce5cb478c 100644 --- a/beetsplug/kodiupdate.py +++ b/beetsplug/kodiupdate.py @@ -28,6 +28,7 @@ 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): @@ -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') From 9d01ba0af2f3015083281169681b963943ff5290 Mon Sep 17 00:00:00 2001 From: Nate Bogdanowicz Date: Tue, 22 Aug 2017 09:56:57 -0700 Subject: [PATCH 3/3] Add changelog entry for #2662 --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 020626e4c..3e44484ed 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -24,6 +24,8 @@ Fixes: :user:`anarcat`. :bug:`2634` :bug:`2632` * :doc:`/plugins/importfeeds`: Fix an error on Python 3 in certain configurations. Thanks to :user:`djl`. :bug:`2467` :bug:`2658` +* :doc:`/plugins/kodiupdate`: Fix server URL and add better error reporting. + :bug:`2662` For developers: