Skip to content

Commit

Permalink
[pixiv] implement 'avatar' option (#595, #623)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Mar 9, 2020
1 parent a63a376 commit a45fbc3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,15 @@ Description Download subalbums.
=========== =====


extractor.pixiv.user.avatar
---------------------------
=========== =====
Type ``bool``
Default ``false``
Description Download user avatars.
=========== =====


extractor.pixiv.ugoira
----------------------
=========== =====
Expand Down
1 change: 1 addition & 0 deletions docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
{
"username": null,
"password": null,
"avatar"; false,
"ugoira": true
},
"reactor":
Expand Down
29 changes: 29 additions & 0 deletions gallery_dl/extractor/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .. import text, exception
from ..cache import cache
from datetime import datetime, timedelta
import itertools
import hashlib
import time

Expand Down Expand Up @@ -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,
}),
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit a45fbc3

Please sign in to comment.