from django.core.management.base import BaseCommand from aliyun_video.models import AliyunVideo, aliyun_transcode_event_callback class Command(BaseCommand): help = "Upload video to aliyun." def add_arguments(self, parser): parser.add_argument( '--video_id', required=True, dest='video_id', help='Must be a absolute path.', ) parser.add_argument( '--lesson_id', required=True, dest='lesson_id' ) def handle(self, *args, **options): AliyunVideo.objects.create( lesson_id=options['lesson_id'], video_id=options['video_id'], title='temp', status=AliyunVideo.STATUS_PROCESSING, ) aliyun_transcode_event_callback(options['video_id']) print('Sync success!')