Rework webmention

This commit is contained in:
Fundor333
2025-01-21 04:15:49 +01:00
parent 7662db92d5
commit 7107784216
81 changed files with 161 additions and 1 deletions

View File

@@ -8,12 +8,13 @@ import hashlib
http_domain = "https://fundor333.com"
domain = "fundor333.com"
token = os.getenv("WEBMENTIONS_TOKEN")
since_days = 90000
since_days = 30
now = datetime.datetime.now()
since_data = now - datetime.timedelta(hours=24 * since_days)
url = f"https://webmention.io/api/mentions.jf2?domain={domain}&token={token}&since={since_data.isoformat()}&per-page=999"
all_hash = []
def clean_slug(slug: str):
@@ -31,6 +32,7 @@ for webmention in data["children"]:
with open("temp.json", "w") as fp:
label = clean_slug(webmention["wm-target"])
all_hash.append(label)
label += "/" + str(webmention["wm-id"])
if output.get(label, False):
@@ -53,3 +55,17 @@ for key in output.keys():
with open(path_file, "w") as fp:
json.dump(output[key], fp)
for folder in all_hash:
path_f = os.path.join("data", "webmentions", folder)
files = os.listdir(path_f)
out_dict = []
for e in files:
with open(os.path.join(path_f, e)) as file:
out_dict.append(json.load(file))
with open(os.path.join("data", "webmentions", folder + ".json"), "w") as fp:
json.dump(out_dict, fp)