Skip to content

Commit

Permalink
[kemonoparty] reject invalid/empty files (#3510)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 10, 2023
1 parent 4833ec3 commit 473bd38
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gallery_dl/extractor/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def items(self):
headers["Referer"] = "{}/{}/user/{}/post/{}".format(
self.root, post["service"], post["user"], post["id"])
post["_http_headers"] = headers
post["_http_validate"] = _validate
post["date"] = text.parse_datetime(
post["published"] or post["added"],
"%a, %d %b %Y %H:%M:%S %Z")
Expand Down Expand Up @@ -197,6 +198,11 @@ def _extract_dms(self, post):
return dms


def _validate(response):
return (response.headers["content-length"] != "9" and
response.content != b"not found")


class KemonopartyUserExtractor(KemonopartyExtractor):
"""Extractor for all posts from a kemono.party user listing"""
subcategory = "user"
Expand Down Expand Up @@ -309,6 +315,12 @@ class KemonopartyPostExtractor(KemonopartyExtractor):
"pattern": r"https://coomer\.party/data/7d/3f/7d3fd9804583dc224968"
r"c0591163ec91794552b04f00a6c2f42a15b68231d5a8\.jpg",
}),
# invalid file (#3510)
("https://kemono.party/patreon/user/19623797/post/29035449", {
"pattern": r"907ba78b4545338d3539683e63ecb51c"
r"f51c10adc9dabd86e92bd52339f298b9\.txt",
"content": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
}),
("https://kemono.party/subscribestar/user/alcorart/post/184330"),
("https://www.kemono.party/subscribestar/user/alcorart/post/184330"),
("https://beta.kemono.party/subscribestar/user/alcorart/post/184330"),
Expand Down

0 comments on commit 473bd38

Please sign in to comment.