diff --git a/.gitignore b/.gitignore index 54f4b39..d19c238 100755 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ tilde.24h.* node_modules/ mg.key /vendor/ +tilde.json diff --git a/gen_tdp b/gen_tdp new file mode 100755 index 0000000..eb68d47 --- /dev/null +++ b/gen_tdp @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import subprocess,json,os.path,requests +from bs4 import BeautifulSoup as bs + +tdp = {} +tdp["name"] = "tilde.team" +tdp["url"] = "https://tilde.team" +tdp["signup_url"] = tdp["url"]+"/signup" +users = subprocess.check_output(["/usr/bin/members","users"]).decode('ascii').split() +tdp["user_count"] = len(users) +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 = [] +for user in users: + tdpuser = dict(username=user) + title = bs(requests.get("https://tilde.team/~{}".format(user)).text,"lxml").title + if title is None: + title = "No title" + else: + title = title.text + tdpuser["title"] = title + if os.path.exists(os.path.expanduser("~{}/public_html/index.html".format(user))): + tdpuser["mtime"] = os.path.getmtime(os.path.expanduser("~{}/public_html/index.html".format(user))) + elif os.path.exists(os.path.expanduser("~{}/public_html/index.htm".format(user))): + tdpuser["mtime"] = os.path.getmtime(os.path.expanduser("~{}/public_html/index.htm".format(user))) + elif os.path.exists(os.path.expanduser("~{}/public_html/index.php".format(user))): + tdpuser["mtime"] = os.path.getmtime(os.path.expanduser("~{}/public_html/index.php".format(user))) + tdpusers.append(tdpuser) +tdp["users"] = tdpusers + +with open("tilde.json","w") as f: + json.dump(tdp,f)