diff --git a/nyaa/models.py b/nyaa/models.py index 189c635..b7d9b6c 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -8,6 +8,7 @@ from werkzeug.security import generate_password_hash, check_password_hash from sqlalchemy_fulltext import FullText import re +import base64 from markupsafe import escape as escape_markup from urllib.parse import unquote as unquote_url @@ -121,6 +122,14 @@ class Torrent(db.Model): # Escaped return escape_markup(self.information) + @property + def info_hash_as_b32(self): + return base64.b32encode(self.info_hash).decode('utf-8') + + @property + def info_hash_as_hex(self): + return self.info_hash.hex() + @property def magnet_uri(self): return create_magnet(self) diff --git a/nyaa/routes.py b/nyaa/routes.py index cfae637..fe4ccff 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -367,7 +367,6 @@ def render_rss(label, query, use_elastic): use_elastic=use_elastic, term=label, site_url=flask.request.url_root, - compute_hash=lambda x: base64.b32encode(x).decode('utf-8'), torrent_query=query) response = flask.make_response(rss_xml) response.headers['Content-Type'] = 'application/xml' diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index 839e55a..53fc8e8 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -1,13 +1,13 @@ - {{ config.SITE_NAME }} Torrent File RSS (No magnets) + {{ config.SITE_NAME }} Torrent File RSS RSS Feed for {{ term }} {{ url_for('home', _external=True) }} {% for torrent in torrent_query %} {{ torrent.display_name }} - + {# #} {% if use_elastic %} {% if torrent.has_torrent %} {{ url_for('download_torrent', torrent_id=torrent.meta.id, _external=True) }} @@ -16,6 +16,11 @@ {% endif %} {{ url_for('view_torrent', torrent_id=torrent.meta.id, _external=True) }} {{ torrent.created_time|rfc822_es }} + + {{- torrent.seed_count }} + {{- torrent.leech_count }} + {{- torrent.download_count }} + {{- torrent.info_hash }} {% else %} {% if torrent.has_torrent %} {{ url_for('download_torrent', torrent_id=torrent.id, _external=True) }} @@ -24,13 +29,16 @@ {% endif %} {{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }} {{ torrent.created_time|rfc822 }} + + {{- torrent.stats.seed_count }} + {{- torrent.stats.leech_count }} + {{- torrent.stats.download_count }} + {{- torrent.info_hash_as_hex }} {% endif %} - {{ torrent.main_category.name }} - {{ torrent.sub_category.name }} - {{ torrent.filesize | filesizeformat(True) }} - {{ torrent.stats.seed_count }} - {{ torrent.stats.leech_count }} - {{ torrent.stats.download_count }} - {{ compute_hash(torrent.info_hash) }} + {% set cat_id = use_elastic and ((torrent.main_category_id|string) + '_' + (torrent.sub_category_id|string)) or torrent.sub_category.id_as_string %} + {{- cat_id }} + {{- category_name(cat_id) }} + {{- torrent.filesize | filesizeformat(True) }} {% endfor %}