Refactor comments handling and update syndication links across multiple posts
This commit is contained in:
@@ -9,7 +9,23 @@ CARTELLA_POST = "content"
|
||||
CSV_LOG = "log_feed.csv"
|
||||
MASTODON_FEED = "https://mastodon.social/users/fundor333.rss"
|
||||
BSKY_FEED = "https://bsky.app/profile/did:plc:u7piwonv4s27ysugjaa6im2q/rss" # facoltativo, se disponibile
|
||||
MEDIUM_FEED = "https://medium.com/feed/@fundor333"
|
||||
MEDIUM_FEED = None # "https://medium.com/feed/@fundor333"
|
||||
|
||||
|
||||
def parse_fediverse_url(url):
|
||||
# Mastodon / Akkoma / Pleroma
|
||||
match1 = re.match(r"https?://([^/]+)/@([^/]+)/(\d+)", url)
|
||||
if match1:
|
||||
host, username, post_id = match1.groups()
|
||||
return {"host": host, "username": username, "id": post_id}
|
||||
|
||||
# Misskey / Firefish
|
||||
match2 = re.match(r"https?://([^/]+)/notes/([a-zA-Z0-9]+)", url)
|
||||
if match2:
|
||||
host, post_id = match2.groups()
|
||||
return {"host": host, "username": None, "id": post_id}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def process_feed_medium(feed_url, fonte):
|
||||
@@ -83,7 +99,7 @@ def aggiungi_syndication_a_post(percorso_file, nuovi_link):
|
||||
content = f.read()
|
||||
|
||||
if content.startswith("+++"):
|
||||
raise NotImplementedError("Supporto TOML non ancora gestito.")
|
||||
raise NotImplementedError("Supporto TOML non gestito.")
|
||||
elif content.startswith("---"):
|
||||
parts = content.split("---")
|
||||
if len(parts) < 3:
|
||||
@@ -92,6 +108,8 @@ def aggiungi_syndication_a_post(percorso_file, nuovi_link):
|
||||
|
||||
frontmatter = yaml.safe_load(parts[1])
|
||||
esistenti = frontmatter.get("syndication", [])
|
||||
if isinstance(esistenti, str):
|
||||
esistenti = [esistenti]
|
||||
|
||||
esistenti_norm = set(map(normalizza_url, esistenti))
|
||||
nuovi_norm = set(map(normalizza_url, nuovi_link))
|
||||
@@ -99,7 +117,17 @@ def aggiungi_syndication_a_post(percorso_file, nuovi_link):
|
||||
da_aggiungere = list(nuovi_norm - esistenti_norm)
|
||||
|
||||
if da_aggiungere:
|
||||
# Aggiorna il campo syndication
|
||||
frontmatter["syndication"] = sorted(esistenti_norm.union(nuovi_norm))
|
||||
|
||||
# Se troviamo un link Mastodon, estrai info nei meta commenti
|
||||
for link in da_aggiungere:
|
||||
parsed = parse_fediverse_url(link)
|
||||
if parsed:
|
||||
frontmatter["comments"] = (
|
||||
parsed # Sostituisce se già esiste (puoi estendere a lista se vuoi)
|
||||
)
|
||||
|
||||
nuovo_frontmatter = yaml.dump(
|
||||
frontmatter, sort_keys=False, allow_unicode=True
|
||||
)
|
||||
|
||||
@@ -27,10 +27,5 @@ repost:
|
||||
like:
|
||||
rsvp:
|
||||
bookmark:
|
||||
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id:
|
||||
---
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: null
|
||||
id: '114587857806058272'
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lroqnpvein2o
|
||||
- https://mastodon.social/@fundor333/114587857806058272
|
||||
|
||||
@@ -15,7 +15,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: 114627452417111937
|
||||
id: '114627452417111937'
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lroqna6rpn2o
|
||||
- https://mastodon.social/@fundor333/114627452417111937
|
||||
|
||||
@@ -16,7 +16,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: 114689671753564243
|
||||
id: '114689671753564243'
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lroici3xqz22
|
||||
- https://mastodon.social/@fundor333/114689671753564243
|
||||
|
||||
@@ -12,7 +12,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: null
|
||||
id: '114615017065338141'
|
||||
syndication:
|
||||
- https://mastodon.social/@fundor333/114615017065338141
|
||||
---
|
||||
|
||||
@@ -15,7 +15,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: 114681429148697486
|
||||
id: '114681429148697486'
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lrkt66xamq2s
|
||||
- https://mastodon.social/@fundor333/114681429148697486
|
||||
|
||||
@@ -13,6 +13,7 @@ categories:
|
||||
- fingerfood
|
||||
description: If you have a static site you can also have forms
|
||||
syndication:
|
||||
- https://fundor333.medium.com/static-with-a-form-in-python-0a11c50a04cd?source=rss-48447ba4c2e
|
||||
- https://fundor333.medium.com/static-with-a-form-in-python-0a11c50a04cd?source=rss-48447ba4c2e------2
|
||||
---
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: 114689582471095983
|
||||
id: '114689582471095983'
|
||||
syndication:
|
||||
- https://mastodon.social/@fundor333/114689582471095983
|
||||
---
|
||||
|
||||
@@ -23,7 +23,7 @@ bookmark: null
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: 114690259109867675
|
||||
id: '114690259109867675'
|
||||
syndication:
|
||||
- https://mastodon.social/@fundor333/114690259109867675
|
||||
---
|
||||
|
||||
@@ -18,6 +18,7 @@ feature_text: by IA Midjourney
|
||||
series:
|
||||
- Tech News
|
||||
syndication:
|
||||
- https://fundor333.medium.com/this-is-why-instagram-ruin-itself-5e939a3bd4c6?source=rss-48447ba4c2e
|
||||
- https://fundor333.medium.com/this-is-why-instagram-ruin-itself-5e939a3bd4c6?source=rss-48447ba4c2e------2
|
||||
---
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ bookmark: https://mxb.dev/blog/webring-kit/
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: 114565534042467712
|
||||
id: '114565534042467712'
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lpxe75uzk52r
|
||||
- https://mastodon.social/@fundor333/114565534042467712
|
||||
|
||||
@@ -10,6 +10,10 @@ draft: false
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lroqnv2r652s
|
||||
- https://mastodon.social/@fundor333/114690259884567597
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: '114690259884567597'
|
||||
---
|
||||
|
||||
- Changing some metadata for better control of what brid.gy publish from my site
|
||||
|
||||
@@ -10,6 +10,10 @@ draft: false
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lroqnfmvut2y
|
||||
- https://mastodon.social/@fundor333/114690258752401420
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: '114690258752401420'
|
||||
---
|
||||
|
||||
- Making some videoediting for a friend
|
||||
|
||||
@@ -10,6 +10,10 @@ draft: false
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lr3n2pfd7f23
|
||||
- https://mastodon.social/@fundor333/114647222339157952
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: '114647222339157952'
|
||||
---
|
||||
|
||||
- And I went to vote for the Referendum
|
||||
|
||||
@@ -10,6 +10,10 @@ draft: false
|
||||
syndication:
|
||||
- https://bsky.app/profile/fundor333.bsky.social/post/3lroqmzb3zz2w
|
||||
- https://mastodon.social/@fundor333/114690257976586167
|
||||
comments:
|
||||
host: mastodon.social
|
||||
username: fundor333
|
||||
id: '114690257976586167'
|
||||
---
|
||||
|
||||
- Setup Umami for my personals' sites
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{ partial "webmention" . }}
|
||||
|
||||
{{ $params := .Params.comments }}
|
||||
{{ with .Params.comments.id}}
|
||||
{{ with .Params.comments}}
|
||||
{{ partial "mastodon" $params }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user