Add long play infra

This commit is contained in:
2023-03-08 12:11:58 -05:00
parent 788e1ab9e9
commit 960fe3e8d1
11 changed files with 209 additions and 48 deletions

View File

@ -32,6 +32,8 @@
min-height: 3em;
border-right: 1px solid #777;
}
.now-playing p { margin:0; }
.now-playing .right { float:right; margin-right:10px; }
.latest-scrobble {
width: 50%;
}
@ -220,33 +222,9 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/tracks/">
<span data-feather="music"></span>
Tracks
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/artists/">
<span data-feather="user"></span>
Artists
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/albums/">
<span data-feather="music"></span>
Albums
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/movies/">
<span data-feather="film"></span>
Movies
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/series/">
<span data-feather="tv"></span>
TV Shows
<a class="nav-link" href="/long-plays/">
<span data-feather="playv"></span>
Long plays
</a>
</li>
<li class="nav-item">
@ -262,28 +240,30 @@
<hr/>
{% if now_playing_list and user.is_authenticated %}
<ul style="padding-right:10px;">
<ul>
<b>Now playing</b>
{% for scrobble in now_playing_list %}
<div>
<div class="now-playing">
{% if scrobble.media_obj.album.cover_image %}
<td><img src="{{scrobble.track.album.cover_image.url}}" width=120 height=120 style="border:1px solid black; " /></td><br/>
<div style="float:left;padding-right:5px;"><img src="{{scrobble.track.album.cover_image.url}}" width=75 height=75 style="border:1px solid black; " /></div>
{% endif %}
<a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a><br/>
<p><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></p>
{% if scrobble.media_obj.subtitle %}
<em><a href="{{scrobble.media_obj.subtitle.get_absolute_url}}">{{scrobble.media_obj.subtitle}}</a></em><br/>
<p><em><a href="{{scrobble.media_obj.subtitle.get_absolute_url}}">{{scrobble.media_obj.subtitle}}</a></em></p>
{% endif %}
<small>{{scrobble.timestamp|naturaltime}}<br/> from {{scrobble.source}}</small>
<br/>
<p><small>{{scrobble.timestamp|naturaltime}} from {{scrobble.source}}</small></p>
<div class="progress-bar" style="margin-right:5px;">
<span class="progress-bar-fill" style="width: {{scrobble.percent_played}}%;"></span>
</div>
<a href="{% url "scrobbles:cancel" scrobble.uuid %}">Cancel</a>
<a href="{% url "scrobbles:finish" scrobble.uuid %}">Finish</a>
<hr />
<p class="action-buttons">
<a href="{% url "scrobbles:cancel" scrobble.uuid %}">Cancel</a>
<a class="right" href="{% url "scrobbles:finish" scrobble.uuid %}">Finish</a>
</p>
</div>
{% endfor %}
</ul>
<hr/>
{% if now_playing_list|length > 1 %}<hr/>{% endif %}
{% endif %}
{% if active_imports %}

View File

@ -45,7 +45,7 @@
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
<tr>
<td>{{scrobble.timestamp}}</td>
<td>{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position|natural_duration}}{% endif %}</td>
<td>{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.long_play_session_seconds|natural_duration}}{% endif %}</td>
<td>{% for author in scrobble.book.authors.all %}<a href="{{author.get_absolute_url}}">{{author}}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</td>
</tr>
{% endfor %}

View File

@ -0,0 +1,95 @@
{% extends "base_list.html" %}
{% load urlreplace %}
{% block title %}Long Plays{% endblock %}
{% block lists %}
<div class="row">
<p class="view">
<span class="view-links">
{% if view == 'grid' %}
View as <a href="?{% urlreplace view='list' %}">List</a>
{% else %}
View as <a href="?{% urlreplace view='grid' %}">Grid</a>
{% endif %}
</span>
</p>
<hr />
<h2>In progress</h2>
{% if view == 'grid' %}
<div>
{% for media in in_progress %}
{% if media.cover %}
<dl style="width: 130px; float: left; margin-right:10px;">
<dd><img src="{{media.cover.url}}" width=120 height=120 /></dd>
</dl>
{% elif media.hltb_cover %}
<dl style="width: 130px; float: left; margin-right:10px;">
<dd><img src="{{media.htlb_cover.url}}" width=120 height=120 /></dd>
</dl>
{% endif %}
{% endfor %}
</div>
{% else %}
<div class="col-md">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Scrobbles</th>
<th scope="col">Title</th>
</tr>
</thead>
<tbody>
{% for media in in_progress %}
<tr>
<td>{{media.scrobble_set.count}}</td>
<td><a href="{{media.get_absolute_url}}">{{media}}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
<h2>Completed</h2>
{% if view == 'grid' %}
<div>
{% for media in completed %}
{% if media.cover %}
<dl style="width: 130px; float: left; margin-right:10px;">
<dd><img src="{{media.cover.url}}" width=120 height=120 /></dd>
</dl>
{% elif media.hltb_cover %}
<dl style="width: 130px; float: left; margin-right:10px;">
<dd><img src="{{media.htlb_cover.url}}" width=120 height=120 /></dd>
</dl>
{% endif %}
{% endfor %}
</div>
{% else %}
<div class="col-md">
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">Scrobbles</th>
<th scope="col">Title</th>
</tr>
</thead>
<tbody>
{% for media in completed %}
<tr>
<td>{{media.scrobble_set.count}}</td>
<td><a href="{{media.get_absolute_url}}">{{media}}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -27,7 +27,8 @@
</div>
<div class="row">
<p>{{object.scrobble_set.count}} scrobbles</p>
<p><a href="">Start playing</a></p>
<p>{{object.scrobble_set.last.playback_position|natural_duration}}{% if object.scrobble_set.last.long_play_complete %} and completed{% else %} spent playing{% endif %}</p>
<p><a href="">Resume long play</a></p>
</div>
<div class="row">
<div class="col-md">
@ -45,7 +46,7 @@
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
<tr>
<td>{{scrobble.timestamp}}</td>
<td>{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position|natural_duration}}{% endif %}</td>
<td>{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.long_play_session_seconds|natural_duration}}{% endif %}</td>
<td>{% for platform in scrobble.video_game.platforms.all %}<a href="{{platform.get_absolute_url}}">{{platform}}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</td>
</tr>
{% endfor %}