Add details from database to details page
This commit is contained in:
parent
d5b04180a6
commit
d0e9457211
2 changed files with 55 additions and 4 deletions
29
indexer.py
29
indexer.py
|
@ -91,8 +91,9 @@ def search():
|
|||
@app.route("/details", methods=['GET'])
|
||||
def details():
|
||||
info_hash = request.args["h"]
|
||||
print(info_hash)
|
||||
return render_template("details.html", categories=get_categories())
|
||||
tf = TorrentFile(fileid=info_hash)
|
||||
tf.fromDb()
|
||||
return render_template("details.html", categories=get_categories(), torrent=tf)
|
||||
|
||||
def scrapeAll():
|
||||
TRACKER_URL = "http://tracker.lootbox.cf:6969/"
|
||||
|
@ -189,6 +190,7 @@ class TorrentFile():
|
|||
description = None
|
||||
audioquality_description = None
|
||||
videoquality_description = None
|
||||
|
||||
def __init__(self, fileid=fileid, name=name, category=category, subcategory=subcategory, description=description, audioquality_description=audioquality_description, videoquality_description=videoquality_description):
|
||||
self.fileid = fileid
|
||||
self.name = name
|
||||
|
@ -197,7 +199,8 @@ class TorrentFile():
|
|||
self.description = description
|
||||
self.audioquality_description = audioquality_description
|
||||
self.videoquality_description = videoquality_description
|
||||
self.metadata = Metadata(fileid)
|
||||
if self.fileid:
|
||||
self.metadata = Metadata(fileid)
|
||||
|
||||
def writeToDb(self, cursor):
|
||||
c = cursor
|
||||
|
@ -206,6 +209,26 @@ class TorrentFile():
|
|||
b64videoquality_description = base64.b64encode(self.videoquality_description.encode())
|
||||
c.execute("INSERT INTO torrents(fileid, name, category, subcategory, description, audioquality_description, videoquality_description) VALUES(:fileid, :name, :category, :subcategory, :description, :audioquality_description, :videoquality_description)", { 'fileid' : self.fileid, 'name' : self.name, 'category' : self.category, 'subcategory' : self.subcategory, 'description' : b64description , 'audioquality_description' : b64audioquality_description, 'videoquality_description' : b64videoquality_description})
|
||||
|
||||
def fromDb(self):
|
||||
def dict_factory(cursor, row):
|
||||
d = {}
|
||||
for idx, col in enumerate(cursor.description):
|
||||
d[col[0]] = row[idx]
|
||||
return d
|
||||
|
||||
con = sqlite3.connect("torrentdb.sqlite")
|
||||
con.row_factory = dict_factory
|
||||
c = con.cursor()
|
||||
res = c.execute("SELECT torrents.*, metadata.* FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE torrents.fileid LIKE :fileid", { "fileid" : self.fileid })
|
||||
res = res.fetchone()
|
||||
self.fileid = res["fileid"]
|
||||
self.name = (base64.b64decode(res["name"])).decode()
|
||||
self.category = res["category"]
|
||||
self.subcategory = res["subcategory"]
|
||||
self.description = (base64.b64decode(res["description"])).decode()
|
||||
self.audioquality_description = (base64.b64decode(res["audioquality_description"])).decode()
|
||||
self.videoquality_description = (base64.b64decode(res["videoquality_description"])).decode()
|
||||
|
||||
@babel.localeselector
|
||||
def get_locale():
|
||||
return request.accept_languages.best_match(LANGUAGES)
|
||||
|
|
|
@ -7,5 +7,33 @@ vim: ts=2 noexpandtab
|
|||
{% block content %}
|
||||
<link href="{{ url_for("static", filename="css/details.css") }}" rel="stylesheet">
|
||||
<script src="{{ url_for("static", filename="js/main.js") }}"></script>
|
||||
<h1>DETAILS</h1>
|
||||
<h3>DETAILS</h3>
|
||||
<div class="row">
|
||||
<span>Info ID:</span>
|
||||
<span>{{ torrent.fileid }}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>Name:</span>
|
||||
<span>{{ torrent.name }}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>Category:</span>
|
||||
<span>{{ torrent.category }}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>Subcategory:</span>
|
||||
<span>{{ torrent.subcategory }}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>Description:</span>
|
||||
<span>{{ torrent.description }}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>Audio quality:</span>
|
||||
<span>{{ torrent.audioquality_description }}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span>Video quality:</span>
|
||||
<span>{{ torrent.videoquality_description }}</span>
|
||||
</div>
|
||||
{% endblock content%}
|
||||
|
|
Loading…
Reference in a new issue