1- from boto import elastictranscoder
1+ from boto3 . session import Session
22
33from django .conf import settings
44from django .contrib .contenttypes .models import ContentType
77
88
99class Transcoder (object ):
10+
1011 def __init__ (self , pipeline_id , region = None , access_key_id = None , secret_access_key = None ):
1112 self .pipeline_id = pipeline_id
1213
@@ -22,7 +23,6 @@ def __init__(self, pipeline_id, region=None, access_key_id=None, secret_access_k
2223 secret_access_key = getattr (settings , 'AWS_SECRET_ACCESS_KEY' , None )
2324 self .aws_secret_access_key = secret_access_key
2425
25-
2626 if self .aws_access_key_id is None :
2727 assert False , 'Please provide AWS_ACCESS_KEY_ID'
2828
@@ -32,15 +32,20 @@ def __init__(self, pipeline_id, region=None, access_key_id=None, secret_access_k
3232 if self .aws_region is None :
3333 assert False , 'Please provide AWS_REGION'
3434
35-
36- def encode (self , input_name , outputs ):
37- encoder = elastictranscoder .connect_to_region (
38- self .aws_region ,
35+ boto_session = Session (
3936 aws_access_key_id = self .aws_access_key_id ,
40- aws_secret_access_key = self .aws_secret_access_key )
41-
42- self .message = encoder .create_job (self .pipeline_id , input_name , outputs = outputs )
43-
37+ aws_secret_access_key = self .aws_secret_access_key ,
38+ region_name = self .aws_region ,
39+ )
40+ self .client = boto_session .client ('elastictranscoder' )
41+
42+ def encode (self , input_name , outputs , ** kwargs ):
43+ self .message = self .client .create_job (
44+ PipelineId = self .pipeline_id ,
45+ Input = input_name ,
46+ Outputs = outputs ,
47+ ** kwargs
48+ )
4449
4550 def create_job_for_object (self , obj ):
4651 content_type = ContentType .objects .get_for_model (obj )
0 commit comments