[deviantart:avatar] ignore default avatars (#5276)
This commit is contained in:
@@ -18,12 +18,12 @@ import binascii
|
||||
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):
|
||||
@@ -177,6 +177,10 @@ class DeviantartExtractor(Extractor):
|
||||
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)
|
||||
@@ -585,6 +589,10 @@ class DeviantartAvatarExtractor(DeviantartExtractor):
|
||||
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"
|
||||
|
||||
@@ -252,6 +252,14 @@ __tests__ = (
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
"#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"),
|
||||
|
||||
Reference in New Issue
Block a user