ppf: set newly added sites to 0,0 (err/stale)

we use the tuple 0,0 later on to detect whether a site is new or not.
This commit is contained in:
rofl0r
2019-01-11 05:23:01 +00:00
parent 8b10df9c1b
commit ecf587c8f7

6
ppf.py
View File

@@ -41,7 +41,7 @@ def import_from_file(fn, sqlite):
exists = [ i[0] for i in sqlite.execute('SELECT url FROM uris WHERE url=?',(u,)).fetchall() ]
if exists: continue
print('adding "%s"' % u)
sqlite.execute('INSERT INTO uris (added,url,check_time,error) VALUES (?,?,?,?)', (int(time.time()),u,0,1))
sqlite.execute('INSERT INTO uris (added,url,check_time,error,stale_count) VALUES (?,?,?,?,?)', (int(time.time()),u,0,0,0))
sqlite.commit()
def fetch_contents(url):
@@ -110,9 +110,9 @@ def insert_urls(urls, search, sqlite):
query = [ 'url=?' for u in urls ]
known = [ i[0] for i in sqlite.execute('SELECT url FROM uris WHERE %s' % ' OR '.join(query),urls).fetchall() ]
time_now = int(time.time())
new = [ (time_now,i,0,5) for i in urls if not i in known ]
new = [ (time_now,i,0,0,0) for i in urls if not i in known ]
if not len(new): return
sqlite.executemany('INSERT INTO uris (added,url,check_time,error) values(?,?,?,?)', new)
sqlite.executemany('INSERT INTO uris (added,url,check_time,error,stale_count) values(?,?,?,?,?)', new)
sqlite.commit()
_log('+%d item(s) from %s' % (len(new), search), 'added')