diff --git a/beets/mediafile.py b/beets/mediafile.py index 7522acf0a..c820dcb3b 100644 --- a/beets/mediafile.py +++ b/beets/mediafile.py @@ -326,7 +326,11 @@ class Image(object): self.data = data self.desc = desc if isinstance(type, int): - type = list(ImageType)[type] + try: + type = list(ImageType)[type] + except IndexError: + log.debug(u"ignoring unknown image type index {0}", type) + type = ImageType.other self.type = type @property diff --git a/beetsplug/embedart.py b/beetsplug/embedart.py index 3192e8c04..6f6daa96f 100644 --- a/beetsplug/embedart.py +++ b/beetsplug/embedart.py @@ -93,10 +93,10 @@ class EmbedCoverArtPlugin(BeetsPlugin): help='image output file') def extract_func(lib, opts, args): - outpath = normpath(opts.outpath or 'cover') - item = lib.items(decargs(args)).get() - if item: - self.extract(outpath, item) + outpath = normpath(opts.outpath or config['art_filename'].get()) + for item in lib.items(decargs(args)): + if self.extract(outpath, item): + return extract_cmd.func = extract_func # Clear command. diff --git a/docs/changelog.rst b/docs/changelog.rst index 1b85248f3..7ad300504 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,6 +22,8 @@ Features: * :doc:`plugins/mbsync`: A new ``-f/--format`` option controls the output format when listing unrecognized items. The output is also now more helpful by default. :bug:`1246` +* :doc:`/plugins/fetchart`: Names of extracted image art is taken from the + ``art_filename`` configuration option. :bug:`1258` Fixes: @@ -46,6 +48,8 @@ Fixes: :bug:`1248` * :doc:`/plugins/embedart`: We now show a comprehensible error message when ``beet embedart -f FILE`` is given a non-existent path. :bug:`1252` +* Fix a crash when a file has an unrecognized image type tag. Thanks to + Matthias Kiefer. :bug:`1260` For developers: diff --git a/docs/plugins/embedart.rst b/docs/plugins/embedart.rst index bf99c3873..273046979 100644 --- a/docs/plugins/embedart.rst +++ b/docs/plugins/embedart.rst @@ -80,8 +80,9 @@ embedded album art: * ``beet extractart [-o FILE] QUERY``: extracts the image from an item matching the query and stores it in a file. You can specify the destination file using the ``-o`` option, but leave off the extension: it will be chosen - automatically. The destination filename defaults to ``cover`` if it's not - specified. + automatically. The destination filename is specified using the + ``art_filename`` configuration option. It defaults to ``cover`` if it's not + specified via ``-o`` nor the config. * ``beet clearart QUERY``: removes all embedded images from all items matching the query. (Use with caution!) diff --git a/test/rsrc/image_unknown_type.mp3 b/test/rsrc/image_unknown_type.mp3 new file mode 100755 index 000000000..441adf62a Binary files /dev/null and b/test/rsrc/image_unknown_type.mp3 differ diff --git a/test/test_mediafile.py b/test/test_mediafile.py index c685cdd94..74f6fe8c5 100644 --- a/test/test_mediafile.py +++ b/test/test_mediafile.py @@ -730,6 +730,10 @@ class MP3Test(ReadWriteTestBase, PartialTestMixin, 'channels': 1, } + def test_unknown_apic_type(self): + mediafile = self._mediafile_fixture('image_unknown_type') + self.assertEqual(mediafile.images[0].type, ImageType.other) + class MP4Test(ReadWriteTestBase, PartialTestMixin, ImageStructureTestMixin, unittest.TestCase):