[pixiv] provide fallback URLs (#6762)
This commit is contained in:
@@ -111,6 +111,7 @@ class PixivExtractor(Extractor):
|
|||||||
{
|
{
|
||||||
"url" : img["image_urls"]["original"],
|
"url" : img["image_urls"]["original"],
|
||||||
"suffix": "_p{:02}".format(num),
|
"suffix": "_p{:02}".format(num),
|
||||||
|
"_fallback": self._fallback_image(img),
|
||||||
}
|
}
|
||||||
for num, img in enumerate(meta_pages)
|
for num, img in enumerate(meta_pages)
|
||||||
]
|
]
|
||||||
@@ -128,7 +129,7 @@ class PixivExtractor(Extractor):
|
|||||||
self.log.warning("%s: 'My pixiv' locked", work["id"])
|
self.log.warning("%s: 'My pixiv' locked", work["id"])
|
||||||
|
|
||||||
elif work["type"] != "ugoira":
|
elif work["type"] != "ugoira":
|
||||||
return ({"url": url},)
|
return ({"url": url, "_fallback": self._fallback_image(url)},)
|
||||||
|
|
||||||
elif self.load_ugoira:
|
elif self.load_ugoira:
|
||||||
try:
|
try:
|
||||||
@@ -269,6 +270,24 @@ class PixivExtractor(Extractor):
|
|||||||
except exception.HttpError:
|
except exception.HttpError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _fallback_image(self, src):
|
||||||
|
if isinstance(src, str):
|
||||||
|
urls = None
|
||||||
|
orig = src
|
||||||
|
else:
|
||||||
|
urls = src["image_urls"]
|
||||||
|
orig = urls["original"]
|
||||||
|
|
||||||
|
base = orig.rpartition(".")[0]
|
||||||
|
yield base.replace("-original/", "-master/", 1) + "_master1200.jpg"
|
||||||
|
|
||||||
|
if urls is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
for fmt in ("large", "medium", "square_medium"):
|
||||||
|
if fmt in urls:
|
||||||
|
yield urls[fmt]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _date_from_url(url, offset=timedelta(hours=9)):
|
def _date_from_url(url, offset=timedelta(hours=9)):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -289,6 +289,15 @@ __tests__ = (
|
|||||||
"caption": r"re:Either she doesn't know how to pose or she can't move with that much clothing on her, in any case she's very well dressed for a holiday trip around town. Lots of stuff to see and a perfect day to grab some sweet pastries at the bakery.<br />...",
|
"caption": r"re:Either she doesn't know how to pose or she can't move with that much clothing on her, in any case she's very well dressed for a holiday trip around town. Lots of stuff to see and a perfect day to grab some sweet pastries at the bakery.<br />...",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://www.pixiv.net/artworks/56360615",
|
||||||
|
"#comment" : "fallback; 'original' version results in HTTP 500 error (#6762)",
|
||||||
|
"#class" : pixiv.PixivWorkExtractor,
|
||||||
|
"#options" : {"retries": 0},
|
||||||
|
"#range" : "4",
|
||||||
|
"#sha1_content": "aa119c27fec0a36bbd06e7491987acf5f1be6293",
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://www.pixiv.net/en/artworks/966412",
|
"#url" : "https://www.pixiv.net/en/artworks/966412",
|
||||||
"#category": ("", "pixiv", "work"),
|
"#category": ("", "pixiv", "work"),
|
||||||
|
|||||||
Reference in New Issue
Block a user