master
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')
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')
while True:
item = cur.fetchone()
if item is None:
break
url = item[7]
cur2.execute('SELECT * FROM totaldl_urls WHERE url=?', [url])
if cur2.fetchone():
continue
title = item[6]
for character in '\\/?:*"><|.':
title = title.replace(character, '')
if len(title) > 35:
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:
handle_generic(url, customname=customname)
def test(imgur=True, gfycat=True, vimeo=True, liveleak=True, youtube=True, generic=True):
print('Testing')
if imgur:
# Imgur gallery album
handle_master('http://imgur.com/gallery/s4WLG')
def test_imgur():
# Imgur gallery album
handle_master('http://imgur.com/gallery/s4WLG')
# Imgur standard album with customname
handle_master('http://imgur.com/a/s4WLG', customname='album')
# Imgur standard album with customname
handle_master('http://imgur.com/a/s4WLG', customname='album')
# Imgur indirect
handle_master('http://imgur.com/gvJUct0')
# Imgur indirect
handle_master('http://imgur.com/gvJUct0')
# Imgur indirect single with customname
handle_master('http://imgur.com/gvJUct0', customname='indirect')
# Imgur indirect single with customname
handle_master('http://imgur.com/gvJUct0', customname='indirect')
# Imgur direct single
handle_master('http://i.imgur.com/gvJUct0.jpg')
# Imgur direct single
handle_master('http://i.imgur.com/gvJUct0.jpg')
if gfycat:
# Gfycat direct .gif
handle_master('http://giant.gfycat.com/FatherlyBruisedIberianchiffchaff.gif')
def test_gfycat():
# Gfycat direct .gif
handle_master('http://giant.gfycat.com/FatherlyBruisedIberianchiffchaff.gif')
# Gfycat general link
handle_master('http://www.gfycat.com/RawWetFlatcoatretriever')
# Gfycat general link
handle_master('http://www.gfycat.com/RawWetFlatcoatretriever')
# Gfycat general link with customname
handle_master('http://www.gfycat.com/RawWetFlatcoatretriever', customname='gfycatgeneral')
# Gfycat general link with customname
handle_master('http://www.gfycat.com/RawWetFlatcoatretriever', customname='gfycatgeneral')
if vimeo:
# Vimeo standard link
handle_master('https://vimeo.com/109405701')
def test_vimeo():
# Vimeo standard link
handle_master('https://vimeo.com/109405701')
# Vimeo player link with customname
handle_master('https://player.vimeo.com/video/109405701', customname='vimeoplayer')
# Vimeo player link with customname
handle_master('https://player.vimeo.com/video/109405701', customname='vimeoplayer')
if liveleak:
# LiveLeak standard link
handle_master('http://www.liveleak.com/view?i=9d1_1429192014')
def test_liveleak():
# LiveLeak standard link
handle_master('http://www.liveleak.com/view?i=9d1_1429192014')
# Liveleak article with youtube embed
handle_master('http://www.liveleak.com/view?i=ab8_1367941301')
# Liveleak article with youtube embed
handle_master('http://www.liveleak.com/view?i=ab8_1367941301')
# LiveLeak standard link with customname
handle_master('http://www.liveleak.com/view?i=9d1_1429192014', customname='liveleak')
# LiveLeak standard link with customname
handle_master('http://www.liveleak.com/view?i=9d1_1429192014', customname='liveleak')
if youtube:
# Youtube standard link
handle_master('https://www.youtube.com/watch?v=bEgeh5hA5ko')
def test_youtube():
# Youtube standard link
handle_master('https://www.youtube.com/watch?v=bEgeh5hA5ko')
# Youtube short link
handle_master('https://youtu.be/GjOBTstnW20')
# Youtube short link
handle_master('https://youtu.be/GjOBTstnW20')
# Youtube player embed link
handle_master('https://www.youtube.com/watch?feature=player_embedded&amp;v=bEgeh5hA5ko')
# Youtube player embed link
handle_master('https://www.youtube.com/watch?feature=player_embedded&amp;v=bEgeh5hA5ko')
if generic:
# Some link that might work
handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt')
def test_generic():
# Some link that might work
handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt')
# Some link that might work with customname
handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt', customname='sss')
# Some link that might work with customname
handle_master('https://raw.githubusercontent.com/voussoir/reddit/master/SubredditBirthdays/show/statistics.txt', customname='sss')
# Some link that might work
handle_master('https://github.com/voussoir/reddit/tree/master/SubredditBirthdays/show')
# Some link that might work
handle_master('https://github.com/voussoir/reddit/tree/master/SubredditBirthdays/show')
if __name__ == '__main__':
test(
imgur=False,
gfycat=False,
vimeo=False,
liveleak=False,
youtube=True,
generic=False)
#test_imgur()
#test_gfycat()
#test_vimeo()
#test_liveleak()
#test_youtube()
#test_generic()
pass