[pixiv] fix 'sanity_level' workaround (#4327)
The App API now returns https://s.pximg.net/common/images/limit_unviewable_360.png as URL for "Work cannot be displayed" artworks.
This commit is contained in:
@@ -27,8 +27,10 @@ class PixivExtractor(Extractor):
|
|||||||
filename_fmt = "{id}_p{num}.{extension}"
|
filename_fmt = "{id}_p{num}.{extension}"
|
||||||
archive_fmt = "{id}{suffix}.{extension}"
|
archive_fmt = "{id}{suffix}.{extension}"
|
||||||
cookies_domain = ".pixiv.net"
|
cookies_domain = ".pixiv.net"
|
||||||
sanity_url = "https://s.pximg.net/common/images/limit_sanity_level_360.png"
|
limit_url = "https://s.pximg.net/common/images/limit_"
|
||||||
mypixiv_url = "https://s.pximg.net/common/images/limit_mypixiv_360.png"
|
# https://s.pximg.net/common/images/limit_sanity_level_360.png
|
||||||
|
# https://s.pximg.net/common/images/limit_unviewable_360.png
|
||||||
|
# https://s.pximg.net/common/images/limit_mypixiv_360.png
|
||||||
|
|
||||||
def _init(self):
|
def _init(self):
|
||||||
self.api = PixivAppAPI(self)
|
self.api = PixivAppAPI(self)
|
||||||
@@ -117,16 +119,30 @@ class PixivExtractor(Extractor):
|
|||||||
]
|
]
|
||||||
|
|
||||||
url = meta_single_page["original_image_url"]
|
url = meta_single_page["original_image_url"]
|
||||||
if url == self.sanity_url:
|
if url.startswith(self.limit_url):
|
||||||
work["_ajax"] = True
|
work_id = work["id"]
|
||||||
self.log.warning("%s: 'limit_sanity_level' warning", work["id"])
|
self.log.debug("%s: %s", work_id, url)
|
||||||
if self.sanity_workaround:
|
|
||||||
body = self._request_ajax("/illust/" + str(work["id"]))
|
|
||||||
return self._extract_ajax(work, body)
|
|
||||||
|
|
||||||
elif url == self.mypixiv_url:
|
limit_type = url.rpartition("/")[2]
|
||||||
work["_mypixiv"] = True
|
if limit_type in (
|
||||||
self.log.warning("%s: 'My pixiv' locked", work["id"])
|
"limit_", # for '_extend_sanity()' inserts
|
||||||
|
"limit_unviewable_360.png",
|
||||||
|
"limit_sanity_level_360.png",
|
||||||
|
):
|
||||||
|
work["_ajax"] = True
|
||||||
|
self.log.warning("%s: 'limit_sanity_level' warning", work_id)
|
||||||
|
if self.sanity_workaround:
|
||||||
|
body = self._request_ajax("/illust/" + str(work_id))
|
||||||
|
return self._extract_ajax(work, body)
|
||||||
|
|
||||||
|
elif limit_type == "limit_mypixiv_360.png":
|
||||||
|
work["_mypixiv"] = True
|
||||||
|
self.log.warning("%s: 'My pixiv' locked", work_id)
|
||||||
|
|
||||||
|
else:
|
||||||
|
work["_mypixiv"] = True # stop further processing
|
||||||
|
self.log.error("%s: Unknown 'limit' URL type: %s",
|
||||||
|
work_id, limit_type)
|
||||||
|
|
||||||
elif work["type"] != "ugoira":
|
elif work["type"] != "ugoira":
|
||||||
return ({"url": url, "_fallback": self._fallback_image(url)},)
|
return ({"url": url, "_fallback": self._fallback_image(url)},)
|
||||||
@@ -430,7 +446,7 @@ class PixivArtworksExtractor(PixivExtractor):
|
|||||||
elif ajax_id > work_id:
|
elif ajax_id > work_id:
|
||||||
index -= 1
|
index -= 1
|
||||||
self.log.debug("Inserting work %s", ajax_id)
|
self.log.debug("Inserting work %s", ajax_id)
|
||||||
yield self._make_work(ajax_id, self.sanity_url, user)
|
yield self._make_work(ajax_id, self.limit_url, user)
|
||||||
|
|
||||||
else: # ajax_id < work_id
|
else: # ajax_id < work_id
|
||||||
break
|
break
|
||||||
@@ -440,7 +456,7 @@ class PixivArtworksExtractor(PixivExtractor):
|
|||||||
while index >= 0:
|
while index >= 0:
|
||||||
ajax_id = ajax_ids[index]
|
ajax_id = ajax_ids[index]
|
||||||
self.log.debug("Inserting work %s", ajax_id)
|
self.log.debug("Inserting work %s", ajax_id)
|
||||||
yield self._make_work(ajax_id, self.sanity_url, user)
|
yield self._make_work(ajax_id, self.limit_url, user)
|
||||||
index -= 1
|
index -= 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user