dr-w-site/gen_tdp

40 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2018-07-08 05:51:54 +00:00
#!/usr/bin/env python3
2020-07-17 21:10:00 +00:00
import subprocess, json, os.path, requests
2018-07-08 05:51:54 +00:00
from bs4 import BeautifulSoup as bs
tdp = {}
tdp["name"] = "tilde.team"
tdp["url"] = "https://tilde.team"
2020-07-17 21:10:00 +00:00
tdp["signup_url"] = tdp["url"] + "/signup/"
users = subprocess.check_output(["/usr/bin/members", "team"]).decode("ascii").split()
2018-11-24 08:51:25 +00:00
users.sort()
2020-07-17 21:10:00 +00:00
tdp["user_count"] = len(users)
2018-07-08 05:51:54 +00:00
tdp["want_users"] = True
tdp["admin_email"] = "sudoers@tilde.team"
tdp["description"] = "a digital community for socializing, learning, and making cool stuff, tilde.team is a shared system that provides a radically inclusive, non-commercial space for teaching, learning, practicing and enjoying the social medium of unix."
tdpusers = []
2020-07-17 21:10:00 +00:00
2018-07-08 05:51:54 +00:00
for user in users:
2020-07-17 21:10:00 +00:00
tdpuser = dict(username=user)
try:
title = bs(
requests.get(f"https://tilde.team/~{user}/", allow_redirects=False).text,
"lxml",
).title.text
except:
title = "No title"
tdpuser["title"] = title
if os.path.exists(f"/home/{user}/public_html/index.html"):
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.html")
elif os.path.exists(f"/home/{user}/public_html/index.cgi"):
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.cgi")
elif os.path.exists(f"/home/{user}/public_html/index.php"):
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.php")
tdpusers.append(tdpuser)
2018-07-08 05:51:54 +00:00
tdp["users"] = tdpusers
2020-07-17 21:10:00 +00:00
with open("tilde.json", "w") as f:
json.dump(tdp, f)