admin-scripts/.archived/mastodon.py

37 lines
894 B
Python
Raw Normal View History

2024-11-09 00:18:47 +01:00
#!/usr/bin/env python3
import pandas as pd
from pandas import json_normalize
import json
from html import unescape
with open("/home/jas/downloads/outbox.json", "r") as jf:
json_data = json.load(jf)
flattened_df = json_normalize(json_data, record_path=["orderedItems"])
published = []
for item in flattened_df["object.published"]:
published.append(item)
content = []
for item in flattened_df["object.content"]:
content.append(item)
x = zip(published, content)
print("#+TITLE: Mastodon posts, 2024-02-16T15:48:46Z - 2024-10-11T20:15:03Z")
print("#+SETUPFILE: ../org-templates/page.org")
print()
for item in x:
if type(item[0]) is str:
print(f"*** {item[0]}")
if type(item[1]) is str:
print("#+BEGIN_QUOTE")
print("#+BEGIN_EXPORT html")
print(unescape(item[1]))
print("#+END_EXPORT")
print("#+END_QUOTE")
print()