[archivedmoe] reword some comments and variable names

This commit is contained in:
Mike Fährmann
2025-06-15 09:54:40 +02:00
parent 6668acf91e
commit b245218c1d

View File

@@ -26,9 +26,9 @@ class FoolfuukaExtractor(BaseExtractor):
self.remote = self._remote_direct
elif self.category == "archivedmoe":
self.referer = False
self.fixup_timestamp = True
self.fixup_redirect = True
else:
self.fixup_timestamp = False
self.fixup_redirect = False
def items(self):
yield Message.Directory, self.metadata()
@@ -65,32 +65,36 @@ class FoolfuukaExtractor(BaseExtractor):
# '.webm' -> '.web' (#5116)
if url.endswith(".webm"):
url = url[:-1]
elif self.fixup_timestamp:
# trim filename/timestamp to 13 characters (#7652)
elif self.fixup_redirect:
# update redirect domain or filename (#7652)
path, _, filename = url.rpartition("/")
# if it's one of these boards, redirect to warosu or 4plebs
# these boards link directly to i.4cdn.org
# -> redirect to warosu or 4plebs instead
board_domains = {
"3": "warosu.org",
"3" : "warosu.org",
"biz": "warosu.org",
"ck": "warosu.org",
"ck" : "warosu.org",
"diy": "warosu.org",
"fa": "warosu.org",
"ic": "warosu.org",
"jp": "warosu.org",
"fa" : "warosu.org",
"ic" : "warosu.org",
"jp" : "warosu.org",
"lit": "warosu.org",
"sci": "warosu.org",
"tg": "archive.4plebs.org",
"tg" : "archive.4plebs.org",
}
# if it's one of these archives, slice the name
filename_slice_archives = {"b4k", "desuarchive", "palanq"}
board = url.split("/", 4)[3]
if board in board_domains:
domain = board_domains[board]
url = f"https://{domain}/{board}/full_image/{filename}"
elif any(archive in path for archive in filename_slice_archives):
# if it's one of these archives, slice the name
elif any(archive in path for archive in (
"b4k.", "desuarchive.", "palanq.")):
name, _, ext = filename.rpartition(".")
if len(name) > 13:
url = "{}/{}.{}".format(path, name[:13], ext)
url = f"{path}/{name[:13]}.{ext}"
return url