Implemented video management facilities.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import logging
|
||||
from typing import Callable, Union, Any, Optional
|
||||
import os
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User
|
||||
@ -282,5 +283,18 @@ class Video(models.Model):
|
||||
views = models.IntegerField(null=False, default=0)
|
||||
rating = models.FloatField(null=False, default=0.5)
|
||||
|
||||
def mark_watched(self):
|
||||
self.watched = True
|
||||
|
||||
def mark_unwatched(self):
|
||||
self.watched = False
|
||||
|
||||
def get_files(self):
|
||||
if self.downloaded_path is not None:
|
||||
directory, file_pattern = os.path.split(self.downloaded_path)
|
||||
for file in os.listdir(directory):
|
||||
if file.startswith(file_pattern):
|
||||
yield os.path.join(directory, file)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
Reference in New Issue
Block a user