From 78320ef5b884732c6e0a1a0bcd2237703eb975fa Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 1 Apr 2020 00:42:43 +0200 Subject: ebknotify: add --wait --- ebknotify/cli.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ebknotify/cli.py b/ebknotify/cli.py index 7b9e612..bb8fb94 100644 --- a/ebknotify/cli.py +++ b/ebknotify/cli.py @@ -8,6 +8,7 @@ options: --cache=FILE Path to cache file [Default: ~/.config/ebk-notify/cache.json] --atom Write atom files --outdir=DIR Write atom files to folder [Default: ~/.config/ebk-notify] + --wait=SEC Wait for a random amount of seconds after a single query """ @@ -19,6 +20,9 @@ from .feed import Feed import json import logging from os.path import join +from random import randrange +from time import sleep + log = logging.getLogger('ebk-notify') def main(): @@ -56,6 +60,11 @@ def main(): ad = cache.update(ad,item) e = ad['notify'] print( f"{e['age_in_h']}h ago: \"{e['title-unescaped']}\" for {e['price']}€ -> {e['url']}") + if args['--wait']: + wait = randrange(1,int(args['--wait'])) + log.info(f"sleeping for {wait} seconds") + sleep(wait) + cache.save() if args['--atom']: f = Feed() -- cgit v1.2.3