diff --git a/app/YtManagerApp/models.py b/app/YtManagerApp/models.py index 93d3913..08a920c 100644 --- a/app/YtManagerApp/models.py +++ b/app/YtManagerApp/models.py @@ -1,4 +1,5 @@ import logging +import mimetypes import os from typing import Callable, Union, Any, Optional @@ -218,6 +219,19 @@ class Video(models.Model): if file.startswith(file_pattern): yield os.path.join(directory, file) + def find_video(self): + """ + Finds the video file from the downloaded files, and + returns + :return: Tuple containing file path and mime type + """ + for file in self.get_files(): + mime, _ = mimetypes.guess_type(file) + if mime is not None and mime.startswith('video/'): + return (file, mime) + + return None, None + def delete_files(self): if self.downloaded_path is not None: from YtManagerApp.management.jobs.delete_video import schedule_delete_video diff --git a/app/YtManagerApp/templates/YtManagerApp/index_videos.html b/app/YtManagerApp/templates/YtManagerApp/index_videos.html index cd10cbf..16e1468 100644 --- a/app/YtManagerApp/templates/YtManagerApp/index_videos.html +++ b/app/YtManagerApp/templates/YtManagerApp/index_videos.html @@ -6,13 +6,17 @@ {% for video in videos %}
{{ video.views | intcomma }} views diff --git a/app/YtManagerApp/templates/YtManagerApp/video.html b/app/YtManagerApp/templates/YtManagerApp/video.html new file mode 100644 index 0000000..823e002 --- /dev/null +++ b/app/YtManagerApp/templates/YtManagerApp/video.html @@ -0,0 +1,83 @@ +{% extends "YtManagerApp/master_default.html" %} +{% load static %} +{% load humanize %} +{% load ratings %} + +{% block body %} + +
+ {{ object.views | intcomma }} views + • + {{ object.publish_date | naturaltime }} +
++ + Mark watched + +
+ {% endif %} + + {% if object.downloaded_path %} + + {% else %} ++ + Download + +
+ {% endif %} +