From 3b87337c71b6b5bfb02365190ad1276606ddae51 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Sun, 14 May 2017 09:21:47 +0300 Subject: [PATCH 1/5] RSS: Add elements & refactor description, size, seeders, leechers, downloads --- nyaa/templates/rss.xml | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index e1787d2..c6fdcdd 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -5,33 +5,31 @@ {{ url_for('home', _external=True) }} {% for torrent in torrent_query %} - {% if torrent.has_torrent %} {{ torrent.display_name }} + {{ torrent.description }} {% if use_elastic %} - {{ url_for('download_torrent', torrent_id=torrent.meta.id, _external=True) }} - {{ url_for('view_torrent', torrent_id=torrent.meta.id, _external=True) }} - {{ torrent.created_time|rfc822_es }} + {% if torrent.has_torrent %} + {{ url_for('download_torrent', torrent_id=torrent.meta.id, _external=True) }} + {% else %} + {{ create_magnet_from_info(torrent.display_name, torrent.info_hash) }} + {% endif %} + {{ url_for('view_torrent', torrent_id=torrent.meta.id, _external=True) }} + {{ torrent.created_time|rfc822_es }} {% else %} - {{ url_for('download_torrent', torrent_id=torrent.id, _external=True) }} - {{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }} - {{ torrent.created_time|rfc822 }} - {% endif %} - - {% else %} - - {{ torrent.display_name }} - {% if use_elastic %} - {{ create_magnet_from_info(torrent.display_name, torrent.info_hash) }} - {{ url_for('view_torrent', torrent_id=torrent.meta.id, _external=True) }} - {{ torrent.created_time|rfc822_es }} - {% else %} - {{ torrent.magnet_uri }} - {{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }} - {{ torrent.created_time|rfc822 }} + {% if torrent.has_torrent %} + {{ url_for('download_torrent', torrent_id=torrent.id, _external=True) }} + {% else %} + {{ torrent.magnet_uri }} + {% endif %} + {{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }} + {{ torrent.created_time|rfc822 }} {% endif %} + {{ torrent.filesize }} + {{ torrent.stats.seed_count }} + {{ torrent.stats.leech_count }} + {{ torrent.stats.download_count }} - {% endif %} {% endfor %} From d4621a23a7a10378ac7eac94947e3ba78e6b41fe Mon Sep 17 00:00:00 2001 From: sharkykh Date: Sun, 14 May 2017 09:23:30 +0300 Subject: [PATCH 2/5] Add bare torrent hash lambda is probably not the best way to go, suggestions for improvement are welcome! --- nyaa/routes.py | 1 + nyaa/templates/rss.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/nyaa/routes.py b/nyaa/routes.py index 48c8428..27d2dfb 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -303,6 +303,7 @@ 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 c6fdcdd..91da605 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -29,6 +29,7 @@ {{ torrent.stats.seed_count }} {{ torrent.stats.leech_count }} {{ torrent.stats.download_count }} + {{ compute_hash(torrent.info_hash) }} {% endfor %} From e2eb3fb33c4ea28807e1860bc40f9c17130547b0 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Sun, 14 May 2017 10:18:45 +0300 Subject: [PATCH 3/5] Category (main+sub) --- nyaa/templates/rss.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index 91da605..f962a0b 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -25,6 +25,7 @@ {{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }} {{ torrent.created_time|rfc822 }} {% endif %} + {{ torrent.main_category.name }} - {{ torrent.sub_category.name }} {{ torrent.filesize }} {{ torrent.stats.seed_count }} {{ torrent.stats.leech_count }} From 837ecde795186480975df20959a09a5345b4381f Mon Sep 17 00:00:00 2001 From: sharkykh Date: Sun, 14 May 2017 11:02:07 +0300 Subject: [PATCH 4/5] Wrap description in a CDATA tag --- nyaa/templates/rss.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index f962a0b..97eaba7 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -7,7 +7,7 @@ {% for torrent in torrent_query %} {{ torrent.display_name }} - {{ torrent.description }} + {% if use_elastic %} {% if torrent.has_torrent %} {{ url_for('download_torrent', torrent_id=torrent.meta.id, _external=True) }} From c691087730f52345cfdbf4c72b056625b70cb5a4 Mon Sep 17 00:00:00 2001 From: Kfir Hadas Date: Sun, 14 May 2017 18:57:57 +0300 Subject: [PATCH 5/5] Use formatted file size since that what was used by Nyaa. --- nyaa/templates/rss.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index 97eaba7..839e55a 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -26,7 +26,7 @@ {{ torrent.created_time|rfc822 }} {% endif %} {{ torrent.main_category.name }} - {{ torrent.sub_category.name }} - {{ torrent.filesize }} + {{ torrent.filesize | filesizeformat(True) }} {{ torrent.stats.seed_count }} {{ torrent.stats.leech_count }} {{ torrent.stats.download_count }}