format DL size in a human-readible way
This commit is contained in:
parent
a67182df2c
commit
28208f1ba6
10
indexer.py
10
indexer.py
@ -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"])
|
||||
|
||||
def scrapeAll():
|
||||
|
@ -1,2 +1,4 @@
|
||||
bencoder==0.2.0
|
||||
requests==2.18.2
|
||||
hurry.filesize==0.9
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user