scripts/genstatusconf

55 lines
1.3 KiB
Text
Raw Normal View History

#!/usr/bin/python
# Generate the status config based on the exozyme explore page
import re
import sys
deny = {
'Status', # Make sure we don't include the status page itself!!
'exolinux',
'Recursion',
'Unicode Visualizer',
'69!=',
'April Gools',
'Diagonal Scroll',
'flexozyme',
'Multiple Pendulum Animation',
'Dumb Physics Engine',
'Hex Color Clock',
'blank'
}
rules = {
'PixivFE': 'about',
'LiteXiv': 'main.css',
'Priviblur': 'priviblur/licences',
'Redlib': 'info',
}
sites = []
with open('/srv/http/www/explore.html') as f:
for l in f.readlines():
m = re.search('<td><a href="https://(.*)">(.*)</a></td>', l)
if m is not None and m.groups()[1] not in deny:
if m.groups()[1] in rules:
sites.append((f'{m.groups()[0]}/{rules[m.groups()[1]]}', m.groups()[1]))
else:
sites.append(m.groups())
newconf = []
with open(sys.argv[1]) as f:
for l in f.readlines():
if 'description = ' not in l:
newconf.append(l)
if l == 'service = [\n':
newconf += list(map(lambda m: f' {{ description = "{m[1]}", url = "https://{m[0]}" }},\n', sites))
with open(sys.argv[1], 'w') as f:
f.write(''.join(newconf))