import datetime,os,requests from importlib import import_module def stringno(theno): if theno < 10: return "00" + str(theno) elif theno < 100: return "0" + str(theno) else: return str(theno) ficlist = [] ficcount = 999 while ficcount > 0: ficcount -= 1 ficcountstring = stringno(ficcount) if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate <= datetime.datetime.now(): goahead = True else: goahead = False except: goahead = True if goahead == True: ficdict = {} ficdict["id"] = stringno(ficcount) ficdict["date"] = fileread.datewords[-1]["date"] ficlist.append(ficdict) elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): ficfile = "files.translationsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate <= datetime.datetime.now(): goahead = True else: goahead = False except: goahead = True if goahead == True: ficdict = {} ficdict["id"] = stringno(ficcount) ficdict["date"] = fileread.datewords[-1]["date"] ficlist.append(ficdict) mentionlist = [] for fic in ficlist: timeelapsed = datetime.datetime.now() - fic["date"] if timeelapsed.days < 8: mentionlist.append(fic["id"]) headers = { "Content-Type": "application/x-www-form-urlencoded", } for fic in mentionlist: response = requests.post("https://fed.brid.gy/webmention",headers=headers,data="source=https://tre.praze.net/fic/" + str(fic) + "&target=https://fed.brid.gy/")