import os from random import choice # from requests import get INDEX_HTML = "/home/naki/server/index.html" SERVER_PATH = "/home/naki/server/a/" LULS_PATH = "/home/naki/server/luls/" RANDOM_SIZE = 5 RANDOM_ALPHABET = ( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" ) def gen_random(size, alphabet) -> str: out = '' for _ in range(size): out += choice(alphabet) return out def main() -> None: images = next(os.walk(SERVER_PATH), (None, None, []))[2] # images = list(map(int, [image[3:-4] for image in images])) images = [image[:-4] for image in images] # out = max(images) + 1 if images else 0 name = '' while True: name = gen_random(RANDOM_SIZE, RANDOM_ALPHABET) if name not in images: break os.system(f"/home/naki/dwmscripts/scrotpy.sh '{SERVER_PATH + name + '.png'}'") # os.system( # f"flameshot gui --raw > {SERVER_PATH}img{out}.png" # ) # os.system( # f"flameshot gui --raw > {SERVER_PATH}{name}.png" # ) ip = "nakidai.ddns.net" # get('https://api.ipify.org').content.decode('utf8') os.system( f"echo \"http://{ip}/a/{name}.png\" |" f" xclip -selection clipboard -r" ) with open(INDEX_HTML, 'w') as f: f.write(f""" Nakidai Perumenei
Latest screenshot:
https://{ip}/a/{name}.png
Cool things:
{"
".join([f"https://{ip}/luls/{img}
" for img in os.listdir(LULS_PATH)])}
""") if __name__ == '__main__': main()