diff --git a/sonata/artwork.py b/sonata/artwork.py index b6f9913a..986b54c8 100644 --- a/sonata/artwork.py +++ b/sonata/artwork.py @@ -102,7 +102,12 @@ def path(self, artist, album, song_dir, specific_kind=None): if specific_kind is None: specific_kind = self.config.art_location - return next(iter(locations_map[specific_kind])) + try: + result = next(iter(locations_map[specific_kind])) + except StopIteration: # We tried an empty location :( + result = None + return result + def path_from_song(self, song, specific_kind=None): """Same as `path()` but using a Song object.""" diff --git a/sonata/tests/test_artwork.py b/sonata/tests/test_artwork.py index 4381a2eb..b3a6cadd 100644 --- a/sonata/tests/test_artwork.py +++ b/sonata/tests/test_artwork.py @@ -88,6 +88,14 @@ def test_find_path_from_data_as_custom_dot_jpg(self): res = self._call_artwork_path_from_data() self.assertEqual('/foo/To/Ta/bar.png', res) + def test_find_path_from_data_as_custom_without_filename(self): + self.config.art_location_custom_filename = "" + self.config.art_location = consts.ART_LOCATION_CUSTOM + + res = self._call_artwork_path_from_data() + # We tried CUSTOM without a valid custom filename :/ + self.assertEqual(None, res) + def test_find_path_from_data_force_location_type(self): self.config.art_location = "foo bar" # Should not be used