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:
6
ppf.py
6
ppf.py
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user