diff options
author | makefu <github@syntax-fehler.de> | 2020-04-01 00:42:43 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2020-04-01 00:42:43 +0200 |
commit | 78320ef5b884732c6e0a1a0bcd2237703eb975fa (patch) | |
tree | 16131010f0762e7ec9d481cf3af4dc24c20c9c3d | |
parent | 6c54ff705e5c1133a46039cf654ac54cd4179955 (diff) |
ebknotify: add --wait
-rw-r--r-- | ebknotify/cli.py | 9 |
1 files changed, 9 insertions, 0 deletions
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() |