diff --git a/docs/configuration.rst b/docs/configuration.rst index 1530d0bd22..af9425dc90 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -887,6 +887,15 @@ Description Download subalbums. =========== ===== +extractor.pixiv.user.avatar +--------------------------- +=========== ===== +Type ``bool`` +Default ``false`` +Description Download user avatars. +=========== ===== + + extractor.pixiv.ugoira ---------------------- =========== ===== diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 6796650e97..5d8abcf060 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -97,6 +97,7 @@ { "username": null, "password": null, + "avatar"; false, "ugoira": true }, "reactor": diff --git a/gallery_dl/extractor/pixiv.py b/gallery_dl/extractor/pixiv.py index 84e3fce87c..eaf97fd46c 100644 --- a/gallery_dl/extractor/pixiv.py +++ b/gallery_dl/extractor/pixiv.py @@ -12,6 +12,7 @@ from .. import text, exception from ..cache import cache from datetime import datetime, timedelta +import itertools import hashlib import time @@ -101,6 +102,13 @@ class PixivUserExtractor(PixivExtractor): "&tag=%E6%89%8B%E3%81%B6%E3%82%8D"), { "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", { "count": 0, }), @@ -135,6 +143,27 @@ def works(self): 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