add tdp script for tilde.json
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Ben Harris 2021-01-07 10:59:52 -05:00
parent 74a172f516
commit 42fd9c3072
2 changed files with 40 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
tilde.24h*
tilde.json

39
gen_tdp Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env python3
import glob, subprocess, json, os.path, requests
from bs4 import BeautifulSoup as bs
tdp = {}
tdp["name"] = "tilde.club"
tdp["url"] = "https://tilde.club"
tdp["signup_url"] = tdp["url"] + "/signup/"
users = sorted([u[len("/home/"):] for u in glob.glob("/home/*", recursive=False)])
tdp["user_count"] = len(users)
tdp["want_users"] = True
tdp["admin_email"] = "root@tilde.club"
tdp["description"] = "the original 'tilde': tilde.club is not a social network it is one tiny totally standard unix computer that people respectfully use together in their shared quest to build awesome web pages"
tdpusers = []
for user in users:
tdpuser = dict(username=user)
try:
title = bs(
requests.get(f"http://tilde.club/~{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.php"):
tdpuser["mtime"] = os.path.getmtime(f"/home/{user}/public_html/index.php")
tdpusers.append(tdpuser)
tdp["users"] = tdpusers
with open("tilde.json", "w") as f:
json.dump(tdp, f)