mirror of
https://github.com/beetbox/beets.git
synced 2026-02-09 00:41:57 +01:00
keyfinder: Catch output from keyfinder-cli with no key
This commit is contained in:
parent
9657919968
commit
e11687f80a
3 changed files with 20 additions and 1 deletions
|
|
@ -76,7 +76,14 @@ class KeyFinderPlugin(BeetsPlugin):
|
|||
item.path)
|
||||
continue
|
||||
|
||||
key_raw = output.rsplit(None, 1)[-1]
|
||||
try:
|
||||
key_raw = output.rsplit(None, 1)[-1]
|
||||
except IndexError:
|
||||
# Sometimes keyfinder-cli returns 0 but with no key, usually when
|
||||
# the file is silent or corrupt, so we log and skip.
|
||||
self._log.error(u'no key returned for path: {0}', item.path)
|
||||
continue
|
||||
|
||||
try:
|
||||
key = util.text_string(key_raw)
|
||||
except UnicodeDecodeError:
|
||||
|
|
|
|||
|
|
@ -282,6 +282,8 @@ Fixes:
|
|||
:bug:`3773` :bug:`3774`
|
||||
* Fix a bug causing PIL to generate poor quality JPEGs when resizing artwork.
|
||||
:bug:`3743`
|
||||
* :doc:`plugins/keyfinder`: Catch output from ``keyfinder-cli`` that is missing key.
|
||||
:bug:`2242`
|
||||
|
||||
For plugin developers:
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ class KeyFinderTest(unittest.TestCase, TestHelper):
|
|||
item.load()
|
||||
self.assertEqual(item['initial_key'], 'F')
|
||||
|
||||
def test_no_key(self, command_output):
|
||||
item = Item(path='/file')
|
||||
item.add(self.lib)
|
||||
|
||||
command_output.return_value = util.CommandOutput(b"", b"")
|
||||
self.run_command('keyfinder')
|
||||
|
||||
item.load()
|
||||
self.assertEqual(item['initial_key'], None)
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue