fetchart: cover engines yield their results

This commit is contained in:
Fabrice Laporte 2014-11-10 22:17:34 +01:00
parent 5713df3d5a
commit ef6d3efe6d
2 changed files with 9 additions and 9 deletions

View file

@ -126,7 +126,7 @@ def aao_art(album):
m = re.search(AAO_PAT, resp.text)
if m:
image_url = m.group(1)
return image_url
yield image_url
else:
log.debug(u'fetchart: no image found on page')
@ -155,7 +155,7 @@ def google_art(album):
data = results['responseData']
dataInfo = data['results']
for myUrl in dataInfo:
return myUrl['unescapedUrl']
yield myUrl['unescapedUrl']
except:
log.debug(u'fetchart: error scraping art page')
return
@ -172,7 +172,7 @@ def itunes_art(album):
if itunes_album.get_artwork()['100']:
small_url = itunes_album.get_artwork()['100']
big_url = small_url.replace('100x100', '1200x1200')
return big_url
yield big_url
else:
log.debug(u'fetchart: album has no artwork in iTunes Store')
except IndexError:
@ -181,6 +181,7 @@ def itunes_art(album):
# Art from the filesystem.
def filename_priority(filename, cover_names):
"""Sort order for image names.
@ -244,7 +245,6 @@ def _source_urls(album, sources=SOURCES_ALL):
"""
for s in sources:
urls = ART_FUNCS[s](album)
if urls:
for url in urls:
yield url

View file

@ -198,13 +198,13 @@ class AAOTest(_common.TestCase):
self.mock_response(self.AAO_URL, body)
album = _common.Bag(asin=self.ASIN)
res = fetchart.aao_art(album)
self.assertEqual(res, 'TARGET_URL')
self.assertEqual(list(res)[0], 'TARGET_URL')
def test_aao_scraper_returns_none_when_no_image_present(self):
def test_aao_scraper_returns_no_result_when_no_image_present(self):
self.mock_response(self.AAO_URL, 'blah blah')
album = _common.Bag(asin=self.ASIN)
res = fetchart.aao_art(album)
self.assertEqual(res, None)
self.assertEqual(list(res), [])
class GoogleImageTest(_common.TestCase):