41 lines
1.3 KiB
Python
Executable file
41 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import email.utils
|
|
import glob
|
|
import json
|
|
import xml.etree.ElementTree as ET
|
|
|
|
# This is what we're aiming to generate:
|
|
#
|
|
# <?xml version="1.0" encoding="UTF-8"?>
|
|
# <opml version="1.0">
|
|
# <head>
|
|
# <title>RSS subscriptions for wes@wezm.net</title>
|
|
# <dateCreated>Sun, 05 May 2024 02:54:31 +0000</dateCreated>
|
|
# <ownerEmail>wes@wezm.net</ownerEmail>
|
|
# </head>
|
|
# <body>
|
|
# <outline text="3D Printing" title="3D Printing">
|
|
# <outline text="CadHub Blog" title="CadHub Blog" type="rss" xmlUrl="https://learn.cadhub.xyz/blog/rss.xml" htmlUrl="https://learn.cadhub.xyz/blog"/>
|
|
# </outline>
|
|
# </body>
|
|
# </opml>
|
|
|
|
opml = ET.Element("opml")
|
|
|
|
head = ET.SubElement(opml, "head")
|
|
title = ET.SubElement(head, "title")
|
|
title.text = "YouTube Subscription"
|
|
dateCreated = ET.SubElement(head, "dateCreated")
|
|
dateCreated.text = email.utils.formatdate(timeval=None, localtime=True)
|
|
|
|
body = ET.SubElement(opml, "body")
|
|
youtube = ET.SubElement(body, "outline", {"title": "YouTube", "text": "YouTube"})
|
|
|
|
for path in glob.glob("json/*.json"):
|
|
with open(path) as f:
|
|
info = json.load(f)
|
|
ET.SubElement(youtube, "outline", info, type="rss", text=info["title"])
|
|
|
|
ET.indent(opml)
|
|
print(ET.tostring(opml, encoding="unicode", xml_declaration=True))
|