Add: managment command to back fill video & gif thumb generation
This commit is contained in:
parent
b6b8b5918c
commit
a404dcf09b
3 changed files with 22 additions and 0 deletions
0
backend/apps/files/management/__init__.py
Normal file
0
backend/apps/files/management/__init__.py
Normal file
0
backend/apps/files/management/commands/__init__.py
Normal file
0
backend/apps/files/management/commands/__init__.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from apps.files.tasks import generate_video_thumbnail
|
||||
from apps.files.models import PostFileModel
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Backfill video and gif thumbs"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# Get all PostFileModel instances that need thumbs
|
||||
files = PostFileModel.objects.filter(file_type__in=["video", "gif"])
|
||||
|
||||
# Create a progress bar
|
||||
pbar = tqdm(total=files.count(), desc="Generating thumbs")
|
||||
|
||||
# Loop through each file and generate thumbs
|
||||
for file in files:
|
||||
generate_video_thumbnail.delay(file.id)
|
||||
pbar.update(1)
|
||||
|
||||
pbar.close()
|
Loading…
Add table
Reference in a new issue