Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite557e37

Browse files
committed
add support for the progress method in the Zencoder API
1 parenta90d643 commite557e37

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

‎README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ Install httplib2 with pip or easy_install.
1919
zen = Zencoder('abc123') # enter your api key
2020

2121
# creates an encoding job with the defaults
22-
response = zen.job.create('http://input-file/movie.avi')
23-
print response.code
24-
print response.body
25-
print response.body['id']
22+
job = zen.job.create('http://input-file/movie.avi')
23+
print job.code
24+
print job.body
25+
print job.body['id']
26+
27+
# get the transcode progress of the first output
28+
progress = zen.output.progress(job.body['outputs'][0]['id'])
29+
print progress.body
2630

2731
**Note:** If you set the**ZENCODER\_API\_KEY** environment variable to your api key, you don't have to provide it when initializing Zencoder.
2832

‎zencoder/zencoder.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
importhttplib2
77
fromurllibimporturlencode
88

9-
# Note: I've seen this pattern for dealing with json in differentpythons
10-
# in a lot of modules -- if there's a better way, I'd love to use it.
9+
# Note: I've seen this pattern for dealing with json in differentversions of
10+
#pythonin a lot of modules -- if there's a better way, I'd love to use it.
1111
try:
1212
# python 2.6 and greater
1313
importjson
@@ -129,6 +129,7 @@ def __init__(self, api_key=None, as_xml=False):
129129
self.as_xml=as_xml
130130
self.job=Job(self.api_key,self.as_xml)
131131
self.account=Account(self.api_key,self.as_xml)
132+
self.output=Output(self.api_key,self.as_xml)
132133

133134
classResponse(object):
134135
""" Response object """
@@ -138,9 +139,21 @@ def __init__(self, code, body, raw_body, raw_response):
138139
self.raw_body=raw_body
139140
self.raw_response=raw_response
140141

141-
classOutput(object):
142-
""" Output object """
143-
pass
142+
classOutput(HTTPBackend):
143+
""" Gets information regarding outputs """
144+
def__init__(self,api_key,as_xml=False):
145+
"""
146+
Initialize an Output object
147+
"""
148+
super(Output,self).__init__(api_key,as_xml,'outputs')
149+
150+
defprogress(self,id):
151+
"""
152+
Gets the given job id's progress
153+
"""
154+
data= {'api_key':self.api_key}
155+
returnself.get(self.base_url+'/%s/progress'%str(id),
156+
params=urlencode(data))
144157

145158
classJob(HTTPBackend):
146159
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp