[kemono] improve 'filename'

This commit is contained in:
Mike Fährmann
2025-10-15 13:13:46 +02:00
parent 36a3fe45e4
commit 3252ead7c7
2 changed files with 16 additions and 9 deletions

View File

@@ -150,13 +150,19 @@ class KemonoExtractor(Extractor):
url = self.root + "/data" + url[20:]
file["url"] = url
text.nameext_from_url(file.get("name", url), file)
ext = text.ext_from_url(url)
if not file["extension"]:
file["extension"] = ext
elif ext == "txt" and file["extension"] != "txt":
file["_http_validate"] = _validate
elif ext in exts_archive or \
if name := file.get("name"):
text.nameext_from_name(name, file)
ext = text.ext_from_url(url)
if not file["extension"]:
file["extension"] = ext
elif ext == "txt" and file["extension"] != "txt":
file["_http_validate"] = _validate
else:
text.nameext_from_url(url, file)
ext = file["extension"]
if ext in exts_archive or \
ext == "bin" and file["extension"] in exts_archive:
file["type"] = "archive"
if archives:

View File

@@ -137,7 +137,7 @@ __tests__ = (
"https://kemono.cr/data/b0/38/b03882c8b0ab3b1cf9fc658a2bb2f9ac6ad4f3449015311dcd2d7ee7f748db31.png",
),
"tags": r"re:\bpin-up\b",
"tags": list,
},
{
@@ -241,7 +241,7 @@ __tests__ = (
"#class" : kemono.KemonoPostExtractor,
"#options" : {"dms": True, "comments": True},
"comments": (),
"comments": [],
"dms": [
{
"added" : "2021-07-31T02:47:51.327865",
@@ -378,6 +378,7 @@ __tests__ = (
"revision_hash": {
"9872bfb536a47cc69d95d2f195cd5c825808f089",
"e0e93281495e151b11636c156e52bfe9234c2a40",
"eb2fa4385af730509a42f8f0424bd0b9a0e4bc21",
},
},