示例#1
0
    def create_job_for_object(self, obj):
        """
        Create an EncodeJob with the same message output as the Transcoder message

        Args:
            obj(Video): Video to create a job for

        Returns:
            EncodeJob object

        """
        content_type = ContentType.objects.get_for_model(obj)
        uuid = str(uuid4())
        if not hasattr(self, "message"):
            self.message = {  # pylint:disable=attribute-defined-outside-init
                "Job": {
                    "Status": "Error",
                    "Id": uuid
                }
            }
        job = EncodeJob()
        job.id = self.message["Job"]["Id"] if "Job" in self.message else uuid
        job.message = self.message
        job.content_type = content_type
        job.object_id = obj.pk
        job.save()
        return job