Fix the fanarttv source failing when there were images found, but no cover art

This commit is contained in:
wordofglass 2016-04-20 12:59:18 +02:00
parent 8e6470d4bc
commit ac2f7fe712
2 changed files with 31 additions and 6 deletions

View file

@ -395,12 +395,12 @@ class FanartTV(RemoteArtSource):
return
matches = []
# can there be more than one releasegroupid per responce?
for mb_releasegroupid in data.get(u'albums', dict()):
if album.mb_releasegroupid == mb_releasegroupid:
# note: there might be more art referenced, e.g. cdart
matches.extend(
data[u'albums'][mb_releasegroupid][u'albumcover'])
# can there be more than one releasegroupid per response?
for mbid, art in data.get(u'albums', dict()).items():
# there might be more art referenced, e.g. cdart, and an albumcover
# might not be present, even if the request was succesful
if album.mb_releasegroupid == mbid and u'albumcover' in art:
matches.extend(art[u'albumcover'])
# can this actually occur?
else:
self._log.debug(u'fanart.tv: unexpected mb_releasegroupid in '

View file

@ -315,6 +315,23 @@ class FanartTVTest(UseThePlugin):
}
}
}"""
RESPONSE_NO_ART = u"""{
"name": "artistname",
"mbid_id": "artistid",
"albums": {
"thereleasegroupid": {
"cdart": [
{
"id": "123",
"url": "http://example.com/4.jpg",
"likes": "0",
"disc": "1",
"size": "1000"
}
]
}
}
}"""
RESPONSE_ERROR = u"""{
"status": "error",
"error message": "the error message"
@ -355,6 +372,14 @@ class FanartTVTest(UseThePlugin):
with self.assertRaises(StopIteration):
next(self.source.get(album, self.extra))
def test_fanarttv_only_other_images(self):
# The source used to fail when there were images present, but no cover
album = _common.Bag(mb_releasegroupid=u'thereleasegroupid')
self.mock_response(fetchart.FanartTV.API_ALBUMS + u'thereleasegroupid',
self.RESPONSE_NO_ART)
with self.assertRaises(StopIteration):
next(self.source.get(album, self.extra))
@_common.slow_test()
class ArtImporterTest(UseThePlugin):