This commit is contained in:
Voussoir 2015-05-16 03:31:00 -07:00
parent dd74f45b00
commit 054b91b1c6
3 changed files with 62 additions and 55 deletions

Binary file not shown.

View file

@ -3,16 +3,25 @@ import totaldl
sql = sqlite3.connect('!!testdata.db') sql = sqlite3.connect('!!testdata.db')
cur = sql.cursor() cur = sql.cursor()
cur2 = sql.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS totaldl_urls(url TEXT)')
sql.commit()
cur.execute('SELECT * FROM posts WHERE self=0 AND url IS NOT NULL') cur.execute('SELECT * FROM posts WHERE self=0 AND url IS NOT NULL')
while True: while True:
item = cur.fetchone() item = cur.fetchone()
if item is None: if item is None:
break break
url = item[7]
cur2.execute('SELECT * FROM totaldl_urls WHERE url=?', [url])
if cur2.fetchone():
continue
title = item[6] title = item[6]
for character in '\\/?:*"><|.': for character in '\\/?:*"><|.':
title = title.replace(character, '') title = title.replace(character, '')
if len(title) > 35: if len(title) > 35:
title = title[:34] + '-' title = title[:34] + '-'
url = item[7]
totaldl.handle_master(url, customname=title) totaldl.handle_master(url, customname=title)
cur2.execute('INSERT INTO totaldl_urls VALUES(?)', [url])
sql.commit()

View file

@ -274,9 +274,7 @@ def handle_master(url, customname=None):
if DO_GENERIC: if DO_GENERIC:
handle_generic(url, customname=customname) handle_generic(url, customname=customname)
def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, generic=True): def test_imgur():
print('Testing')
if imgur:
# Imgur gallery album # Imgur gallery album
handle_master('http://imgur.com/gallery/s4WLG') handle_master('http://imgur.com/gallery/s4WLG')
@ -292,7 +290,7 @@ def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, gener
# Imgur direct single # Imgur direct single
handle_master('http://i.imgur.com/gvJUct0.jpg') handle_master('http://i.imgur.com/gvJUct0.jpg')
if gfycat: def test_gfycat():
# Gfycat direct .gif # Gfycat direct .gif
handle_master('http://giant.gfycat.com/FatherlyBruisedIberianchiffchaff.gif') handle_master('http://giant.gfycat.com/FatherlyBruisedIberianchiffchaff.gif')
@ -302,14 +300,14 @@ def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, gener
# Gfycat general link with customname # Gfycat general link with customname
handle_master('http://www.gfycat.com/RawWetFlatcoatretriever', customname='gfycatgeneral') handle_master('http://www.gfycat.com/RawWetFlatcoatretriever', customname='gfycatgeneral')
if vimeo: def test_vimeo():
# Vimeo standard link # Vimeo standard link
handle_master('https://vimeo.com/109405701') handle_master('https://vimeo.com/109405701')
# Vimeo player link with customname # Vimeo player link with customname
handle_master('https://player.vimeo.com/video/109405701', customname='vimeoplayer') handle_master('https://player.vimeo.com/video/109405701', customname='vimeoplayer')
if liveleak: def test_liveleak():
# LiveLeak standard link # LiveLeak standard link
handle_master('http://www.liveleak.com/view?i=9d1_1429192014') handle_master('http://www.liveleak.com/view?i=9d1_1429192014')
@ -319,7 +317,7 @@ def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, gener
# LiveLeak standard link with customname # LiveLeak standard link with customname
handle_master('http://www.liveleak.com/view?i=9d1_1429192014', customname='liveleak') handle_master('http://www.liveleak.com/view?i=9d1_1429192014', customname='liveleak')
if youtube: def test_youtube():
# Youtube standard link # Youtube standard link
handle_master('https://www.youtube.com/watch?v=bEgeh5hA5ko') handle_master('https://www.youtube.com/watch?v=bEgeh5hA5ko')
@ -329,7 +327,7 @@ def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, gener
# Youtube player embed link # Youtube player embed link
handle_master('https://www.youtube.com/watch?feature=player_embedded&amp;v=bEgeh5hA5ko') handle_master('https://www.youtube.com/watch?feature=player_embedded&amp;v=bEgeh5hA5ko')
if generic: def test_generic():
# Some link that might work # Some link that might work
handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt') handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt')
@ -340,10 +338,10 @@ def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, gener
handle_master('https://github.com/voussoir/reddit/tree/master/SubredditBirthdays/show') handle_master('https://github.com/voussoir/reddit/tree/master/SubredditBirthdays/show')
if __name__ == '__main__': if __name__ == '__main__':
test( #test_imgur()
imgur=False, #test_gfycat()
gfycat=False, #test_vimeo()
vimeo=False, #test_liveleak()
liveleak=False, #test_youtube()
youtube=True, #test_generic()
generic=False) pass