diff --git a/checker.py b/checker.py index ca5ad40..e6b41bc 100644 --- a/checker.py +++ b/checker.py @@ -4,7 +4,7 @@ import json import time import requests import random -#import schedule +import schedule from collections import defaultdict previous = defaultdict(int) @@ -38,8 +38,9 @@ def check(item): def notify(data, url=NTFY_CHANNEL): - requests.post(url, - data=data.encode(encoding='utf-8')) + print(f"Sending {data} to {url}") + requests.post(url, + data=data.encode(encoding='utf-8')) def check_watchlist(): @@ -48,12 +49,17 @@ def check_watchlist(): item = client.get_item(id) total += check(item) time.sleep(random.randint(2, 10)) + +def notify_all(): + total = sum(previous.values()) notify(f"List checked. Total available: {total}", url=NTFY_CHANNEL_DEBUG) -#schedule.every(1).minutes.do(check_watchlist) +schedule.every(1).minutes.do(check_watchlist) +schedule.every(60).minutes.do(notify_all) + while True: - #schedule.run_pending() - check_watchlist() + schedule.run_pending() + #check_watchlist() time.sleep(30)