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

Commit91fd3ec

Browse files
committed
Merge pull request#19 from schworer/inputs-endpoint
Add Inputs support
2 parentsdbda8e9 +0d868c3 commit91fd3ec

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

‎test/fixtures/input_details.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"audio_sample_rate":44100,
3+
"frame_rate":30,
4+
"job_id":45497494,
5+
"channels":"2",
6+
"audio_bitrate_in_kbps":50,
7+
"height":720,
8+
"audio_codec":"aac",
9+
"duration_in_ms":5067,
10+
"url":"http://s3.amazonaws.com/zencodertesting/test.mov",
11+
"file_size_in_bytes":922620,
12+
"width":1280,
13+
"format":"mpeg4",
14+
"state":"finished",
15+
"total_bitrate_in_kbps":1452,
16+
"video_bitrate_in_kbps":1402,
17+
"id":45475483,
18+
"video_codec":"h264",
19+
"privacy":false
20+
}

‎test/fixtures/input_progress.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"state":"processing",
3+
"current_event":"Downloading",
4+
"current_event_progress":"32.34567345",
5+
"progress":"45.2353255"
6+
}

‎test/test_inputs.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
importunittest
2+
fromzencoderimportZencoder
3+
4+
frommockimportpatch
5+
6+
fromtest_utilimportTEST_API_KEY,load_response
7+
fromzencoderimportZencoder
8+
9+
classTestInputs(unittest.TestCase):
10+
defsetUp(self):
11+
self.zen=Zencoder(api_key=TEST_API_KEY)
12+
13+
@patch("requests.Session.get")
14+
deftest_input_details(self,get):
15+
get.return_value=load_response(200,'fixtures/input_details.json')
16+
17+
resp=self.zen.input.details(15432)
18+
self.assertEquals(resp.code,200)
19+
self.assertTrue(resp.body['id']>0)
20+
21+
@patch("requests.Session.get")
22+
deftest_input_progress(self,get):
23+
get.return_value=load_response(200,'fixtures/input_progress.json')
24+
25+
resp=self.zen.input.progress(14325)
26+
self.assertEquals(resp.code,200)
27+
self.assertEquals(resp.body['state'],'processing')
28+
29+
if__name__=="__main__":
30+
unittest.main()
31+

‎zencoder/core.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def __init__(self, api_key=None, api_version=None, timeout=None, test=False):
157157
self.job=Job(*args,**kwargs)
158158
self.account=Account(*args,**kwargs)
159159
self.output=Output(*args,**kwargs)
160+
self.input=Input(*args,**kwargs)
160161
self.report=None
161162
ifapi_version=='v2':
162163
self.report=Report(*args,**kwargs)
@@ -230,6 +231,27 @@ def details(self, output_id):
230231
"""
231232
returnself.get(self.base_url+'/%s'%str(output_id))
232233

234+
classInput(HTTPBackend):
235+
""" Returns information regarding inputs """
236+
def__init__(self,*args,**kwargs):
237+
"""
238+
Contains all API methods relating to Inputs.
239+
"""
240+
kwargs['resource_name']='inputs'
241+
super(Input,self).__init__(*args,**kwargs)
242+
243+
defprogress(self,input_id):
244+
"""
245+
Gets the given input id's progress.
246+
"""
247+
returnself.get(self.base_url+'/%s/progress'%str(input_id))
248+
249+
defdetails(self,input_id):
250+
"""
251+
Gets the given input id's details
252+
"""
253+
returnself.get(self.base_url+'/%s'%str(input))
254+
233255
classJob(HTTPBackend):
234256
""" Contains all API methods relating to transcoding Jobs. """
235257
def__init__(self,*args,**kwargs):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp