123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import os
- import sqlite3
- vvvvidb = "vvvvidb.sqlite3"
- if not os.path.isfile(vvvvidb):
- print("{} file not found. Scrape the DB first using vvvvget.py".format(vvvvidb))
- exit(1)
- con = sqlite3.connect(vvvvidb)
- cur = con.cursor()
- out = open('index.html', 'w')
- out.write('''<!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Anime | lsd.cat</title>
- <link rel="icon" sizes="16x16" type="image/png" href="/icon.png" />
- <style type="text/css">body{margin:40px auto;max-width:740px;line-height:1.6;color:#444;padding:0 10px}h1,h2,h3{line-height:1.2;font-size:18px;}li{font-size:12px;}</style>
- </head>
- <body>
- <a href="''' + vvvvidb + '''">Source Database</a><br/><br/>''')
- # select all the series
- # cur.execute("SELECT * FROM series;")
- # selecy only series with at least one episodes
- cur.execute("SELECT s.* FROM series as s INNER JOIN episodes as e ON e.serie_id = s.id AND e.season_id = s.season_id GROUP BY s.id, s.season_id;")
- series = cur.fetchall()
- for s in series:
- serie = (str(s[0]), str(s[2]))
- out.write("\t<h3>{}: {} - Id Serie: {} - Tipo: {}</h3>\n\t<ul>\n".format(s[0], s[1], s[2], s[3]))
- cur.execute("SELECT e.cdn_url FROM episodes AS e JOIN series AS s ON e.serie_id = s.id AND e.season_id = s.season_id WHERE s.id = ? AND s.season_id = ?;", serie)
- episodes = cur.fetchall()
- [out.write("\t\t<li><a href=\"player.html#{0}\">{0}</a></li>\n".format(e[0])) for e in episodes]
- out.write('\t</ul>\n')
- out.write('\n</body>\n</html>')
- out.close()
- con.commit()
- con.close()
|