MediaDash/templates/index.html

149 lines
6.6 KiB
HTML

{% extends "base.html" %}
{% macro make_row(title,items) %}
<div class="d-flex flex-wrap">
{% for item in items %}
{{item|safe}}
{% endfor %}
</div>
{% endmacro %}
{% macro make_tabs(tabs) %}
<div class="row">
<div class="col">
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
{% for (label,_) in tabs %}
{% set slug = (label|slugify) %}
{% if not (loop.first and loop.last) %}
<li class="nav-item">
<a class="nav-link {{'active' if loop.first}}" id="nav-{{slug}}-tab" data-toggle="pill" href="#pills-{{slug}}" role="tab" aria-controls="pills-{{slug}}" aria-selected="{{loop.first}}">
{{label}}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<div class="tab-content" id="searchResults">
{% for (label,items) in tabs %}
{% set slug = (label|slugify) %}
<div class="tab-pane fade {{'show active' if loop.first}}" id="pills-{{slug}}" role="tabpanel" aria-labelledby="nav-{{slug}}-tab">
{{make_row(label,items)}}
</div>
{% endfor %}
</div>
{% endmacro %}
{% macro upcoming(data) %}
<div class="container">
<div class="row">
<div class="col-lg">
<h3>Movies</h3>
<table class="table table-sm table-bordered">
<tr>
<th>Title</th>
<th>Status</th>
<th>In Cinemas</th>
<th>Digital Release</th>
</tr>
{% for movie in data.calendar.movies %}
{% if movie.isAvailable and movie.hasFile %}
{% set row_attrs = "bg-success" %}
{% elif movie.isAvailable and not movie.hasFile %}
{% set row_attrs = "bg-danger" %}
{% elif not movie.isAvailable and movie.hasFile %}
{% set row_attrs = "bg-primary" %}
{% elif not movie.isAvailable and not movie.hasFile %}
{% set row_attrs = "bg-info" %}
{% endif %}
<tr class={{row_attrs}}>
<td>
<a title="{{movie.overview}}" href="{{urljoin(config.APP_CONFIG.radarr_url,'movie/'+movie.titleSlug)}}" style="color: #eee; text-decoration: underline;">
{{movie.title}}
</a>
</td>
<td>{{movie.status}}</td>
<td>{{movie.inCinemas|fromiso|ago_dt_utc_human(rnd=0)}}</td>
{% if movie.digitalRelease %}
<td>{{movie.digitalRelease|fromiso|ago_dt_utc_human(rnd=0)}}</td>
{% else %}
<td>Unknown</td>
{% endif %}
</tr>
{% endfor %}
</table>
<h3>Episodes</h3>
<table class="table table-sm table-bordered">
<tr>
<th>Season | Episode Number</th>
<th>Show</th>
<th>Title</th>
<th>Status</th>
<th>Air Date</th>
</tr>
{% for entry in data.calendar.episodes %}
{% if entry.details %}
{% set details = entry.details[0] %}
{% endif %}
{% if entry.episode.hasAired and entry.episode.hasFile %}
{% set row_attrs = {"class":"bg-success"} %}
{% elif entry.episode.hasAired and not entry.episode.hasFile and details %}
{% set row_attrs = {"style":"background-color: green !important"} %}
{% elif entry.episode.hasAired and not entry.episode.hasFile %}
{% set row_attrs = {"class":"bg-danger"} %}
{% elif not entry.episode.hasAired and entry.episode.hasFile %}
{% set row_attrs = {"class":"bg-primary"} %}
{% elif not entry.episode.hasAired and not entry.episode.hasFile %}
{% set row_attrs = {"class":"bg-info"} %}
{% endif %}
<tr {{row_attrs|xmlattr}}>
<td>{{entry.episode.seasonNumber}} | {{entry.episode.episodeNumber}}</td>
<td>
<a href="{{urljoin(config.APP_CONFIG.sonarr_url,'series/'+entry.series.titleSlug)}}" style="color: #eee; text-decoration: underline;">
{{entry.series.title}}
</a>
</td>
<td title="{{entry.episode.overview}}">{{entry.episode.title}}</td>
<td>
{% if details %}
{% set details = entry.details[0] %}
{% set dl_prc =((details.size-details.sizeleft)/details.size)*100|round(2) %}
{{details.status}} ({{dl_prc|round(2)}} %)
{% elif row_attrs.class=="bg-success" %}
downloaded
{% elif row_attrs.class=="bg-danger" %}
not downloaded
{% elif row_attrs.class=="bg-primary" %}
leaked?
{% elif row_attrs.class=="bg-info" %}
not aired
{% endif %}
</td>
<td>{{entry.episode.airDateUtc|fromiso|ago_dt_utc_human(rnd=0)}}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endmacro %}
{% block app_content %}
{% if data is none %}
<h2>No Data available!</h2>
{% else %}
{% set tabs = [] %}
{% do tabs.append(("Schedule",[upcoming(data)])) %}
{% for row in data.images %}
{% if row[0] is string %}
{% set title=row[0] %}
{% set row=row[1:] %}
{% do tabs.append((title,row)) %}
{% endif %}
{% endfor %}
{{make_tabs(tabs)}}
{% endif %}
{% endblock %}