Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit f91c2ac

Browse files
committed
Merge pull request StreetVoice#7 from vinta/feature/boto3
use boto3 which fully supports Elastic Transcoder's API
2 parents 8f0e54f + d563d1a commit f91c2ac

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

dj_elastictranscoder/transcoder.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from boto import elastictranscoder
1+
from boto3.session import Session
22

33
from django.conf import settings
44
from django.contrib.contenttypes.models import ContentType
@@ -7,6 +7,7 @@
77

88

99
class 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)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
zip_safe=False,
1717
install_requires=[
1818
"django >= 1.4, < 1.9",
19-
"boto >= 2.5",
19+
"boto3 >= 1.1",
2020
"South >= 0.8",
2121
],
2222
classifiers=[

0 commit comments

Comments
 (0)