* [pixiv] fix novel embeds with AJAX request All novel embeds seem to be broken since `meta-preload-data` is no longer present in the html of the php response after a site change. * [pixiv] remove headers used for old novel embed request * [pixiv] cleanup novel embed fix * [pixiv] handle novel embed exceptions * [pixiv] fix PEP formatting for novel embeds fix * Fix error message * [pixiv] include exception info in novel error message --------- Co-authored-by: prowlguru <prowlguru@github.com> Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
This commit is contained in:
@@ -866,16 +866,6 @@ class PixivNovelExtractor(PixivExtractor):
|
||||
embeds = self.config("embeds")
|
||||
covers = self.config("covers")
|
||||
|
||||
if embeds:
|
||||
headers = {
|
||||
"User-Agent" : "Mozilla/5.0",
|
||||
"App-OS" : None,
|
||||
"App-OS-Version": None,
|
||||
"App-Version" : None,
|
||||
"Referer" : self.root + "/",
|
||||
"Authorization" : None,
|
||||
}
|
||||
|
||||
novels = self.novels()
|
||||
if self.max_posts:
|
||||
novels = itertools.islice(novels, self.max_posts)
|
||||
@@ -935,15 +925,12 @@ class PixivNovelExtractor(PixivExtractor):
|
||||
|
||||
if desktop:
|
||||
try:
|
||||
novel_id = str(novel["id"])
|
||||
url = "{}/novel/show.php?id={}".format(
|
||||
self.root, novel_id)
|
||||
data = util.json_loads(text.extr(
|
||||
self.request(url, headers=headers).text,
|
||||
"id=\"meta-preload-data\" content='", "'"))
|
||||
images = (data["novel"][novel_id]
|
||||
["textEmbeddedImages"]).values()
|
||||
except Exception:
|
||||
body = self._request_ajax("/novel/" + str(novel["id"]))
|
||||
images = body["textEmbeddedImages"].values()
|
||||
except Exception as exc:
|
||||
self.log.warning(
|
||||
"%s: Failed to get embedded novel images (%s: %s)",
|
||||
novel["id"], exc.__class__.__name__, exc)
|
||||
images = ()
|
||||
|
||||
for image in images:
|
||||
|
||||
Reference in New Issue
Block a user