[pixiv:novel] add 'covers' option (#5373)
This commit is contained in:
@@ -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 images embedded in novels.
|
||||
Download cover images.
|
||||
|
||||
|
||||
extractor.pixiv.novel.embeds
|
||||
----------------------------
|
||||
Type
|
||||
``bool``
|
||||
Default
|
||||
``false``
|
||||
Description
|
||||
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,
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user