MediaDash/templates/search/include/torrent.html

124 lines
3.8 KiB
HTML

{% macro torrent_result_row(result,with_tracker=false) -%}
<tr>
<td colspan="{{4 if with_tracker else 3}}">
<hr/>
</td>
</tr>
<tr>
<td colspan="{{4 if with_tracker else 3}}">
<input type="checkbox" id="torrent_selected" name="torrent[]" value="{{result.Link or result.MagnetUri}}">
<a href="{{result.Link or result.MagnetUri}}">
{{result.Title}}
</a>
{% if result.DownloadVolumeFactor==0.0 %}
<span class="badge badge-success">Freeleech</span>
{% endif %}
{% if result.UploadVolumeFactor > 1.0 %}
<span class="badge badge-success">UL x{{result.UploadVolumeFactor}}</span>
{% endif %}
</td>
</tr>
<tr>
<td>
{{result.CategoryDesc}}
</td>
<td>
{{result.Size|filesizeformat}}
</td>
{% if with_tracker %}
<td>
<a href="{{result.Guid}}">
{{result.Tracker}}
</a>
</td>
{% endif %}
<td>
({{result.Seeders}}/{{result.Peers}}/{{ "?" if result.Grabs is none else result.Grabs}})
</td>
</tr>
{% endmacro %}
{% macro torrent_result_grouped(results) %}
{% if results %}
<table class="torrent_results">
{% for tracker,results in results.Results|groupby(attribute="Tracker") %}
<thead>
<tr>
<th>
<h2>{{tracker}} ({{results|length}})</h2>
</th>
</tr>
<tr>
<th colspan="{{4 if with_tracker else 3}}">
Name
</th>
</tr>
<tr>
<th>
Category
</th>
<th>
Size
</th>
<th>
Seeds/Peers/Grabs
</th>
</tr>
</thead>
{%for result in results|sort(attribute='Gain',reverse=true) %}
{{ torrent_result_row(result,with_tracker=false) }}
{% endfor %}
{% endfor %}
<tr>
<td colspan="{{4 if with_tracker else 3}}">
<hr/>
</td>
</tr>
</table>
{% endif %}
{% endmacro %}
{% macro torrent_results(results,group_by_tracker=false) %}
<form action="/api/add_torrent" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="text" class="form-control" id="category" name="category" placeholder="Category"/>
<span class="badge badge-primary" style="cursor: pointer" onclick="this.parentElement.submit()">
Add selected to QBittorrent
</span>
{% if group_by_tracker %}
{{ torrent_result_grouped(results) }}
{% else %}
{% if results %}
<table class="torrent_results">
<thead>
<tr>
<th colspan="{{4 if with_tracker else 3}}">
Name
</th>
</tr>
<tr>
<th>
Category
</th>
<th>
Size
</th>
<th>
Tracker
</th>
<th>
Seeds/Peers/Grabs
</th>
</tr>
</thead>
{% for result in results.Results|sort(attribute='Gain',reverse=true) %}
{{ torrent_result_row(result,with_tracker=true) }}
{% endfor %}
</table>
{% endif %}
{% endif %}
</form>
{% endmacro %}