[deviantart] implement '"group": "skip"' (#4630)

This commit is contained in:
Mike Fährmann
2023-10-12 22:07:11 +02:00
parent a9c3442d4e
commit 2d41702762
3 changed files with 34 additions and 10 deletions

View File

@@ -1306,13 +1306,21 @@ Description
extractor.deviantart.group extractor.deviantart.group
-------------------------- --------------------------
Type Type
``bool`` * ``bool``
* ``string``
Default Default
``true`` ``true``
Description Description
Check whether the profile name in a given URL Check whether the profile name in a given URL
belongs to a group or a regular user. belongs to a group or a regular user.
When disabled, assume every given profile name
belongs to a regular user.
Special values:
* ``"skip"``: Skip groups
extractor.deviantart.include extractor.deviantart.include
---------------------------- ----------------------------

View File

@@ -91,14 +91,20 @@ class DeviantartExtractor(Extractor):
return True return True
def items(self): def items(self):
if self.user and self.config("group", True): if self.user:
profile = self.api.user_profile(self.user) group = self.config("group", True)
self.group = not profile if group:
if self.group: profile = self.api.user_profile(self.user)
self.subcategory = "group-" + self.subcategory if profile:
self.user = self.user.lower() self.user = profile["user"]["username"]
else: self.group = False
self.user = profile["user"]["username"] elif group == "skip":
self.log.info("Skipping group '%s'", self.user)
raise exception.StopExtraction()
else:
self.subcategory = "group-" + self.subcategory
self.user = self.user.lower()
self.group = True
for deviation in self.deviations(): for deviation in self.deviations():
if isinstance(deviation, tuple): if isinstance(deviation, tuple):

View File

@@ -123,6 +123,16 @@ __tests__ = (
"#count" : ">= 15", "#count" : ">= 15",
}, },
{
"#url" : "https://www.deviantart.com/yakuzafc/gallery",
"#comment" : "'group': 'skip' (#4630)",
"#category" : ("", "deviantart", "gallery"),
"#class" : deviantart.DeviantartGalleryExtractor,
"#options" : {"group": "skip"},
"#exception": exception.StopExtraction,
"#count" : 0,
},
{ {
"#url" : "https://www.deviantart.com/justatest235723/gallery", "#url" : "https://www.deviantart.com/justatest235723/gallery",
"#comment" : "'folders' option (#276)", "#comment" : "'folders' option (#276)",
@@ -725,7 +735,7 @@ __tests__ = (
{ {
"#url" : "https://www.deviantart.com/chain-man/gallery/scraps", "#url" : "https://www.deviantart.com/chain-man/gallery/scraps",
"#comment" : "deactivated account" "#comment" : "deactivated account",
"#category": ("", "deviantart", "scraps"), "#category": ("", "deviantart", "scraps"),
"#class" : deviantart.DeviantartScrapsExtractor, "#class" : deviantart.DeviantartScrapsExtractor,
}, },