[pixiv] implement 'avatar' option (#595, #623)

This commit is contained in:
Mike Fährmann
2020-03-09 21:17:16 +01:00
parent a63a376ad2
commit a45fbc38ea
3 changed files with 39 additions and 0 deletions

View File

@@ -887,6 +887,15 @@ Description Download subalbums.
=========== ===== =========== =====
extractor.pixiv.user.avatar
---------------------------
=========== =====
Type ``bool``
Default ``false``
Description Download user avatars.
=========== =====
extractor.pixiv.ugoira extractor.pixiv.ugoira
---------------------- ----------------------
=========== ===== =========== =====

View File

@@ -97,6 +97,7 @@
{ {
"username": null, "username": null,
"password": null, "password": null,
"avatar"; false,
"ugoira": true "ugoira": true
}, },
"reactor": "reactor":

View File

@@ -12,6 +12,7 @@ from .common import Extractor, Message
from .. import text, exception from .. import text, exception
from ..cache import cache from ..cache import cache
from datetime import datetime, timedelta from datetime import datetime, timedelta
import itertools
import hashlib import hashlib
import time import time
@@ -101,6 +102,13 @@ class PixivUserExtractor(PixivExtractor):
"&tag=%E6%89%8B%E3%81%B6%E3%82%8D"), { "&tag=%E6%89%8B%E3%81%B6%E3%82%8D"), {
"url": "25b1cd81153a8ff82eec440dd9f20a4a22079658", "url": "25b1cd81153a8ff82eec440dd9f20a4a22079658",
}), }),
# avatar (#595, 623)
("https://www.pixiv.net/en/users/173530", {
"options": (("avatar", True),),
"content": "22af450d4dbaf4973d370f164f66f48c7382a6de",
"range": "1",
}),
# deleted account
("http://www.pixiv.net/member_illust.php?id=173531", { ("http://www.pixiv.net/member_illust.php?id=173531", {
"count": 0, "count": 0,
}), }),
@@ -135,6 +143,27 @@ class PixivUserExtractor(PixivExtractor):
if tag in [t["name"].lower() for t in work["tags"]] if tag in [t["name"].lower() for t in work["tags"]]
) )
if self.config("avatar"):
user = self.api.user_detail(self.user_id)
url = user["profile_image_urls"]["medium"].replace("_170.", ".")
avatar = {
"create_date" : None,
"height" : 0,
"id" : "avatar",
"image_urls" : None,
"meta_pages" : (),
"meta_single_page": {"original_image_url": url},
"page_count" : 1,
"sanity_level" : 0,
"tags" : (),
"title" : "avatar",
"type" : "avatar",
"user" : user,
"width" : 0,
"x_restrict" : 0,
}
works = itertools.chain((avatar,), works)
return works return works