Merge remote-tracking branch 'struppi/master'

Add human readable file sizes
This commit is contained in:
sqozz 2017-12-29 03:24:05 +01:00
commit ea6b815c41
3 changed files with 11 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import bencoder
import requests
from flask import Flask, render_template, url_for, request, send_file, redirect
from werkzeug import secure_filename
from hurry.filesize import size
app = Flask(__name__)
strings = None
settings = None
@ -71,8 +72,13 @@ def search():
search += " AND ".join(["torrents.fileid LIKE (?)"] * len(query.split(" ")))
print(search)
c.execute("SELECT torrents.fileid, torrents.name, metadata.torrentsize FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE " + search, search_params)
results = c.fetchall()
#c.execute("SELECT torrents.fileid, torrents.name, metadata.torrentsize FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE " + search, search_params)
#results = c.fetchall()
results = list()
for row in c.execute("SELECT torrents.fileid, torrents.name, metadata.torrentsize FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE " + search, search_params):
r = row[0:2] + (size(float(row[2])) , ) + row[3:]
results.append(r)
return render_template("result.html", results=results, strings=strings, language="english", categories=settings["categories"])
@app.route("/details", methods=['GET'])

View File

@ -1,2 +1,4 @@
bencoder==0.2.0
requests==2.18.2
hurry.filesize==0.9

View File

@ -18,7 +18,7 @@ vim: ts=2 noexpandtab
{% for result in results %}
<tr>
<td><a href="/download/{{ result[0] }}">{{ result[1] }}</a></td>
<td>{{ result[2]|int / 1000 / 1000 }}</td>
<td>{{ result[2] }}</td>
<td>N/A</td>
<td>N/A</td>
<td>N/A</td>