Initial commit

This commit is contained in:
dtb
2025-09-11 21:27:18 -06:00
commit ed900f1e4a
14 changed files with 1201 additions and 0 deletions

26
examples/ytfeed.aggregate Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# 2025 dtb. public domain
import re, sys, xml.etree.ElementTree as ET
ET.register_namespace("", "http://www.w3.org/2005/Atom")
ET.register_namespace("media", "http://search.yahoo.com/mrss/")
ET.register_namespace("yt", "http://www.youtube.com/xml/schemas/2015")
def sortby(entry):
return entry.findall("{http://www.w3.org/2005/Atom}published")[0].text
macrofeed = ET.Element('feed')
macrofeed.extend(
sorted([
entry
# Split the input by file.
for feed in re.split(r'<\?xml.*?\?>', sys.stdin.read())[1:]
# Get the entries out of each file.
for entry
in ET.fromstring(feed)
.findall("{http://www.w3.org/2005/Atom}entry")
],
# Gets the publication date and sorts the entries from old to new.
key = lambda entry
: entry.findall("{http://www.w3.org/2005/Atom}published")[0].text,
reverse = False # toggle this to switch the order
)
)
print(ET.tostring(macrofeed, encoding="unicode"))