The following script converts a json to md. The following 4 articles are made this way:
- 14.00 gameTheoryMatpatDump
- 14.01 filmTheoryMatpatDump
- 14.02 foodTheoryMatpatDump
- 14.03 styleTheoryMatpatDump
The json that you should input into this is 26.02 all youtubers videos script
# for every file in /input, load it as a json object
import json
import os
try:
os.listdir("input")
except FileNotFoundError:
os.chdir("jsonToMd")
if not os.path.exists("output"):
os.mkdir("output")
for file in os.listdir("input"):
finalText=""
number = 0
if file.endswith(".json"):
with open(f"input/{file}", "r", encoding="utf-8") as f:
data = json.load(f, strict=False)
data = data[::-1]
# print(data)
# for each key in the json object, create a new file in /output
for key in data:
number += 1
# print(key)
finalText+= f"- [ ] [{number}.{key['title']}]({key['link']})\n\n"
with open(f"output/{file.split('.')[0]}.md", "w", encoding="utf-8") as f:
f.write(finalText)