# dependencies: xmltodict # setup: echo -n "0" > lastnotif; put your discord webhook url in webhookurl import requests import xmltodict from time import sleep from datetime import datetime, timezone from collections import defaultdict # put the tags you wanna watch below WATCHED = [ { "language": {"speechless", "english"}, }, { "artist": { "acbins", "agagaga", "aimaitei umami", "airandou", "akiamare", "alp", "aomushi", "binto", "dakkoku jiro", "eigetu", "frogsnake", "gennsui", "hanpatsu zokusei", "itami", "jairou", "kakuninii", "kamata", "kamotama", "kataokasan", "katou jun", "kawakami kou", "koyama shigeru", "lbl", "lemon snail", "magifuro konnyaku", "mmchair", "momomo", "muneshiro", "nakani", "noname", "okuva", "poncocchan", "rabu", "sakai", "sella", "shakekare", "sumiyao", "tototo", "try", "wagashi", "yassy", "yoshiie", }, "group": {"aimaitei", "contamination", "gyuumagyuuma", "kemomimi eki", "otonano omochiya", "yuruyakatou"} } ] FJORDED = {"lolicon", "shotacon", "toddlercon", "abortion", "bestiality"} def main(): res = xmltodict.parse(requests.get("https://xml.e-hentai.org/ehg.xml").text, cdata_separator="\n") entries = res["feed"]["entry"] for e in entries: e["updated"] = datetime.fromisoformat(e["updated"]) with open("lastnotif", "r+") as f: lastnotif = datetime.fromtimestamp(int(f.read().strip()), tz=timezone.utc) f.seek(0) f.write(str(int(entries[0]["updated"].timestamp()))) f.truncate() with open("webhook", "r") as f: webhookurl = f.read().strip() for e in entries: if e["updated"] > lastnotif: content = e["content"]["div"]["p"][1]["#text"] tags_text, desc_text = content.split("\n", maxsplit=1) tags = defaultdict(set) for nstag in tags_text.removeprefix("Tags: ").split(", "): if ":" not in nstag: tags["temp"].add(nstag) else: ns, tag = nstag.split(":") tags[ns].add(tag) fail = False for condition in WATCHED: if not any(tags[ns] & required for ns, required in condition.items()): fail = True break if fail: continue tags_text = "\n".join(ns + ": " + " ".join(f"`{tag}`" for tag in sorted(t)) for ns, t in tags.items()) embed = { "title": e["title"][:256], "url": e["link"]["@href"], "description": tags_text[:4096], # desc_text.removeprefix("Description: ") + "\n\n" + "color": 0x000000, } fjorded = any(FJORDED & t for t in tags.values()) if not fjorded: # yeah let's *try* not getting banned from discord embed["thumbnail"] = {"url": e["content"]["div"]["img"]["@src"]} print(embed) print(requests.post(webhookurl, json={"embeds": [embed]})) sleep(1) if __name__ == "__main__": try: main() except Exception as e: print(e) with open("webhook", "r") as f: webhookurl = f.read().strip() requests.post(webhookurl, json={"content": f"{e.__class__.__name__}: {str(e)}"[:2000]})