mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 20:22:36 +01:00
[tests] use fallback URLs for content tests (#3163)
This commit is contained in:
parent
b92645cd37
commit
c7bd9925d9
@ -219,10 +219,21 @@ __tests__ = (
|
|||||||
"#comment" : "high-quality images (#1344)",
|
"#comment" : "high-quality images (#1344)",
|
||||||
"#category": ("", "tumblr", "post"),
|
"#category": ("", "tumblr", "post"),
|
||||||
"#class" : tumblr.TumblrPostExtractor,
|
"#class" : tumblr.TumblrPostExtractor,
|
||||||
|
"#exception" : exception.NotFoundError,
|
||||||
"#count" : 2,
|
"#count" : 2,
|
||||||
"#sha1_content": "6bc19a42787e46e1bba2ef4aeef5ca28fcd3cd34",
|
"#sha1_content": "6bc19a42787e46e1bba2ef4aeef5ca28fcd3cd34",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://k-eke.tumblr.com/post/185341184856",
|
||||||
|
"#comment" : "wrong extension returned by api (#3095)",
|
||||||
|
"#category": ("", "tumblr", "post"),
|
||||||
|
"#class" : tumblr.TumblrPostExtractor,
|
||||||
|
"#options" : {"retries": 0},
|
||||||
|
"#urls" : "https://64.media.tumblr.com/5e9d760aba24c65beaf0e72de5aae4dd/tumblr_psj5yaqV871t1ig6no1_1280.gif",
|
||||||
|
"#sha1_content": "3508d894b6cc25e364d182a8e1ff370d706965fb",
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://mikf123.tumblr.com/image/689860196535762944",
|
"#url" : "https://mikf123.tumblr.com/image/689860196535762944",
|
||||||
"#category": ("", "tumblr", "post"),
|
"#category": ("", "tumblr", "post"),
|
||||||
|
@ -222,6 +222,8 @@ class ResultJob(job.DownloadJob):
|
|||||||
|
|
||||||
if content:
|
if content:
|
||||||
self.fileobj = TestPathfmt(self.content_hash)
|
self.fileobj = TestPathfmt(self.content_hash)
|
||||||
|
else:
|
||||||
|
self._update_content = lambda url, kwdict: None
|
||||||
|
|
||||||
self.format_directory = TestFormatter(
|
self.format_directory = TestFormatter(
|
||||||
"".join(self.extractor.directory_fmt)).format_map
|
"".join(self.extractor.directory_fmt)).format_map
|
||||||
@ -269,10 +271,17 @@ class ResultJob(job.DownloadJob):
|
|||||||
self.archive_hash.update(archive_id.encode())
|
self.archive_hash.update(archive_id.encode())
|
||||||
|
|
||||||
def _update_content(self, url, kwdict):
|
def _update_content(self, url, kwdict):
|
||||||
if self.content:
|
|
||||||
scheme = url.partition(":")[0]
|
|
||||||
self.fileobj.kwdict = kwdict
|
self.fileobj.kwdict = kwdict
|
||||||
self.get_downloader(scheme).download(url, self.fileobj)
|
|
||||||
|
downloader = self.get_downloader(url.partition(":")[0])
|
||||||
|
if downloader.download(url, self.fileobj):
|
||||||
|
return
|
||||||
|
|
||||||
|
for num, url in enumerate(kwdict.get("_fallback") or (), 1):
|
||||||
|
self.log.warning("Trying fallback URL #%d", num)
|
||||||
|
downloader = self.get_downloader(url.partition(":")[0])
|
||||||
|
if downloader.download(url, self.fileobj):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class TestPathfmt():
|
class TestPathfmt():
|
||||||
|
Loading…
Reference in New Issue
Block a user