Merge branch 'master' into pr_deezer_tolerate_missing_fields

This commit is contained in:
Adrian Sampson 2021-12-12 14:33:30 -05:00 committed by GitHub
commit 3fcedba5c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 23 deletions

View file

@ -522,8 +522,8 @@ class Item(LibModel):
'rg_track_peak': types.NULL_FLOAT,
'rg_album_gain': types.NULL_FLOAT,
'rg_album_peak': types.NULL_FLOAT,
'r128_track_gain': types.NullPaddedInt(6),
'r128_album_gain': types.NullPaddedInt(6),
'r128_track_gain': types.NULL_FLOAT,
'r128_album_gain': types.NULL_FLOAT,
'original_year': types.PaddedInt(4),
'original_month': types.PaddedInt(2),
'original_day': types.PaddedInt(2),
@ -1071,7 +1071,7 @@ class Album(LibModel):
'releasegroupdisambig': types.STRING,
'rg_album_gain': types.NULL_FLOAT,
'rg_album_peak': types.NULL_FLOAT,
'r128_album_gain': types.NullPaddedInt(6),
'r128_album_gain': types.NULL_FLOAT,
'original_year': types.PaddedInt(4),
'original_month': types.PaddedInt(2),
'original_day': types.PaddedInt(2),

View file

@ -54,11 +54,12 @@ class KodiUpdate(BeetsPlugin):
super().__init__()
# Adding defaults.
config['kodi'].add({
config['kodi'].add([{
'host': 'localhost',
'port': 8080,
'user': 'kodi',
'pwd': 'kodi'})
'pwd': 'kodi'
}])
config['kodi']['pwd'].redact = True
self.register_listener('database_change', self.listen_for_db_change)
@ -72,24 +73,34 @@ class KodiUpdate(BeetsPlugin):
"""
self._log.info('Requesting a Kodi library update...')
# Try to send update request.
try:
r = update_kodi(
config['kodi']['host'].get(),
config['kodi']['port'].get(),
config['kodi']['user'].get(),
config['kodi']['pwd'].get())
r.raise_for_status()
kodi = config['kodi'].get()
except requests.exceptions.RequestException as e:
self._log.warning('Kodi update failed: {0}',
str(e))
return
# Backwards compatibility in case not configured as an array
if not isinstance(kodi, list):
kodi = [kodi]
json = r.json()
if json.get('result') != 'OK':
self._log.warning('Kodi update failed: JSON response was {0!r}',
json)
return
for instance in kodi:
# Try to send update request.
try:
r = update_kodi(
instance['host'],
instance['port'],
instance['user'],
instance['pwd']
)
r.raise_for_status()
self._log.info('Kodi update triggered')
json = r.json()
if json.get('result') != 'OK':
self._log.warning(
'Kodi update failed: JSON response was {0!r}', json
)
continue
self._log.info(
'Kodi update triggered for {0}:{1}',
instance['host'], instance['port']
)
except requests.exceptions.RequestException as e:
self._log.warning('Kodi update failed: {0}', str(e))
continue

View file

@ -6,6 +6,11 @@ Changelog
Changelog goes here!
New features:
* :doc:`/plugins/kodiupdate`: Now supports multiple kodi instances
:bug:`4101`
Bug fixes:
* :doc:`/plugins/lyrics`: Fix Genius search by using query params instead of body.
@ -14,6 +19,10 @@ Bug fixes:
* :doc:`/plugins/deezer`: Tolerate missing fields when searching for singleton
tracks
:bug:`4116`
* :doc:`/plugins/replaygain`: The type of the internal ``r128_track_gain`` and
``r128_album_gain`` fields was changed from integer to float to fix loss of
precision due to truncation.
:bug:`4169`
For packagers:

View file

@ -16,6 +16,19 @@ which looks like this::
user: kodi
pwd: kodi
To update multiple Kodi instances, specify them as an array::
kodi:
- host: x.x.x.x
port: 8080
user: kodi
pwd: kodi
- host: y.y.y.y
port: 8081
user: kodi2
pwd: kodi2
To use the ``kodiupdate`` plugin you need to install the `requests`_ library with::
pip install requests