[pixiv:novel] add 'covers' option (#5373)

pull/5479/head
Mike Fährmann 5 months ago
parent b57051719f
commit 35d4a706ae
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -2964,14 +2964,24 @@ Description
`gppt <https://github.com/eggplants/get-pixivpy-token>`__.
extractor.pixiv.embeds
----------------------
extractor.pixiv.novel.covers
----------------------------
Type
``bool``
Default
``false``
Description
Download cover images.
extractor.pixiv.novel.embeds
----------------------------
Type
``bool``
Default
``false``
Description
Download images embedded in novels.
Download embedded images.
extractor.pixiv.novel.full-series

@ -619,6 +619,7 @@ class PixivNovelExtractor(PixivExtractor):
meta_user = self.config("metadata")
meta_bookmark = self.config("metadata-bookmark")
embeds = self.config("embeds")
covers = self.config("covers")
if embeds:
headers = {
@ -658,6 +659,19 @@ class PixivNovelExtractor(PixivExtractor):
novel["extension"] = "txt"
yield Message.Url, "text:" + content, novel
if covers:
path = novel["image_urls"]["large"].partition("/img/")[2]
url = ("https://i.pximg.net/novel-cover-original/img/" +
path.rpartition(".")[0].replace("_master1200", ""))
novel["date_url"] = self._date_from_url(url)
novel["num"] += 1
novel["suffix"] = "_p{:02}".format(novel["num"])
novel["_fallback"] = (url + ".png",)
url_jpg = url + ".jpg"
text.nameext_from_url(url_jpg, novel)
yield Message.Url, url_jpg, novel
del novel["_fallback"]
if embeds:
desktop = False
illusts = {}

@ -459,11 +459,14 @@ __tests__ = (
{
"#url" : "https://www.pixiv.net/novel/show.php?id=16422450",
"#comment" : "embeds",
"#comment" : "embeds // covers (#5373)",
"#category": ("", "pixiv", "novel"),
"#class" : pixiv.PixivNovelExtractor,
"#options" : {"embeds": True},
"#count" : 3,
"#options" : {
"embeds": True,
"covers": True,
},
"#count" : 4,
},
{

Loading…
Cancel
Save