Start filling out content urls

This commit is contained in:
2023-01-09 00:29:55 -05:00
parent 657b194dc7
commit 28bd9ad504
9 changed files with 104 additions and 15 deletions

View File

@ -0,0 +1,7 @@
def convert_to_seconds(run_time: str) -> int:
"""Jellyfin sends run time as 00:00:00 string. We want the run time to
actually be in seconds so we'll convert it"""
if ":" in run_time:
run_time_list = run_time.split(":")
run_time = (int(run_time_list[1]) * 60) + int(run_time_list[2])
return int(run_time)

View File

@ -3,6 +3,7 @@ from typing import Dict
from uuid import uuid4 from uuid import uuid4
from django.db import models from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django_extensions.db.models import TimeStampedModel from django_extensions.db.models import TimeStampedModel
from scrobbles.utils import convert_to_seconds from scrobbles.utils import convert_to_seconds
@ -64,6 +65,10 @@ class Video(TimeStampedModel):
return f"{self.tv_series} - Season {self.season_number}, Episode {self.episode_number}" return f"{self.tv_series} - Season {self.season_number}, Episode {self.episode_number}"
return self.title return self.title
def get_absolute_url(self):
return reverse("videos:video_detail", kwargs={'slug': self.uuid})
@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/{self.imdb_id}"

View File

@ -0,0 +1,21 @@
from django.urls import path
from videos import views
app_name = 'scrobbles'
urlpatterns = [
# path('', views.scrobble_endpoint, name='scrobble-list'),
path("movies/", views.MovieListView.as_view(), name='movie_list'),
path('series/', views.SeriesListView.as_view(), name='series_list'),
path(
'series/<slug:slug>/',
views.SeriesDetailView.as_view(),
name='series_detail',
),
path(
'video/<slug:slug>/',
views.VideoDetailView.as_view(),
name='video_detail',
),
]

View File

@ -0,0 +1,25 @@
from django.views import generic
from videos.models import Series, Video
# class VideoIndexView():
class MovieListView(generic.ListView):
model = Video
def get_queryset(self):
return Video.objects.filter(video_type=Video.VideoType.MOVIE)
class SeriesListView(generic.ListView):
model = Series
class SeriesDetailView(generic.DetailView):
model = Series
slug_field = 'uuid'
class VideoDetailView(generic.DetailView):
model = Video
slug_field = 'uuid'

View File

@ -2,7 +2,7 @@
<!doctype html> <!doctype html>
<html class="no-js" lang=""> <html class="no-js" lang="">
<head> <head>
<title>{% block page_title %}Welcome{% endblock %} | Vrobbler &raquo; For video scrobbling</title> <title>{% block page_title %}Scrobble all the things{% endblock %} @ Vrobbler</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge"> <meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content=""> <meta name="description" content="">
@ -75,7 +75,7 @@
<![endif]--> <![endif]-->
<div class="container"> <div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Vrobbler</a> <a class="navbar-brand" href="/">Vrobbler</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -88,7 +88,7 @@
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Movies</a> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Movies</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{ url "games:gamesystem_list" %}">All</a> <a class="dropdown-item" href="{% url "videos:movie_list" %}">All</a>
{% for movie in movie_list %} {% for movie in movie_list %}
<a class="dropdown-item" href="{{movie.get_absolute_url}}">{{movie.title}}</a> <a class="dropdown-item" href="{{movie.get_absolute_url}}">{{movie.title}}</a>
{% endfor %} {% endfor %}

View File

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% block content %}
<h2>Movies</h2>
<ul>
{% for movie in object_list %}
<li>{{movie}}</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}Videos{% endblock %}
{% block content %}
{{object}}
{% for scrobble in object.scrobble_set.all %}
<ul>
<li>{{scrobble}}</li>
</ul>
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "base.html" %}
{% block title %}Movies{% endblock %}
{% block content %}
{% for movie in object_list %}
<dl>
<dt>{{movie}}</dt>
{% for scrobble in movie.scrobble_set.all %}
<dd>{{scrobble}}</dd>
{% endfor %}
</dl>
{% endfor %}
{% endblock %}

View File

@ -2,20 +2,11 @@ from django.conf import settings
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path
from scrobbles.views import RecentScrobbleList
from scrobbles import urls as scrobble_urls
# from scrobbles.api.views import ScrobbleViewSet
# from media_types.api.views import (
# ShowViewSet,
# MovieViewSet,
# )
from rest_framework import routers from rest_framework import routers
from scrobbles.views import RecentScrobbleList
from videos import urls as video_urls
# router = routers.DefaultRouter() from scrobbles import urls as scrobble_urls
# router.register(r"scrobbles", ScrobbleViewSet)
# router.register(r"shows", ShowViewSet)
# router.register(r"movies", MovieViewSet)
urlpatterns = [ urlpatterns = [
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
@ -24,6 +15,7 @@ urlpatterns = [
# path("movies/", include(movies, namespace="movies")), # path("movies/", include(movies, namespace="movies")),
# path("shows/", include(shows, namespace="shows")), # path("shows/", include(shows, namespace="shows")),
path("api/v1/scrobbles/", include(scrobble_urls, namespace="scrobbles")), path("api/v1/scrobbles/", include(scrobble_urls, namespace="scrobbles")),
path("", include(video_urls, namespace="videos")),
path("", RecentScrobbleList.as_view(), name="home"), path("", RecentScrobbleList.as_view(), name="home"),
] ]