@@ -123,35 +123,19 @@ def __init__(
123123 region = None ,
124124 notify_url = None
125125 ):
126- if not access_key_id :
127- access_key_id = get_setting_or_raise ('ALIYUN_TRANSCODE_ACCESS_KEY_ID' )
128- self .access_key_id = access_key_id
129-
130- if not access_key_secret :
131- access_key_secret = get_setting_or_raise ('ALIYUN_TRANSCODE_ACCESS_KEY_SECRET' )
132- self .access_key_secret = access_key_secret
133-
134- if not pipeline_id :
135- pipeline_id = get_setting_or_raise ('ALIYUN_TRANSCODE_PIPELINE_ID' )
136- self .pipeline_id = pipeline_id
137-
138- if not region :
139- region = get_setting_or_raise ('ALIYUN_TRANSCODE_REGION' )
140- self .region = region
141-
142- if not notify_url :
143- notify_url = get_setting_or_raise ('ALIYUN_TRANSCODE_NOTIFY_URL' )
144- self .notify_url = notify_url
126+ self .access_key_id = access_key_id if access_key_id else get_setting_or_raise ('ALIYUN_TRANSCODE_ACCESS_KEY_ID' )
127+ self .access_key_secret = access_key_secret if access_key_secret else get_setting_or_raise ('ALIYUN_TRANSCODE_ACCESS_KEY_SECRET' )
128+ self .pipeline_id = pipeline_id if pipeline_id else get_setting_or_raise ('ALIYUN_TRANSCODE_ACCESS_KEY_SECRET' )
129+ self .region = region if region else get_setting_or_raise ('ALIYUN_TRANSCODE_REGION' )
130+ self .notify_url = notify_url if notify_url else get_setting_or_raise ('ALIYUN_TRANSCODE_NOTIFY_URL' )
145131
146132 from aliyunsdkcore import client
147-
148133 self .client = client .AcsClient (self .access_key_id , self .access_key_secret , self .region )
149134
150135 def start_job (self , obj , transcode_kwargs , message = '' ):
151136 """
152- https://help.aliyun.com/document_detail/57347 .html?spm=5176.doc56767.6.724.AJ8z3E
137+ Transcoder reference: https://help.aliyun.com/document_detail/67664 .html
153138 """
154-
155139 import json
156140 from aliyunsdkmts .request .v20140618 import SubmitJobsRequest
157141
@@ -165,9 +149,8 @@ def start_job(self, obj, transcode_kwargs, message=''):
165149 response = json .loads (self .client .do_action_with_exception (request ).decode ('utf-8' ))
166150
167151 content_type = ContentType .objects .get_for_model (obj )
168- job = EncodeJob ()
169- job .id = response ['JobResultList' ]['JobResult' ][0 ]['Job' ]['JobId' ]
170- job .content_type = content_type
171- job .object_id = obj .pk
172- job .message = message
152+ job = EncodeJob (id = response ['JobResultList' ]['JobResult' ][0 ]['Job' ]['JobId' ],
153+ content_type = content_type ,
154+ object_id = obj .pk ,
155+ message = message )
173156 job .save ()
0 commit comments