mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-10-31 23:55:54 +00:00
Resolves #129 and refactored create magnet es naming
This commit is contained in:
parent
02c04ce893
commit
142dd5359c
|
@ -21,6 +21,7 @@ settings:
|
|||
- resolution
|
||||
- lowercase
|
||||
- my_ngram
|
||||
- word_delimit
|
||||
filter:
|
||||
my_ngram:
|
||||
type: edgeNGram
|
||||
|
@ -28,7 +29,11 @@ settings:
|
|||
max_gram: 15
|
||||
resolution:
|
||||
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:
|
||||
my_char_filter:
|
||||
type: mapping
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<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 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 %}
|
||||
<a href="{{ torrent.magnet_uri }}"><i class="fa fa-fw fa-magnet"></i></a>
|
||||
{% endif %}
|
||||
|
@ -85,7 +85,7 @@
|
|||
{% if use_elastic %}
|
||||
<td class="text-center" data-timestamp="{{ torrent.created_time | utc_time }}">{{ torrent.created_time | display_time }}</td>
|
||||
{% 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 %}
|
||||
|
||||
{% if config.ENABLE_SHOW_STATS %}
|
||||
|
|
|
@ -58,7 +58,7 @@ def get_trackers(torrent):
|
|||
return list(trackers)
|
||||
|
||||
|
||||
def get_trackers_magnet():
|
||||
def get_default_trackers():
|
||||
trackers = OrderedSet()
|
||||
|
||||
# Our main one first
|
||||
|
@ -73,8 +73,9 @@ def get_trackers_magnet():
|
|||
|
||||
|
||||
def create_magnet(torrent, max_trackers=5, trackers=None):
|
||||
# Unless specified, we just use default trackers
|
||||
if trackers is None:
|
||||
trackers = get_trackers_magnet()
|
||||
trackers = get_default_trackers()
|
||||
|
||||
magnet_parts = [
|
||||
('dn', torrent.display_name)
|
||||
|
@ -88,10 +89,10 @@ def create_magnet(torrent, max_trackers=5, trackers=None):
|
|||
|
||||
# For processing ES links
|
||||
@app.context_processor
|
||||
def create_magnet_from_info():
|
||||
def _create_magnet_from_info(display_name, info_hash, max_trackers=5, trackers=None):
|
||||
def create_magnet_from_es_info():
|
||||
def _create_magnet_from_es_info(display_name, info_hash, max_trackers=5, trackers=None):
|
||||
if trackers is None:
|
||||
trackers = get_trackers_magnet()
|
||||
trackers = get_default_trackers()
|
||||
|
||||
magnet_parts = [
|
||||
('dn', display_name)
|
||||
|
@ -101,7 +102,7 @@ def create_magnet_from_info():
|
|||
|
||||
b32_info_hash = base64.b32encode(bytes.fromhex(info_hash)).decode('utf-8')
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue