-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrss.py
More file actions
executable file
·44 lines (37 loc) · 1.11 KB
/
Copy pathrss.py
File metadata and controls
executable file
·44 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/python3
"""rss feed with one item, with ID of file hash"""
from datetime import timezone, datetime
import os
import hashlib
from dotenv import load_dotenv
load_dotenv()
FILE = "polycule.yaml"
HOME_URL = os.environ["HOME_URL"]
ISO_DATE = "%Y-%m-%dT%H:%M:%S%z"
mod_date = os.path.getmtime(FILE)
mod_datetime = datetime.fromtimestamp(mod_date, tz=timezone.utc)
with open(FILE, "rb") as file:
contents = file.read()
md5hash = hashlib.md5(contents).hexdigest()
print("Content-type: application/xml")
print()
print(
f"""<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>polycule</title>
<link href='https://server.alifeee.net{HOME_URL}rss' rel='self' />
<updated>{mod_datetime.isoformat()}</updated>
<author>
<name>alifeee</name>
</author>
<id>https://server.alifeee.net{HOME_URL}</id>
<entry>
<title>polycule update!</title>
<link href='https://server.alifeee.net{HOME_URL}' />
<id>uuid:{md5hash}</id>
<updated>{mod_datetime.isoformat()}</updated>
<summary>updated!</summary>
</entry>
</feed>
"""
)