1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-10-31 23:05:54 +00:00

Resolves #129 and refactored create magnet es naming

This commit is contained in:
aldacron 2017-05-24 23:19:08 -07:00
parent 02c04ce893
commit 142dd5359c
3 changed files with 15 additions and 9 deletions

View file

@ -21,6 +21,7 @@ settings:
- resolution - resolution
- lowercase - lowercase
- my_ngram - my_ngram
- word_delimit
filter: filter:
my_ngram: my_ngram:
type: edgeNGram type: edgeNGram
@ -28,7 +29,11 @@ settings:
max_gram: 15 max_gram: 15
resolution: resolution:
type: pattern_capture type: pattern_capture
patterns: ["(\\d+)x(\\d+)"] patterns: ["(\\d+)[xX](\\d+)"]
word_delimit:
type: word_delimiter
preserve_original: true
split_on_numerics: false
char_filter: char_filter:
my_char_filter: my_char_filter:
type: mapping type: mapping

View file

@ -76,7 +76,7 @@
<td style="white-space: nowrap;text-align: center;"> <td style="white-space: nowrap;text-align: center;">
{% if torrent.has_torrent %}<a href="{{ url_for('download_torrent', torrent_id=torrent.id) }}"><i class="fa fa-fw fa-download"></i></a>{% endif %} {% if torrent.has_torrent %}<a href="{{ url_for('download_torrent', torrent_id=torrent.id) }}"><i class="fa fa-fw fa-download"></i></a>{% endif %}
{% if use_elastic %} {% if use_elastic %}
<a href="{{ create_magnet_from_info(torrent.display_name, torrent.info_hash) }}"><i class="fa fa-fw fa-magnet"></i></a> <a href="{{ create_magnet_from_es_info(torrent.display_name, torrent.info_hash) }}"><i class="fa fa-fw fa-magnet"></i></a>
{% else %} {% else %}
<a href="{{ torrent.magnet_uri }}"><i class="fa fa-fw fa-magnet"></i></a> <a href="{{ torrent.magnet_uri }}"><i class="fa fa-fw fa-magnet"></i></a>
{% endif %} {% endif %}
@ -85,7 +85,7 @@
{% if use_elastic %} {% if use_elastic %}
<td class="text-center" data-timestamp="{{ torrent.created_time | utc_time }}">{{ torrent.created_time | display_time }}</td> <td class="text-center" data-timestamp="{{ torrent.created_time | utc_time }}">{{ torrent.created_time | display_time }}</td>
{% else %} {% else %}
<td class="text-center" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M') }}</td> <td class="text-center" data-timestamp="{{ torrent.created_utc_timestamp | int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M') }}</td>
{% endif %} {% endif %}
{% if config.ENABLE_SHOW_STATS %} {% if config.ENABLE_SHOW_STATS %}

View file

@ -58,7 +58,7 @@ def get_trackers(torrent):
return list(trackers) return list(trackers)
def get_trackers_magnet(): def get_default_trackers():
trackers = OrderedSet() trackers = OrderedSet()
# Our main one first # Our main one first
@ -73,8 +73,9 @@ def get_trackers_magnet():
def create_magnet(torrent, max_trackers=5, trackers=None): def create_magnet(torrent, max_trackers=5, trackers=None):
# Unless specified, we just use default trackers
if trackers is None: if trackers is None:
trackers = get_trackers_magnet() trackers = get_default_trackers()
magnet_parts = [ magnet_parts = [
('dn', torrent.display_name) ('dn', torrent.display_name)
@ -88,10 +89,10 @@ def create_magnet(torrent, max_trackers=5, trackers=None):
# For processing ES links # For processing ES links
@app.context_processor @app.context_processor
def create_magnet_from_info(): def create_magnet_from_es_info():
def _create_magnet_from_info(display_name, info_hash, max_trackers=5, trackers=None): def _create_magnet_from_es_info(display_name, info_hash, max_trackers=5, trackers=None):
if trackers is None: if trackers is None:
trackers = get_trackers_magnet() trackers = get_default_trackers()
magnet_parts = [ magnet_parts = [
('dn', display_name) ('dn', display_name)
@ -101,7 +102,7 @@ def create_magnet_from_info():
b32_info_hash = base64.b32encode(bytes.fromhex(info_hash)).decode('utf-8') b32_info_hash = base64.b32encode(bytes.fromhex(info_hash)).decode('utf-8')
return 'magnet:?xt=urn:btih:' + b32_info_hash + '&' + urlencode(magnet_parts) return 'magnet:?xt=urn:btih:' + b32_info_hash + '&' + urlencode(magnet_parts)
return dict(create_magnet_from_info=_create_magnet_from_info) return dict(create_magnet_from_es_info=_create_magnet_from_es_info)
def create_default_metadata_base(torrent, trackers=None): def create_default_metadata_base(torrent, trackers=None):