You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
1.4 KiB

import xml.etree.ElementTree as ET
from datetime import datetime, timedelta
root = ET.Element("opml", version="2.0")
head = ET.SubElement(root, "head")
ET.SubElement(head, "ownerEmail").text = "[email protected]"
body = ET.SubElement(root, "body")
# Day colors for each weekday
day_colors = ["red", "teal", "pink", "green", "yellow", "sky", "purple"]
# Adjust start date to ensure weeks start on Sunday
start_date = datetime(2025, 1, 5)
for week_number in range(1, 53):
week_outline = ET.SubElement(body, "outline", text=f"2025 Week {week_number}")
ET.SubElement(week_outline, "outline", text="") # Empty bullet before the first day
for day in range(7):
current_date = start_date + timedelta(days=(week_number-1)*7 + day)
day_name = current_date.strftime('%A')
color = day_colors[current_date.weekday()]
day_text = f"<b><span class=\"colored bc-{color}\">{day_name}</span></b>"
note_text = (f"<time startYear=\"2025\" startMonth=\"{current_date.month}\" "
f"startDay=\"{current_date.day}\">"
f"{current_date.strftime('%a, %b %d, %Y')}</time>")
day_outline = ET.SubElement(week_outline, "outline", text=day_text, _note=note_text)
ET.SubElement(day_outline, "outline", text="")
# Output the XML as a string and print it
xml_str = ET.tostring(root, encoding="unicode")
print(xml_str)