From 4fd22043264bf401d71a0a5ad0bcdb5af3782386 Mon Sep 17 00:00:00 2001 From: Jeffrey Serio Date: Mon, 3 Feb 2025 12:53:18 -0600 Subject: [PATCH] Fix for case of multiple attachments --- python/publish_mastodon_archive.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python/publish_mastodon_archive.py b/python/publish_mastodon_archive.py index 14238ff..7d745f3 100644 --- a/python/publish_mastodon_archive.py +++ b/python/publish_mastodon_archive.py @@ -23,7 +23,7 @@ def main(): published = item.get("object").get("published") content = item.get("object").get("content") attachment = ( - item.get("object").get("attachment")[0] + item.get("object").get("attachment") if len(item.get("object").get("attachment")) >= 1 else None ) @@ -34,11 +34,12 @@ def main(): print(unescape(content)) print("#+END_EXPORT") if attachment: - if attachment.get("name"): - print(f"#+CAPTION: {attachment.get('name')}") - print( - f"[[https://files.hyperreal.coffee/mastodon_20240216-20250131/{attachment.get('url')}]]" - ) + for item in attachment: + if item.get("name"): + print(f"#+CAPTION: {item.get('name')}") + print( + f"[[https://files.hyperreal.coffee/mastodon_20240216-20250131/{item.get('url')}]]" + ) print("-----") print()