else/TotalDL/timesearch_dl.py

31 lines
741 B
Python
Raw Normal View History

2015-05-16 10:31:37 +00:00
import traceback
2015-05-15 06:02:21 +00:00
import sqlite3
import totaldl
sql = sqlite3.connect('!!testdata.db')
cur = sql.cursor()
2015-05-16 10:31:00 +00:00
cur2 = sql.cursor()
2015-05-15 06:02:21 +00:00
2015-05-16 10:31:00 +00:00
cur.execute('CREATE TABLE IF NOT EXISTS totaldl_urls(url TEXT)')
sql.commit()
2015-05-15 06:02:21 +00:00
cur.execute('SELECT * FROM posts WHERE self=0 AND url IS NOT NULL')
while True:
item = cur.fetchone()
if item is None:
break
2015-05-16 10:31:00 +00:00
url = item[7]
cur2.execute('SELECT * FROM totaldl_urls WHERE url=?', [url])
if cur2.fetchone():
continue
2015-05-15 21:46:32 +00:00
title = item[6]
for character in '\\/?:*"><|.':
title = title.replace(character, '')
if len(title) > 35:
title = title[:34] + '-'
2015-05-16 10:31:37 +00:00
try:
totaldl.handle_master(url, customname=title)
except:
traceback.print_exc()
2015-05-16 10:31:00 +00:00
cur2.execute('INSERT INTO totaldl_urls VALUES(?)', [url])
sql.commit()