Skip to content

Commit

Permalink
[deviantart:avatar] ignore default avatars (#5276)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Mar 4, 2024
1 parent 0cbc910 commit a767832
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gallery_dl/extractor/deviantart.py
Expand Up @@ -18,12 +18,12 @@
import time
import re


BASE_PATTERN = (
r"(?:https?://)?(?:"
r"(?:www\.)?(?:fx)?deviantart\.com/(?!watch/)([\w-]+)|"
r"(?!www\.)([\w-]+)\.(?:fx)?deviantart\.com)"
)
DEFAULT_AVATAR = "https://a.deviantart.net/avatars/default.gif"


class DeviantartExtractor(Extractor):
Expand Down Expand Up @@ -177,6 +177,10 @@ def items(self):
for comment in deviation["comments"]:
user = comment["user"]
name = user["username"].lower()
if user["usericon"] == DEFAULT_AVATAR:
self.log.debug(
"Skipping avatar of '%s' (default)", name)
continue
_user_details.update(name, user)

url = "{}/{}/avatar/".format(self.root, name)
Expand Down Expand Up @@ -585,6 +589,10 @@ def deviations(self):
return ()

icon = user["usericon"]
if icon == DEFAULT_AVATAR:
self.log.debug("Skipping avatar of '%s' (default)", name)
return ()

_, sep, index = icon.rpartition("?")
if not sep:
index = "0"
Expand Down
8 changes: 8 additions & 0 deletions test/results/deviantart.py
Expand Up @@ -252,6 +252,14 @@
),
},

{
"#url" : "https://deviantart.com/h3813067/avatar",
"#comment" : "default avatar (#5276)",
"#category": ("", "deviantart", "avatar"),
"#class" : deviantart.DeviantartAvatarExtractor,
"#count" : 0,
},

{
"#url" : "https://deviantart.com/gdldev/banner",
"#category": ("", "deviantart", "background"),
Expand Down

0 comments on commit a767832

Please sign in to comment.