jellyfin / mopidy-jellyfin

Jellyfin Extension for Mopidy
https://jellyfin.org
Apache License 2.0
93 stars 16 forks source link

Key Error when using album_format #30

Closed mcarlton00 closed 4 years ago

mcarlton00 commented 4 years ago

When the album_format field contains a key that doesn't exist for a chosen item, we get a traceback and no values.

This could occur both if a user inputs a wrong key field or if a piece of media doesn't contain the chosen key (In this example, my format was album_format = {ProductionYear} - {Name} and one of my albums apparently doesn't have a year in it's metadata).

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/usr/lib/python3.8/site-packages/mopidy/core/library.py", line 114, in _browse
    result = backend.library.browse(uri).get()
  File "/usr/lib/python3.8/site-packages/pykka/_threading.py", line 45, in get
    _compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python3.8/site-packages/pykka/_compat/__init__.py", line 29, in reraise
    raise value
  File "/usr/lib/python3.8/site-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/usr/lib/python3.8/site-packages/pykka/_actor.py", line 299, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/home/matt/Projects/jellyfin/mopidy-jellyfin/mopidy_jellyfin/library.py", line 29, in browse
    return self.backend.remote.browse_item(item_id)
  File "/home/matt/Projects/jellyfin/mopidy-jellyfin/mopidy_jellyfin/utils.py", line 34, in _memoized
    value = self.func(*args)
  File "/home/matt/Projects/jellyfin/mopidy-jellyfin/mopidy_jellyfin/remote.py", line 290, in browse_item
    name=self.album_format.format(**item)
KeyError: 'ProductionYear'