arr-summary/templates/watch.html
Barely Removable 8115ed4855
All checks were successful
Deploy / deploy (push) Successful in 28s
Add active-viewer list to Watch with per-user 48h history drill-down
Lists anyone who's watched something in the last 10 days; clicking a
name shows their play history for the last 48 hours.

Bump to v2.1.0 per the just-added CLAUDE.md rule that every commit
should be matched with a version change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kn4ZaFd6RCnbMewMyMsfe
2026-08-31 07:56:18 -07:00

120 lines
4.8 KiB
HTML

{% extends "_shell.html" %}
{% from "_macros.html" import service_error, bar %}
{% block title %}P101 Watch{% endblock %}
{% block content %}
<h1 class="tt-dh bloom tt-masthead">WATCH</h1>
{% if tautulli.status != 'ok' %}
<div class="tt-field crit"><span>Tautulli</span><span class="tt-field-meta">off air</span></div>
{{ service_error('Tautulli', tautulli.error) }}
{% else %}
{%- set sessions = tautulli.sessions or [] -%}
{% if selected_user %}
<div class="tt-field"><span>History &mdash; {{ selected_user }}</span><span class="tt-field-meta">last 48 hours</span></div>
{% if user_history.status != 'ok' %}
{{ service_error('Tautulli', user_history.error) }}
{% elif user_history.entries %}
<div class="tt-rows">
{% for it in user_history.entries %}
<div class="tt-row">
<span class="tt-row-name">{{ (it.media_type or 'play') | upper }}</span>
<span class="tt-row-body">
<span class="tt-row-title">{{ it.title }}</span>
<span class="tt-row-sub">{{ it.when }}</span>
</span>
<span class="tt-row-val">{{ it.percent }}%</span>
</div>
{% endfor %}
</div>
{% else %}
<p class="tt-empty">Nothing played in the last 48 hours.</p>
{% endif %}
<p class="tt-empty"><a href="{{ request.script_root }}/watch">&larr; All viewers</a></p>
{% endif %}
<div class="tt-field {{ 'warn' if sessions else '' }}">
<span>Streaming Now</span>
<span class="tt-field-meta">{{ tautulli.active_streams }} active</span>
</div>
{% if sessions %}
<div class="tt-rows">
{% for s in sessions %}
<div class="tt-row">
<span class="tt-row-name">{{ (s.media_type or 'play') | upper }}</span>
<span class="tt-row-body">
<span class="tt-row-title">{{ s.title }}</span>
<span class="tt-row-sub">
{{ s.user or s.username }}
{%- if s.player %} &middot; {{ s.player }}{% endif %}
{%- if s.quality %} &middot; {{ s.quality }}{% endif %}
{%- if s.decision %} &middot; {{ s.decision | upper }}{% endif %}
{%- if s.ends_at %} &middot; ENDS {{ s.ends_at }}{% endif %}
</span>
</span>
{{ bar(s.progress | default(0), 'ok') }}
<span class="tt-row-val">{{ s.progress | default(0) | round | int }}%</span>
</div>
{% endfor %}
</div>
{% else %}
<p class="tt-empty">Nothing streaming. The service is quiet.</p>
{% endif %}
<div class="tt-field"><span>Most Played</span><span class="tt-field-meta">last 30 days</span></div>
<div class="tt-rows">
{% for t in (tautulli.top_tv_list or [])[:5] %}
<div class="tt-row">
<span class="tt-row-num">{{ loop.index }}</span>
<span class="tt-row-name">TV</span>
<span class="tt-row-body"><span class="tt-row-title">{{ t.title }}</span></span>
<span class="tt-row-val">{{ t.plays }} PLAYS</span>
</div>
{% endfor %}
{% for t in (tautulli.top_movie_list or [])[:5] %}
<div class="tt-row">
<span class="tt-row-num">{{ loop.index }}</span>
<span class="tt-row-name">Film</span>
<span class="tt-row-body"><span class="tt-row-title">{{ t.title }}</span></span>
<span class="tt-row-val">{{ t.plays }} PLAYS</span>
</div>
{% endfor %}
{% if not tautulli.top_tv_list and not tautulli.top_movie_list %}
<p class="tt-empty">No play history yet.</p>
{% endif %}
</div>
{% if tautulli.top_users %}
<div class="tt-field"><span>Who Is Watching</span></div>
<div class="tt-rows">
{% for u in tautulli.top_users[:5] %}
<div class="tt-row">
<span class="tt-row-num">{{ loop.index }}</span>
<span class="tt-row-body"><span class="tt-row-title">{{ u.username or u.user }}</span></span>
<span class="tt-row-val">{{ u.plays }} PLAYS</span>
</div>
{% endfor %}
</div>
{% endif %}
<div class="tt-field"><span>Active Viewers</span><span class="tt-field-meta">last 10 days</span></div>
{% if tautulli.active_users %}
<div class="tt-rows">
{% for u in tautulli.active_users %}
<a class="tt-row" href="{{ request.script_root }}/watch?user={{ u.username | urlencode }}">
<span class="tt-row-num">{{ loop.index }}</span>
<span class="tt-row-body">
<span class="tt-row-title">{{ u.username }}</span>
<span class="tt-row-sub">Last watched {{ u.last_watched }}</span>
</span>
<span class="tt-row-val">{{ u.plays }} PLAYS</span>
</a>
{% endfor %}
</div>
{% else %}
<p class="tt-empty">No viewers in the last 10 days.</p>
{% endif %}
{% endif %}
{% endblock %}