Add video and series detail pages
This commit is contained in:
@ -22,7 +22,7 @@ class VideoAdmin(admin.ModelAdmin):
|
|||||||
"tv_series",
|
"tv_series",
|
||||||
"season_number",
|
"season_number",
|
||||||
"episode_number",
|
"episode_number",
|
||||||
"imdb_id",
|
"imdb_rating",
|
||||||
)
|
)
|
||||||
list_filter = ("year", "tv_series", "video_type")
|
list_filter = ("year", "tv_series", "video_type")
|
||||||
ordering = ("-created",)
|
ordering = ("-created",)
|
||||||
|
|||||||
@ -37,6 +37,7 @@ def lookup_video_from_imdb(name_or_id: str, kind: str = "movie") -> dict:
|
|||||||
if not video_dict:
|
if not video_dict:
|
||||||
logger.warn(f"No video found for key {name_or_id}")
|
logger.warn(f"No video found for key {name_or_id}")
|
||||||
return video_dict
|
return video_dict
|
||||||
|
imdb_client.update(video_dict)
|
||||||
|
|
||||||
cover_url = video_dict.get("cover url")
|
cover_url = video_dict.get("cover url")
|
||||||
if cover_url:
|
if cover_url:
|
||||||
|
|||||||
@ -29,21 +29,30 @@ class Series(TimeStampedModel):
|
|||||||
|
|
||||||
genres = TaggableManager()
|
genres = TaggableManager()
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
def imdb_link(self):
|
|
||||||
return f"https://www.imdb.com/title/{self.imdb_id}"
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "series"
|
verbose_name_plural = "series"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse("videos:series_detail", kwargs={"slug": self.uuid})
|
||||||
|
|
||||||
|
def imdb_link(self):
|
||||||
|
return f"https://www.imdb.com/title/tt{self.imdb_id}"
|
||||||
|
|
||||||
|
def scrobbles_for_user(self, user_id: int):
|
||||||
|
from scrobbles.models import Scrobble
|
||||||
|
|
||||||
|
return Scrobble.objects.filter(
|
||||||
|
video__tv_series=self, user=user_id, played_to_completion=True
|
||||||
|
).order_by("-timestamp")
|
||||||
|
|
||||||
def fix_metadata(self, force_update=False):
|
def fix_metadata(self, force_update=False):
|
||||||
imdb_dict = lookup_video_from_imdb(self.name, kind="tv series")
|
imdb_dict = lookup_video_from_imdb(self.name, kind="tv series")
|
||||||
logger.info(imdb_dict)
|
self.imdb_id = imdb_dict.data.get("imdbID")
|
||||||
self.imdb_id = imdb_dict.get("movieID")
|
self.imdb_rating = imdb_dict.data.get("arithmetic mean")
|
||||||
self.imdb_rating = imdb_dict.get("rating")
|
self.plot = imdb_dict.data.get("plot outline")
|
||||||
self.plot = imdb_dict.get("plot outline")
|
|
||||||
self.save(update_fields=["imdb_id", "imdb_rating", "plot"])
|
self.save(update_fields=["imdb_id", "imdb_rating", "plot"])
|
||||||
|
|
||||||
cover_url = imdb_dict.get("cover url")
|
cover_url = imdb_dict.get("cover url")
|
||||||
@ -104,7 +113,7 @@ class Video(ScrobblableMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def imdb_link(self):
|
def imdb_link(self):
|
||||||
return f"https://www.imdb.com/title/{self.imdb_id}"
|
return f"https://www.imdb.com/title/tt{self.imdb_id}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def info_link(self):
|
def info_link(self):
|
||||||
@ -116,10 +125,14 @@ class Video(ScrobblableMixin):
|
|||||||
|
|
||||||
def fix_metadata(self, force_update=False):
|
def fix_metadata(self, force_update=False):
|
||||||
imdb_dict = lookup_video_from_imdb(self.imdb_id)
|
imdb_dict = lookup_video_from_imdb(self.imdb_id)
|
||||||
self.imdb_rating = imdb_dict.get("rating")
|
if imdb_dict.get("runtimes") and len(imdb_dict.get("runtimes")) > 0:
|
||||||
self.plot = imdb_dict.get("plot outline")
|
self.run_time_seconds = int(imdb_dict.get("runtimes")[0]) * 60
|
||||||
self.year = imdb_dict.get("year")
|
self.imdb_rating = imdb_dict.data.get("rating")
|
||||||
self.save(update_fields=["imdb_rating", "plot", "year"])
|
self.plot = imdb_dict.data.get("plot")
|
||||||
|
self.year = imdb_dict.data.get("year")
|
||||||
|
self.save(
|
||||||
|
update_fields=["imdb_rating", "plot", "year", "run_time_seconds"]
|
||||||
|
)
|
||||||
|
|
||||||
cover_url = imdb_dict.get("cover url")
|
cover_url = imdb_dict.get("cover url")
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,14 @@ class SeriesDetailView(generic.DetailView):
|
|||||||
model = Series
|
model = Series
|
||||||
slug_field = "uuid"
|
slug_field = "uuid"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context_data = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
context_data["scrobbles"] = self.object.scrobbles_for_user(
|
||||||
|
self.request.user.id
|
||||||
|
)
|
||||||
|
return context_data
|
||||||
|
|
||||||
|
|
||||||
class VideoDetailView(generic.DetailView):
|
class VideoDetailView(generic.DetailView):
|
||||||
model = Video
|
model = Video
|
||||||
|
|||||||
@ -504,8 +504,8 @@
|
|||||||
{% for scrobble in video_scrobble_list %}
|
{% for scrobble in video_scrobble_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{scrobble.timestamp|naturaltime}}</td>
|
<td>{{scrobble.timestamp|naturaltime}}</td>
|
||||||
<td>{% if scrobble.video.tv_series%}S{{scrobble.video.season_number}}E{{scrobble.video.episode_number}} -{%endif %} {{scrobble.video.title}}</td>
|
<td><a href="{{scrobble.video.get_absolute_url }}">{% if scrobble.video.tv_series%}S{{scrobble.video.season_number}}E{{scrobble.video.episode_number}} -{%endif %} {{scrobble.video.title}}</a></td>
|
||||||
<td>{% if scrobble.video.tv_series %}{{scrobble.video.tv_series}}{% endif %}
|
<td><a href="{{scrobble.video.tv_series.get_absolute_url }}">{% if scrobble.video.tv_series %}{{scrobble.video.tv_series}}</a>{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@ -7,35 +7,47 @@
|
|||||||
|
|
||||||
{% block head_extra %}
|
{% block head_extra %}
|
||||||
<style>
|
<style>
|
||||||
.cover img { width: 250px; }
|
.cover img {
|
||||||
.cover { float: left; width:252px; padding:0; border: 1px solid #ccc; }
|
width: 250px;
|
||||||
.summary {
|
}
|
||||||
float:left; width:600px; margin-left:10px;
|
|
||||||
}
|
.cover {
|
||||||
|
float: left;
|
||||||
|
width: 252px;
|
||||||
|
padding: 0;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary {
|
||||||
|
float: left;
|
||||||
|
width: 600px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block lists %}
|
{% block lists %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
{% if object.hltb_cover%}
|
{% if object.hltb_cover%}
|
||||||
<div class="cover"><img src="{{object.hltb_cover.url}}" /></div>
|
<div class="cover"><img src="{{object.hltb_cover.url}}" /></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="summary">
|
<div class="summary">
|
||||||
{% if object.summary %}
|
{% if object.summary %}
|
||||||
<p>{{object.summary|safe|linebreaks|truncatewords:160}}</p>
|
<p>{{object.summary|safe|linebreaks|truncatewords:160}}</p>
|
||||||
<hr/>
|
<hr />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p style="float:right;">
|
<p style="float:right;">
|
||||||
<a href="{{object.igdb_link}}"><img src="{% static "images/igdb-logo.png" %}" width=35></a>
|
<a href="{{object.igdb_link}}"><img src="{% static " images/igdb-logo.png" %}" width=35></a>
|
||||||
<a href="{{object.hltb_link}}"><img style="background: black;" src="{% static "images/hltb.webp" %}" width=35></a>
|
<a href="{{object.hltb_link}}"><img style="background: black;" src="{% static " images/hltb.webp" %}"
|
||||||
|
width=35></a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p>{{object.scrobble_set.count}} scrobbles</p>
|
<p>{{object.scrobble_set.count}} scrobbles</p>
|
||||||
<p>{{object.scrobble_set.last.long_play_seconds|natural_duration}}{% if object.scrobble_set.last.long_play_complete %} and completed{% else %} spent playing{% endif %}</p>
|
<p>{{object.scrobble_set.last.long_play_seconds|natural_duration}}{% if object.scrobble_set.last.long_play_complete
|
||||||
|
%} and completed{% else %} spent playing{% endif %}</p>
|
||||||
<p>
|
<p>
|
||||||
{% if object.scrobble_set.last.long_play_complete == True %}
|
{% if object.scrobble_set.last.long_play_complete == True %}
|
||||||
<a href="">Play again</a>
|
<a href="">Play again</a>
|
||||||
@ -49,24 +61,27 @@
|
|||||||
<h3>Last scrobbles</h3>
|
<h3>Last scrobbles</h3>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-sm">
|
<table class="table table-striped table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Date</th>
|
<th scope="col">Date</th>
|
||||||
<th scope="col">Completed</th>
|
<th scope="col">Completed</th>
|
||||||
<th scope="col">Duration</th>
|
<th scope="col">Duration</th>
|
||||||
<th scope="col">Platforms</th>
|
<th scope="col">Platforms</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
|
{% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{scrobble.timestamp}}</td>
|
<td>{{scrobble.timestamp}}</td>
|
||||||
<td>{% if scrobble.long_play_complete == True %}Yes{% endif %}</td>
|
<td>{% if scrobble.long_play_complete == True %}Yes{% endif %}</td>
|
||||||
<td>{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position_seconds|natural_duration}}{% endif %}</td>
|
<td>{% if scrobble.in_progress %}Now playing{% else
|
||||||
<td>{% for platform in scrobble.video_game.platforms.all %}<a href="{{platform.get_absolute_url}}">{{platform}}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</td>
|
%}{{scrobble.playback_position_seconds|natural_duration}}{% endif %}</td>
|
||||||
</tr>
|
<td>{% for platform in scrobble.video_game.platforms.all %}<a
|
||||||
{% endfor %}
|
href="{{platform.get_absolute_url}}">{{platform}}</a>{% if not forloop.last %}, {% endif
|
||||||
</tbody>
|
%}{% endfor %}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
56
vrobbler/templates/videos/series_detail.html
Normal file
56
vrobbler/templates/videos/series_detail.html
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{% extends "base_list.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block title %}{{object.title}}{% if object.tv_series %} - {{object.tv_series}}{% endif %}{% endblock %}
|
||||||
|
|
||||||
|
{% block head_extra %}
|
||||||
|
<style>
|
||||||
|
.cover {float:left; width:300px; margin-right:10px;}
|
||||||
|
.summary{float:left; width:600px; margin-left:10px;}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block lists %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
{% if object.cover_image %}
|
||||||
|
<div class="cover"><img src="{{object.cover_image.url}}" /></div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="summary">
|
||||||
|
{% if object.plot%}
|
||||||
|
<p>{{object.plot|safe|linebreaks|truncatewords:160}}</p>
|
||||||
|
<hr />
|
||||||
|
{% endif %}
|
||||||
|
<p style="float:right;">
|
||||||
|
<a href="{{object.imdb_link}}"><img src="{% static " images/imdb-logo.png" %}" width=35></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md">
|
||||||
|
<h3>Last scrobbles</h3>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Date</th>
|
||||||
|
<th scope="col">Title</th>
|
||||||
|
<th scope="col">Season</th>
|
||||||
|
<th scope="col">Episode</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for scrobble in scrobbles %}
|
||||||
|
<tr>
|
||||||
|
<td>{{scrobble.timestamp}}</td>
|
||||||
|
<td><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></td>
|
||||||
|
<td>{{scrobble.media_obj.season_number}}</td>
|
||||||
|
<td>{{scrobble.media_obj.episode_number}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@ -1,8 +1,35 @@
|
|||||||
{% extends "base_detail.html" %}
|
{% extends "base_list.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block title %}{{object.title}}{% if object.tv_series %} - {{object.tv_series}}{% endif %}{% endblock %}
|
{% block title %}{{object.title}}{% if object.tv_series %} - {{object.tv_series}}{% endif %}{% endblock %}
|
||||||
|
|
||||||
{% block details %}
|
{% block head_extra %}
|
||||||
|
<style>
|
||||||
|
.cover {float:left; width:300px; margin-right:10px;}
|
||||||
|
.summary{float:left; width:600px; margin-left:10px;}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block lists %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
{% if object.cover_image %}
|
||||||
|
<div class="cover"><img src="{{object.cover_image.url}}" /></div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="summary">
|
||||||
|
{% if object.overview %}
|
||||||
|
<p><em>{{object.overview}}</em></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if object.plot%}
|
||||||
|
<p>{{object.plot|safe|linebreaks|truncatewords:160}}</p>
|
||||||
|
<hr />
|
||||||
|
{% endif %}
|
||||||
|
<p style="float:right;">
|
||||||
|
<a href="{{object.imdb_link}}"><img src="{% static " images/imdb-logo.png" %}" width=35></a>
|
||||||
|
<a href="{{object.tmdb_link}}"><img style="background: black;" src="{% static " images/tmdb-logo.png" %}" width=35></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<h3>Last scrobbles</h3>
|
<h3>Last scrobbles</h3>
|
||||||
@ -11,7 +38,6 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Date</th>
|
<th scope="col">Date</th>
|
||||||
<th scope="col">Title</th>
|
|
||||||
{% if object.tv_series %}
|
{% if object.tv_series %}
|
||||||
<th scope="col">Series</th>
|
<th scope="col">Series</th>
|
||||||
<th scope="col">Season</th>
|
<th scope="col">Season</th>
|
||||||
@ -23,9 +49,8 @@
|
|||||||
{% for scrobble in object.scrobble_set.all %}
|
{% for scrobble in object.scrobble_set.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{scrobble.timestamp}}</td>
|
<td>{{scrobble.timestamp}}</td>
|
||||||
<td>{{scrobble.video.title}}</td>
|
|
||||||
{% if object.tv_series %}
|
{% if object.tv_series %}
|
||||||
<td>{{scrobble.video.tv_series}}</td>
|
<td><a href="{{scrobble.video.tv_series.get_absolute_url}}">{{scrobble.video.tv_series}}</a></td>
|
||||||
<td>{{scrobble.video.season_number}}</td>
|
<td>{{scrobble.video.season_number}}</td>
|
||||||
<td>{{scrobble.video.episode_number}}</td>
|
<td>{{scrobble.video.episode_number}}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user