Initial commit

This commit is contained in:
Daniel S. 2021-08-29 15:03:28 +02:00
commit 7523a19d1f
40 changed files with 3984 additions and 0 deletions

View file

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% block app_content %}
<h1>{{info.title}} ({{info.year}})</h1>
<h2>{{info.hasFile}}</h2>
<p>{{info.id}}</p>
<pre>
{{info|tojson(indent=4)}}
</pre>
{% endblock %}

View file

@ -0,0 +1,18 @@
{% macro movie_results(results) -%}
<div class="d-flex flex-wrap">
{%for result in results %}
<form action="search/details" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="type" value="movie"/>
<input type="hidden" name="data" value="{{result|tojson|urlencode}}"/>
<a style="cursor: pointer" onclick="this.parentElement.submit()">
{% for poster in result.images|selectattr('coverType','eq','poster') %}
<img class="img-fluid poster" src="{{poster.url}}" title="{{result.title}}">
{% else %}
<img class="img-fluid poster" src="{{url_for('placeholder',width=333, height=500, text=result.title, wrap = 15)}}" title="{{result.title}}" />
{% endfor %}
</a>
</form>
{% endfor %}
</div>
{% endmacro %}

View file

@ -0,0 +1,123 @@
{% 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 %}

View file

@ -0,0 +1,23 @@
{% macro tv_show_results(results) -%}
<div class="d-flex flex-wrap">
{% for result in results %}
<form action="search/details" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="type" value="show"/>
<input type="hidden" name="data" value="{{result|tojson|urlencode}}" />
<a style="cursor: pointer" onclick="this.parentElement.submit()">
{% for banner in result.images|selectattr('coverType','eq','banner') %}
<img class="img-fluid banner" src="{{client.sonarr.url.rsplit("/",2)[0]+banner.url}}" title="{{result.title}}" />
{% else %}
{% set poster=(result.images|selectattr('coverType','eq','poster')|first) %}
{% if poster %}
{% set poster=(client.sonarr.url.rsplit("/",2)[0]+poster.url) %}
{% endif %}
<img class="img-fluid banner" src="{{url_for('placeholder',width=758, height=140, poster=poster, text=result.title)}}" title="{{result.title}}" />
{% endfor %}
</a>
</form>
{% endfor %}
</div>
{% endmacro %}

View file

@ -0,0 +1,64 @@
{% extends "base.html" %}
{% from "utils.html" import make_tabs, custom_render_form_row %}
{% from 'bootstrap/form.html' import render_form, render_field, render_form_row %}
{% from 'bootstrap/table.html' import render_table %}
{% from 'search/include/tv_show.html' import tv_show_results with context %}
{% from 'search/include/movie.html' import movie_results with context %}
{% from 'search/include/torrent.html' import torrent_results with context %}
{% block styles %}
{{super()}}
<style>
.poster {
height: 500px;
object-fit: cover;
}
</style>
{% endblock %}
{% block app_content %}
{% if form %}
<h1>Search</h1>
{% endif %}
<div class="row">
<div class="col-lg">
{% if session.new_torrents %}
<div class="alert alert-success alert-dismissible fade show" role="alert">
{% for torrent in session.pop('new_torrents',{}).values() %}
<p>
Added <a class="alert-link" href="{{url_for('qbittorrent',infohash=torrent.hash)}}">{{torrent.name}}</a>
</p>
{% endfor %}
</div>
{% endif %}
{% if form %}
<form method="post" class="form">
{{form.csrf_token()}}
{{custom_render_form_row([form.query],render_args={'form_type':'horizontal','horizontal_columns':('lg',1,11)})}}
{{custom_render_form_row([form.tv_shows,form.movies,form.torrents])}}
{{custom_render_form_row([form.group_by_tracker])}}
{{custom_render_form_row([form.indexer])}}
{{custom_render_form_row([form.search])}}
</form>
{% else %}
<h1>Search results for '{{search_term}}'</h1>
{% endif %}
</div>
</div>
{% set search_results = [
(results.tv_shows,"tv","TV Shows",tv_show_results,{}),
(results.movies,"movie","Movies",movie_results,{}),
(results.torrents,"torrent","Torrents",torrent_results,{"group_by_tracker":group_by_tracker}),
] %}
{% if results %}
{% set tabs = [] %}
{% for results,id_name,label,func,kwargs in search_results if results %}
{% do tabs.append((label,func(results,**kwargs))) %}
{% endfor %}
{{make_tabs(tabs)}}
{% endif %}
{% endblock %}