[deviantart] add 'comments-avatars' option (#4995)
This commit is contained in:
@@ -1388,6 +1388,18 @@ Description
|
||||
Extract ``comments`` metadata.
|
||||
|
||||
|
||||
extractor.deviantart.comments-avatars
|
||||
-------------------------------------
|
||||
Type
|
||||
``bool``
|
||||
Default
|
||||
``false``
|
||||
Description
|
||||
Download the avatar of each commenting user.
|
||||
|
||||
Note: Enabling this option also enables deviantart.comments_.
|
||||
|
||||
|
||||
extractor.deviantart.extra
|
||||
--------------------------
|
||||
Type
|
||||
@@ -6009,6 +6021,7 @@ Description
|
||||
.. _base-directory: `extractor.*.base-directory`_
|
||||
.. _date-format: `extractor.*.date-format`_
|
||||
.. _deviantart.metadata: `extractor.deviantart.metadata`_
|
||||
.. _deviantart.comments: `extractor.deviantart.comments`_
|
||||
.. _postprocessors: `extractor.*.postprocessors`_
|
||||
.. _download archive: `extractor.*.archive`_
|
||||
|
||||
|
||||
@@ -47,8 +47,9 @@ class DeviantartExtractor(Extractor):
|
||||
self.extra = self.config("extra", False)
|
||||
self.quality = self.config("quality", "100")
|
||||
self.original = self.config("original", True)
|
||||
self.comments = self.config("comments", False)
|
||||
self.intermediary = self.config("intermediary", True)
|
||||
self.comments_avatars = self.config("comments-avatars", False)
|
||||
self.comments = self.comments_avatars or self.config("comments", False)
|
||||
|
||||
self.api = DeviantartOAuthAPI(self)
|
||||
self.group = False
|
||||
@@ -172,6 +173,13 @@ class DeviantartExtractor(Extractor):
|
||||
deviation["is_original"] = True
|
||||
yield self.commit_journal(deviation, journal)
|
||||
|
||||
if self.comments_avatars:
|
||||
for comment in deviation["comments"]:
|
||||
url = "{}/{}/avatar/".format(
|
||||
self.root, comment["user"]["username"])
|
||||
comment["_extractor"] = DeviantartAvatarExtractor
|
||||
yield Message.Queue, url, comment
|
||||
|
||||
if not self.extra:
|
||||
continue
|
||||
|
||||
|
||||
@@ -703,6 +703,20 @@ __tests__ = (
|
||||
"comments": "len:20",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.deviantart.com/justatest235723/art/Blue-811519058",
|
||||
"#comment" : "comment avatars (#4995)",
|
||||
"#category": ("", "deviantart", "deviation"),
|
||||
"#class" : deviantart.DeviantartDeviationExtractor,
|
||||
"#options" : {
|
||||
"original" : False,
|
||||
"comments-avatars": True,
|
||||
},
|
||||
"#range" : "5-",
|
||||
"#pattern" : r"^https://www\.deviantart\.com/justatest235723/avatar/$",
|
||||
"#count" : 16,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.deviantart.com/citizenfresh/art/Hverarond-789295466",
|
||||
"#comment" : "wixmp URL rewrite /intermediary/",
|
||||
|
||||
Reference in New Issue
Block a user