From cc957ccc96ab9f7d1c26485064f8e40068623998 Mon Sep 17 00:00:00 2001 From: Simon Veit Engmann Date: Sat, 20 May 2017 01:13:04 +0200 Subject: [PATCH] Changed RSS feed to conform to RSS standards and added a namespace --- nyaa/routes.py | 4 ++++ nyaa/templates/rss.xml | 24 ++++++++++++------------ nyaa/templates/xmlns.html | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 nyaa/templates/xmlns.html diff --git a/nyaa/routes.py b/nyaa/routes.py index 4bb4e8f..27aa889 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -743,6 +743,10 @@ def site_rules(): def site_help(): return flask.render_template('help.html') +@app.routes('/xmlns/nyaa', methods=['GET']) +def xmlns_nyaa(): + return flask.render_template('xmlns.html') + # #################################### API ROUTES #################################### @app.route('/api/upload', methods=['POST']) diff --git a/nyaa/templates/rss.xml b/nyaa/templates/rss.xml index 7664da9..0cd5181 100644 --- a/nyaa/templates/rss.xml +++ b/nyaa/templates/rss.xml @@ -1,4 +1,4 @@ - + {{ config.SITE_NAME }} Torrent File RSS RSS Feed for {{ term }} @@ -17,10 +17,10 @@ {{ 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 }} + {{- torrent.seed_count }} + {{- torrent.leech_count }} + {{- torrent.download_count }} + {{- torrent.info_hash }} {% else %} {% if torrent.has_torrent and not magnet_links %} {{ url_for('download_torrent', torrent_id=torrent.id, _external=True) }} @@ -30,15 +30,15 @@ {{ 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 }} + {{- torrent.stats.seed_count }} + {{- torrent.stats.leech_count }} + {{- torrent.stats.download_count }} + {{- torrent.info_hash_as_hex }} {% endif %} {% 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) }} + {{- cat_id }} + {{- category_name(cat_id) }} + {{- torrent.filesize | filesizeformat(True) }} {% endfor %} diff --git a/nyaa/templates/xmlns.html b/nyaa/templates/xmlns.html new file mode 100644 index 0000000..9d3481e --- /dev/null +++ b/nyaa/templates/xmlns.html @@ -0,0 +1,32 @@ +{% extends "layout.html" %} +{% block title %}XML Namespace :: {{ config.SITE_NAME }}{% endblock %} +{% block body %} +
+

Nyaa XML Namespace

+

You found this page because our RSS feeds contain an URL that links here. Said URL is not an actual page but rather a unique identifier used to prevent name collisions with other XML namespaces.

+

The namespace contains the following additional, informational tags:

+
    +
  • +

    <nyaa:seeders> holds the current amount of seeders on the respective torrent.

    +
  • +
  • +

    <nyaa:leechers> holds the current amount of leechers on the respective torrent.

    +
  • +
  • +

    <nyaa:downloads> counts the downloads the torrent got up to the point the feed was refreshed.

    +
  • +
  • +

    <nyaa:infoHash> is the torrent's infohash, a unique identifier, in hexadecimal.

    +
  • +
  • +

    <nyaa:categoryId> contains the ID of the category containing the upload in the form category_subcategory.

    +
  • +
  • +

    <nyaa:category> contains the written name of the torrent's category in the form Category - Subcategory.

    +
  • +
  • +

    <nyaa:size> indicates the torrent's download size to one decimal place, using a magnitude prefix according to ISO/IEC 80000-13.

    +
  • +
+
+{% endblock %}