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,76 +274,74 @@ 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') # Imgur gallery album
if imgur: handle_master('http://imgur.com/gallery/s4WLG')
# Imgur gallery album
handle_master('http://imgur.com/gallery/s4WLG')
# Imgur standard album with customname # Imgur standard album with customname
handle_master('http://imgur.com/a/s4WLG', customname='album') handle_master('http://imgur.com/a/s4WLG', customname='album')
# Imgur indirect # Imgur indirect
handle_master('http://imgur.com/gvJUct0') handle_master('http://imgur.com/gvJUct0')
# Imgur indirect single with customname # Imgur indirect single with customname
handle_master('http://imgur.com/gvJUct0', customname='indirect') handle_master('http://imgur.com/gvJUct0', customname='indirect')
# 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')
# Gfycat general link # Gfycat general link
handle_master('http://www.gfycat.com/RawWetFlatcoatretriever') handle_master('http://www.gfycat.com/RawWetFlatcoatretriever')
# 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')
# Liveleak article with youtube embed # Liveleak article with youtube embed
handle_master('http://www.liveleak.com/view?i=ab8_1367941301') handle_master('http://www.liveleak.com/view?i=ab8_1367941301')
# 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')
# Youtube short link # Youtube short link
handle_master('https://youtu.be/GjOBTstnW20') handle_master('https://youtu.be/GjOBTstnW20')
# 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')
# Some link that might work with customname # Some link that might work with customname
handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt', customname='sss') handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt', customname='sss')
# Some link that might work # Some link that might work
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