update webmention script
Deploy Website / build (push) Successful in 28s Details

This commit is contained in:
James Ravenscroft 2024-12-23 09:00:20 +00:00
parent a62436ca61
commit e66b5fc968
3 changed files with 20 additions and 20 deletions

View File

@ -1,4 +1,3 @@
import uuid
import os
import hashlib
from datetime import datetime
@ -105,27 +104,27 @@ def generate_card(input_file, workspace_path):
if os.path.exists(output_path):
print(f"{output_path} Already exists, using cached image")
return
else:
print(f"Generating card... {output_path}")
hti.temp_path = Path(workspace_path) / "tmp"
hti.temp_path = Path(workspace_path) / "tmp"
if not os.path.exists(hti.temp_path):
os.mkdir(hti.temp_path)
if not os.path.exists(hti.temp_path):
os.mkdir(hti.temp_path)
files = hti.screenshot(
html_str=[parsed_html], save_as=file_name, size=[(1128, 600)]
)
files = hti.screenshot(
html_str=[parsed_html], save_as=file_name, size=[(1128, 600)]
)
# move from tmp location to workspace folder
output_path = output_path.absolute().as_posix()
os.rename(files[0], output_path)
# move from tmp location to workspace folder
output_path = output_path.absolute().as_posix()
os.rename(files[0], output_path)
if "preview" in front_matter:
# strip '/social/' from the existing preview value
old_fin = front_matter["preview"][:8]
old_fill_path = Path(workspace_path) / "static" / "social" / old_fin
if os.path.exists(old_fill_path):
if os.path.exists(old_fill_path) and (old_fill_path != output_path):
print(f"Move {old_fill_path} into cleanup...")
os.rename(old_fill_path, old_fill_path + ".cleanup")

View File

@ -65,6 +65,7 @@ def update():
feed: feedparser.FeedParserDict = feedparser.parse(os.environ.get("RSS_URL"))
print(f"Checking for new entries on {os.environ.get('RSS_URL')} since {last_updated}")
for entry in feed["entries"]:
if datetime(*entry["published_parsed"][:6]) > last_updated:
links = check_for_links(entry["link"])

View File

@ -1,13 +1,13 @@
{
"last_updated": [
2024,
11,
16,
17,
15,
37,
5,
321,
12,
22,
12,
25,
46,
6,
357,
0
]
}