1 from django.core.management.base import BaseCommand
2 from archive.constants import status
3 from archive.models import Audiobook
4 from youtube import tasks
7 class Command(BaseCommand):
8 help = "Schedules some audiobooks for uploading to YouTube."
10 def add_arguments(self, parser):
11 parser.add_argument("--limit", type=int, default=6)
13 def handle(self, *args, **options):
14 for audiobook in Audiobook.objects.exclude(youtube_queued=None).order_by(
16 )[: options["limit"]]:
17 audiobook.youtube_task = tasks.YouTubeTask.delay(
18 None, audiobook.id, True
20 audiobook.youtube_status = status.WAITING
21 audiobook.save(update_fields=["youtube_task", "youtube_status"])