Ignore this. Don't know if I'll finish/use it.
This commit is contained in:
parent
72f63fe8c9
commit
85b5f188aa
@ -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()
|
27
python/publish_mastodon_archive.py
Normal file
27
python/publish_mastodon_archive.py
Normal file
@ -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()
|
Loading…
x
Reference in New Issue
Block a user