mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 20:10:00 +00:00
Finalize RSS ES fix
This commit is contained in:
parent
e7614bcef1
commit
daef4a9c6a
|
@ -8,6 +8,7 @@ from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
from sqlalchemy_fulltext import FullText
|
from sqlalchemy_fulltext import FullText
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import base64
|
||||||
from markupsafe import escape as escape_markup
|
from markupsafe import escape as escape_markup
|
||||||
from urllib.parse import unquote as unquote_url
|
from urllib.parse import unquote as unquote_url
|
||||||
|
|
||||||
|
@ -121,6 +122,14 @@ class Torrent(db.Model):
|
||||||
# Escaped
|
# Escaped
|
||||||
return escape_markup(self.information)
|
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
|
@property
|
||||||
def magnet_uri(self):
|
def magnet_uri(self):
|
||||||
return create_magnet(self)
|
return create_magnet(self)
|
||||||
|
|
|
@ -367,7 +367,6 @@ def render_rss(label, query, use_elastic):
|
||||||
use_elastic=use_elastic,
|
use_elastic=use_elastic,
|
||||||
term=label,
|
term=label,
|
||||||
site_url=flask.request.url_root,
|
site_url=flask.request.url_root,
|
||||||
compute_hash=lambda x: base64.b32encode(x).decode('utf-8'),
|
|
||||||
torrent_query=query)
|
torrent_query=query)
|
||||||
response = flask.make_response(rss_xml)
|
response = flask.make_response(rss_xml)
|
||||||
response.headers['Content-Type'] = 'application/xml'
|
response.headers['Content-Type'] = 'application/xml'
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<title>{{ config.SITE_NAME }} Torrent File RSS (No magnets)</title>
|
<title>{{ config.SITE_NAME }} Torrent File RSS</title>
|
||||||
<description>RSS Feed for {{ term }}</description>
|
<description>RSS Feed for {{ term }}</description>
|
||||||
<link>{{ url_for('home', _external=True) }}</link>
|
<link>{{ url_for('home', _external=True) }}</link>
|
||||||
<atom:link href="{{ url_for('home', page='rss', _external=True) }}" rel="self" type="application/rss+xml" />
|
<atom:link href="{{ url_for('home', page='rss', _external=True) }}" rel="self" type="application/rss+xml" />
|
||||||
{% for torrent in torrent_query %}
|
{% for torrent in torrent_query %}
|
||||||
<item>
|
<item>
|
||||||
<title>{{ torrent.display_name }}</title>
|
<title>{{ torrent.display_name }}</title>
|
||||||
<description><![CDATA[{{ torrent.description }}]]></description>
|
{# <description><![CDATA[{{ torrent.description }}]]></description> #}
|
||||||
{% if use_elastic %}
|
{% if use_elastic %}
|
||||||
{% if torrent.has_torrent %}
|
{% if torrent.has_torrent %}
|
||||||
<link>{{ url_for('download_torrent', torrent_id=torrent.meta.id, _external=True) }}</link>
|
<link>{{ url_for('download_torrent', torrent_id=torrent.meta.id, _external=True) }}</link>
|
||||||
|
@ -16,6 +16,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<guid isPermaLink="true">{{ url_for('view_torrent', torrent_id=torrent.meta.id, _external=True) }}</guid>
|
<guid isPermaLink="true">{{ url_for('view_torrent', torrent_id=torrent.meta.id, _external=True) }}</guid>
|
||||||
<pubDate>{{ torrent.created_time|rfc822_es }}</pubDate>
|
<pubDate>{{ torrent.created_time|rfc822_es }}</pubDate>
|
||||||
|
|
||||||
|
<seeders> {{- torrent.seed_count }}</seeders>
|
||||||
|
<leechers> {{- torrent.leech_count }}</leechers>
|
||||||
|
<downloads>{{- torrent.download_count }}</downloads>
|
||||||
|
<infoHash> {{- torrent.info_hash }}</infoHash>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if torrent.has_torrent %}
|
{% if torrent.has_torrent %}
|
||||||
<link>{{ url_for('download_torrent', torrent_id=torrent.id, _external=True) }}</link>
|
<link>{{ url_for('download_torrent', torrent_id=torrent.id, _external=True) }}</link>
|
||||||
|
@ -24,13 +29,16 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<guid isPermaLink="true">{{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }}</guid>
|
<guid isPermaLink="true">{{ url_for('view_torrent', torrent_id=torrent.id, _external=True) }}</guid>
|
||||||
<pubDate>{{ torrent.created_time|rfc822 }}</pubDate>
|
<pubDate>{{ torrent.created_time|rfc822 }}</pubDate>
|
||||||
|
|
||||||
|
<seeders> {{- torrent.stats.seed_count }}</seeders>
|
||||||
|
<leechers> {{- torrent.stats.leech_count }}</leechers>
|
||||||
|
<downloads>{{- torrent.stats.download_count }}</downloads>
|
||||||
|
<infoHash> {{- torrent.info_hash_as_hex }}</infoHash>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<category>{{ torrent.main_category.name }} - {{ torrent.sub_category.name }}</category>
|
{% set cat_id = use_elastic and ((torrent.main_category_id|string) + '_' + (torrent.sub_category_id|string)) or torrent.sub_category.id_as_string %}
|
||||||
<size>{{ torrent.filesize | filesizeformat(True) }}</size>
|
<categoryId>{{- cat_id }}</categoryId>
|
||||||
<seeders>{{ torrent.stats.seed_count }}</seeders>
|
<category> {{- category_name(cat_id) }}</category>
|
||||||
<leechers>{{ torrent.stats.leech_count }}</leechers>
|
<size> {{- torrent.filesize | filesizeformat(True) }}</size>
|
||||||
<downloads>{{ torrent.stats.download_count }}</downloads>
|
|
||||||
<infoHash>{{ compute_hash(torrent.info_hash) }}</infoHash>
|
|
||||||
</item>
|
</item>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</channel>
|
</channel>
|
||||||
|
|
Loading…
Reference in a new issue