website/uptime-kuma-homepage.py
2023-09-02 14:25:00 +02:00

37 lines
2.1 KiB
Python
Executable file

#! /bin/python3
import json
from env import *
from uptime_kuma_api import UptimeKumaApi, MonitorType
descriptions = {
"Jellyfin":"Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.",
"Element Web":"A secure communications platform built around the Matrix protocol.",
"Uptime Kuma":"Uptime Kuma is an easy-to-use self-hosted monitoring tool.",
"Jellyseerr":"Jellyseerr is a free and open source software application for managing requests for your media library.",
"Pixelfed":"Pixelfed is a free and open-source image sharing social network service.",
"EteSync":"Secure, end-to-end encrypted, and privacy respecting sync for your contacts, calendars, tasks and notes.",
"Gitea":"Gitea is a lightweight DevOps platform. It brings teams and developers high-efficiency but easy operations from planning to production.",
"IPFS Gateway":"A peer-to-peer hypermedia protocol designed to preserve and grow humanity's knowledge.",
"Calibre Web":"Calibre-Web is a web app that offers a clean and intuitive interface for browsing, reading, and downloading eBooks."}
exclude=('Synapse','Mailserver')
HTMLTEMPLATE='<a class="item" href="{link}"><div id="{item}" class="item"><h2 class="item">{item}</h2><p class="desc">{desc}</p></div></a>'
htmllist=[]
htmllist.append(HTMLTEMPLATE.format(link=UPTIME_KUMA_URL,item="Uptime Kuma",desc=descriptions["Uptime Kuma"]))
with UptimeKumaApi(UPTIME_KUMA_URL) as api:
api.login(UPTIME_KUMA_ADMIN_USER,UPTIME_KUMA_ADMIN_PASSWORD)
for item in api.get_monitors():
if item["name"] in exclude or item["type"] == MonitorType.GROUP:
continue
print(item["name"])
# save every formatted entry in a list
try:
htmllist.append(HTMLTEMPLATE.format(link=item["url"],item=item["name"],desc=descriptions[item["name"]]))
except Exception:
htmllist.append(HTMLTEMPLATE.format(link=item["url"],item=item["name"],desc=""))
with open(UPTIME_KUMA_OUT,"w") as htmlfile:
htmlfile.write("\n".join(htmllist))