diff --git a/python/mastodon.py b/python/mastodon.py deleted file mode 100755 index e3f2fb3..0000000 --- a/python/mastodon.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/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() diff --git a/python/publish_mastodon_archive.py b/python/publish_mastodon_archive.py new file mode 100644 index 0000000..6446b71 --- /dev/null +++ b/python/publish_mastodon_archive.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from pandas import json_normalize +import json +from html import unescape + + +def main(): + with open("/home/jas/downloads/outbox.json", "r") as jf: + json_data = json.load(jf) + + flattened_df = json_normalize(json_data, record_path=["orderedItems"]) + + for item in flattened_df.iterrows(): + print(f"*** {item[1]["object.published"]}") + if type(item[1]["object.content"]) is str: + print("#+BEGIN_QUOTE") + print("#+BEGIN_EXPORT html") + print(unescape(item[1]["object.content"])) + print("#+END_EXPORT") + if item[1]["object.attachment"]: + if type(item[1]["object.attachment"]) is list: + for i in item[1]["object.attachment"]: + + +if __name__ == "__main__": + main()