[deviantart] always download original images

Deviation-objects returned by the DeviantArt API don't always contain
the URL and metadata of the original image ([1]). Getting this
information requires an additional API call [2], which is indicated by
the 'is_downloadable' and 'download_filesize' metadata within a
deviation-object.

[1] https://myria-moon.deviantart.com/art/Aime-Moi-part-en-vadrouille-261986576
[2] https://www.deviantart.com/developers/http/v1/20160316/deviation_download/bed6982b88949bdb08b52cd6763fcafd
This commit is contained in:
Mike Fährmann
2017-10-07 13:07:34 +02:00
parent 8e6a767109
commit 75d3a1f72f
3 changed files with 48 additions and 11 deletions

View File

@@ -27,17 +27,23 @@ class TestExtractors(unittest.TestCase):
config.clear()
def _run_test(self, extr, url, result):
content = "content" in result if result else False
if result:
if "options" in result:
for key, value in result["options"]:
config.set(key.split("."), value)
content = "content" in result
else:
content = False
tjob = job.TestJob(url, content=content)
self.assertEqual(extr, tjob.extractor.__class__)
if not result:
return
if "options" in result:
for key, value in result["options"]:
config.set(key, value)
if "exception" in result:
self.assertRaises(result["exception"], tjob.run)
return
tjob.run()
if "url" in result:
self.assertEqual(result["url"], tjob.hash_url.hexdigest())