[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 self.remote = self._remote_direct
elif self.category == "archivedmoe": elif self.category == "archivedmoe":
self.referer = False self.referer = False
self.fixup_timestamp = True self.fixup_redirect = True
else: else:
self.fixup_timestamp = False self.fixup_redirect = False
def items(self): def items(self):
yield Message.Directory, self.metadata() yield Message.Directory, self.metadata()
@@ -65,32 +65,36 @@ class FoolfuukaExtractor(BaseExtractor):
# '.webm' -> '.web' (#5116) # '.webm' -> '.web' (#5116)
if url.endswith(".webm"): if url.endswith(".webm"):
url = url[:-1] 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("/") 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 = { board_domains = {
"3": "warosu.org", "3" : "warosu.org",
"biz": "warosu.org", "biz": "warosu.org",
"ck": "warosu.org", "ck" : "warosu.org",
"diy": "warosu.org", "diy": "warosu.org",
"fa": "warosu.org", "fa" : "warosu.org",
"ic": "warosu.org", "ic" : "warosu.org",
"jp": "warosu.org", "jp" : "warosu.org",
"lit": "warosu.org", "lit": "warosu.org",
"sci": "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] board = url.split("/", 4)[3]
if board in board_domains: if board in board_domains:
domain = board_domains[board] domain = board_domains[board]
url = f"https://{domain}/{board}/full_image/{filename}" 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(".") name, _, ext = filename.rpartition(".")
if len(name) > 13: if len(name) > 13:
url = "{}/{}.{}".format(path, name[:13], ext) url = f"{path}/{name[:13]}.{ext}"
return url return url