diff --git a/indexer.py b/indexer.py index 5a02339..dd5d921 100644 --- a/indexer.py +++ b/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(): diff --git a/requirements.txt b/requirements.txt index c7688c7..065179c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ bencoder==0.2.0 requests==2.18.2 +hurry.filesize==0.9 + diff --git a/templates/result.html b/templates/result.html index a70fd06..4d8b4bc 100644 --- a/templates/result.html +++ b/templates/result.html @@ -18,7 +18,7 @@ vim: ts=2 noexpandtab {% for result in results %}