Code fixed according to flake8

This commit is contained in:
Pauligrinder 2017-03-01 11:11:54 +02:00 committed by GitHub
parent f315a17bb2
commit 659c17f825

View file

@ -13,7 +13,8 @@
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
"""Updates a Kodi library whenever the beets library is changed. This is based on the Plex Update plugin.
"""Updates a Kodi library whenever the beets library is changed.
This is based on the Plex Update plugin.
Put something like the following in your config.yaml to configure:
kodi:
@ -34,13 +35,22 @@ def update_kodi(host, port, user, password):
"""
url = "http://{0}:{1}/jsonrpc/".format(host, port)
# The kodi jsonrpc documentation states that Content-Type: application/json is mandatory
"""Content-Type: application/json is mandatory
according to the kodi jsonrpc documentation"""
headers = {'Content-Type': 'application/json'}
# Create the payload. Id seems to be mandatory.
payload = {'jsonrpc': '2.0', 'method':'AudioLibrary.Scan', 'id':1}
r = requests.post(url, auth=(user, password), json=payload, headers=headers)
payload = {'jsonrpc': '2.0', 'method': 'AudioLibrary.Scan', 'id': 1}
r = requests.post(
url,
auth=(user, password),
json=payload,
headers=headers)
return r
class KodiUpdate(BeetsPlugin):
def __init__(self):
super(KodiUpdate, self).__init__()
@ -56,7 +66,7 @@ class KodiUpdate(BeetsPlugin):
self.register_listener('database_change', self.listen_for_db_change)
def listen_for_db_change(self, lib, model):
"""Listens for beets db change and register the update for the end"""
"""Listens for beets db change and register the update"""
self.register_listener('cli_exit', self.update)
def update(self, lib):
@ -75,4 +85,3 @@ class KodiUpdate(BeetsPlugin):
except requests.exceptions.RequestException:
self._log.warning(u'Update failed.')