/ mastodon.py
mastodon.py
1 #!/usr/bin/env python3 2 3 import pandas as pd 4 from pandas import json_normalize 5 import json 6 from html import unescape 7 8 with open("/home/jas/downloads/outbox.json", "r") as jf: 9 json_data = json.load(jf) 10 11 flattened_df = json_normalize(json_data, record_path=["orderedItems"]) 12 13 published = [] 14 for item in flattened_df["object.published"]: 15 published.append(item) 16 17 content = [] 18 for item in flattened_df["object.content"]: 19 content.append(item) 20 21 x = zip(published, content) 22 23 print("#+TITLE: Mastodon posts, 2024-02-16T15:48:46Z - 2024-10-11T20:15:03Z") 24 print("#+SETUPFILE: ../org-templates/page.org") 25 print() 26 for item in x: 27 if type(item[0]) is str: 28 print(f"*** {item[0]}") 29 30 if type(item[1]) is str: 31 print("#+BEGIN_QUOTE") 32 print("#+BEGIN_EXPORT html") 33 print(unescape(item[1])) 34 print("#+END_EXPORT") 35 print("#+END_QUOTE") 36 print()