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

pull/644/head
Mike Fährmann 5 years ago
parent a63a376ad2
commit a45fbc38ea
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -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
---------------------- ----------------------
=========== ===== =========== =====

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

@ -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

Loading…
Cancel
Save