prizebot: make it work for years besides 2024

mike/playlist-debug
Mike Lang 2 months ago
parent 15f4767f32
commit 6b7ae95c1f

@ -353,6 +353,7 @@
prizebot:: { prizebot:: {
email: "blog-bot@chat.videostrike.team", email: "blog-bot@chat.videostrike.team",
api_key: "", api_key: "",
year: "2024",
state: "/prizebot_state.json", state: "/prizebot_state.json",
// Path in host fs for the state file. // Path in host fs for the state file.
// Must exist and be initialized to "{}" // Must exist and be initialized to "{}"

@ -15,8 +15,8 @@ from .zulip import Client
Prize = namedtuple("Prize", ["id", "link", "type", "title", "state", "result"]) Prize = namedtuple("Prize", ["id", "link", "type", "title", "state", "result"])
def get_prizes(type): def get_prizes(year, type):
resp = requests.get(f"https://desertbus.org/2024/prizes/{type}", {"User-Agent": ""}) resp = requests.get(f"https://desertbus.org/{year}/prizes/{type}", {"User-Agent": ""})
resp.raise_for_status() resp.raise_for_status()
html = BeautifulSoup(resp.content.decode(), "html.parser") html = BeautifulSoup(resp.content.decode(), "html.parser")
@ -73,6 +73,7 @@ def main(config_file, test=False, all=False, once=False, interval=60):
""" """
Config: Config:
url, email, api_key: zulip creds url, email, api_key: zulip creds
year: the correct URL part for the prizes page: https://desertbus.org/YEAR/prizes/giveaway
state: path to state file state: path to state file
""" """
config = get_config(config_file) config = get_config(config_file)
@ -83,7 +84,7 @@ def main(config_file, test=False, all=False, once=False, interval=60):
while True: while True:
start = time.time() start = time.time()
for type in ('live', 'silent', 'giveaway'): for type in ('live', 'silent', 'giveaway'):
prizes = get_prizes(type) prizes = get_prizes(config['year'], type)
for prize in prizes: for prize in prizes:
logging.info(f"Got prize: {prize}") logging.info(f"Got prize: {prize}")
if prize.state == "sold" and (all or state.get(prize.id, "sold") != "sold"): if prize.state == "sold" and (all or state.get(prize.id, "sold") != "sold"):

Loading…
Cancel
Save