repeat every 30 seconds
This commit is contained in:
11
epgrab.py
11
epgrab.py
@@ -4,7 +4,9 @@ import logging
|
||||
import tinydb
|
||||
import json
|
||||
import pushover
|
||||
import time
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
pushover.init('abz8is31hd3m2e36g62w4msihj87cr')
|
||||
db = tinydb.TinyDB(os.getenv('DB_FILE',default='/data/grabbing.json'))
|
||||
@@ -17,9 +19,12 @@ def thash(inp: str):
|
||||
cfgs = db.table('cfgs')
|
||||
grabs = db.table('grabs')
|
||||
Entry = tinydb.Query()
|
||||
_logger.info('initialization done, start grabbing')
|
||||
while True:
|
||||
g = grab.Grab()
|
||||
for cfg in config['grab']:
|
||||
cfgid = thash(str(cfg))
|
||||
_logger.info('grabbing with config %s', cfgid)
|
||||
cfgentry = {'id': cfgid}
|
||||
cfgentry.update(cfg)
|
||||
if len(cfgs.search(Entry.id == cfgid)) == 0:
|
||||
@@ -49,7 +54,7 @@ for cfg in config['grab']:
|
||||
'info': info
|
||||
})
|
||||
pushover.Client("u5w9h8gc7hpzvr5a2kh2xh4m9zpidq").send_message(txt, title=txt[:50], url=url)
|
||||
|
||||
|
||||
|
||||
_logger.info('news found %s', info)
|
||||
_logger.info('sleeping')
|
||||
time.sleep(30)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user