summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-02-21 20:30:52 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-02-21 20:30:52 +0100
commit1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86 (patch)
tree16bf83a61ce8dacd31a51fdbce9d8ef99cf97928
parentescaping html in filenames (diff)
downloadtravnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.tar
travnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.tar.gz
travnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.tar.bz2
travnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.tar.lz
travnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.tar.xz
travnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.tar.zst
travnik-1e21a8bc7d39547e8e5cb8f9bd7322d7a6c22d86.zip
-rw-r--r--templates/index.html10
-rw-r--r--travnik.py4
-rwxr-xr-xwww/app.py2
3 files changed, 14 insertions, 2 deletions
diff --git a/templates/index.html b/templates/index.html
index d83dfdf..2547750 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -31,7 +31,15 @@
</select>
<input type=submit value=išči />
{% if request.args.get("regex") %}
- <p>število zadetkov: {{ lentorrents }}</p>
+ {% if lentorrents < 100 %}
+ <p>
+ število zadetkov: {{ lentorrents }}
+ </p>
+ {% else %}
+ <p>
+ prikazujem le prvih sto zadetkov
+ </p>
+ {% endif %}
{% endif %}
{% for torrent in found_torrents %}
<h2><a href={{ torrent.magnet }}>{{ torrent.name | e }}</a></h2>
diff --git a/travnik.py b/travnik.py
index 98ef449..7aea6e4 100644
--- a/travnik.py
+++ b/travnik.py
@@ -79,6 +79,8 @@ class Torrent():
decoded = self.dict.get(b'info').get(b'name').decode()
except UnicodeDecodeError:
decoded = self.dict.get(b'info').get(b'name').decode("iso-8859-2")
+ except AttributeError:
+ decoded = str(self.dict.get(b'info').get(b'name'))
if search(r, decoded, IGNORECASE):
return True
for path, size in self.paths():
@@ -98,7 +100,7 @@ class Torrent():
except UnicodeDecodeError:
decoded = name.decode("iso-8859-2") # TODO we could try detecting the encoding
if search(r, decoded, IGNORECASE):
- files[decoded if decode else name] = content
+ files[decoded if decode else name] = content if type(content) is int else {}
if type(content) is dict:
inhalt = matching_files_r(content, r, decode)
if inhalt:
diff --git a/www/app.py b/www/app.py
index 1bb512a..de60c37 100755
--- a/www/app.py
+++ b/www/app.py
@@ -27,6 +27,8 @@ def index():
for hash, torrent in torrents.items():
if not request.args.get("regex"):
break
+ if len(result) >= 100:
+ break
if torrent.matches(request.args.get("regex")):
try:
decodedname = torrent.dict.get(b'info').get(b'name').decode()