Skip to content

Commit 860613e

Browse files
committed
improvements
1 parent d878b31 commit 860613e

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ For instance, encode an mp3
9696
transcoder = Transcoder(pipeline_id)
9797
transcoder.encode(input, outputs)
9898
99+
# your can also create a EncodeJob for object automatically
100+
transcoder.create_job_for_object(obj)
101+
99102
100103
# Transcoder can also work standalone without Django
101104
# just pass region and required aws key/secret to Transcoder, when initiate
@@ -124,7 +127,6 @@ Signals
124127

125128
This package provide various signals for you to get notification, and do more things in your application. you can check the signals usage in tests.py for more usage example.
126129

127-
* transcode_init
128130
* transcode_onprogress
129131
* transcode_onerror
130132
* transcode_oncomplete

dj_elastictranscoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.6'
1+
__version__ = '0.7'

dj_elastictranscoder/admins.py renamed to dj_elastictranscoder/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
class EncodeJobAdmin(admin.ModelAdmin):
55
list_display = ('id', 'state', 'message')
6-
list_filter = ('state',)
7-
admin.site.register(EncodeJob, EncodeJob)
6+
list_filters = ('state',)
7+
admin.site.register(EncodeJob, EncodeJobAdmin)

dj_elastictranscoder/signals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.dispatch import Signal
22

3-
transcode_init = Signal(providing_args=["message"])
43
transcode_onprogress = Signal(providing_args=["message"])
54
transcode_onerror = Signal(providing_args=["message"])
65
transcode_oncomplete = Signal(providing_args=["message"])

dj_elastictranscoder/transcoder.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from boto import elastictranscoder
22

33
from django.conf import settings
4+
from django.contrib.contenttypes.models import ContentType
45

5-
from .signals import transcode_init
6+
from .models import EncodeJob
67

78

89
class Transcoder(object):
@@ -38,7 +39,14 @@ def encode(self, input_name, outputs):
3839
aws_access_key_id=self.aws_access_key_id,
3940
aws_secret_access_key=self.aws_secret_access_key)
4041

41-
message = encoder.create_job(self.pipeline_id, input_name, outputs=outputs)
42-
43-
# send signal
44-
transcode_init.send(sender=None, message=message)
42+
self.message = encoder.create_job(self.pipeline_id, input_name, outputs=outputs)
43+
44+
45+
def create_job_for_object(self, obj):
46+
content_type = ContentType.objects.get_for_model(obj)
47+
48+
job = EncodeJob()
49+
job.id = self.message['Job']['Id']
50+
job.content_type = content_type
51+
job.object_id = obj.id
52+
job.save()

0 commit comments

Comments
 (0)