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

Add Inputs support#19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
schworer merged 4 commits intomasterfrominputs-endpoint
May 22, 2013
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletionstest/fixtures/input_details.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
{
"audio_sample_rate": 44100,
"frame_rate": 30,
"job_id": 45497494,
"channels": "2",
"audio_bitrate_in_kbps": 50,
"height": 720,
"audio_codec": "aac",
"duration_in_ms": 5067,
"url": "http://s3.amazonaws.com/zencodertesting/test.mov",
"file_size_in_bytes": 922620,
"width": 1280,
"format": "mpeg4",
"state": "finished",
"total_bitrate_in_kbps": 1452,
"video_bitrate_in_kbps": 1402,
"id": 45475483,
"video_codec": "h264",
"privacy": false
}
6 changes: 6 additions & 0 deletionstest/fixtures/input_progress.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
{
"state": "processing",
"current_event": "Downloading",
"current_event_progress": "32.34567345",
"progress": "45.2353255"
}
31 changes: 31 additions & 0 deletionstest/test_inputs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
import unittest
from zencoder import Zencoder

from mock import patch

from test_util import TEST_API_KEY, load_response
from zencoder import Zencoder

class TestInputs(unittest.TestCase):
def setUp(self):
self.zen = Zencoder(api_key=TEST_API_KEY)

@patch("requests.Session.get")
def test_input_details(self, get):
get.return_value = load_response(200, 'fixtures/input_details.json')

resp = self.zen.input.details(15432)
self.assertEquals(resp.code, 200)
self.assertTrue(resp.body['id'] > 0)

@patch("requests.Session.get")
def test_input_progress(self, get):
get.return_value = load_response(200, 'fixtures/input_progress.json')

resp = self.zen.input.progress(14325)
self.assertEquals(resp.code, 200)
self.assertEquals(resp.body['state'], 'processing')

if __name__ == "__main__":
unittest.main()

22 changes: 22 additions & 0 deletionszencoder/core.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,6 +157,7 @@ def __init__(self, api_key=None, api_version=None, timeout=None, test=False):
self.job = Job(*args, **kwargs)
self.account = Account(*args, **kwargs)
self.output = Output(*args, **kwargs)
self.input = Input(*args, **kwargs)
self.report = None
if api_version == 'v2':
self.report = Report(*args, **kwargs)
Expand DownExpand Up@@ -230,6 +231,27 @@ def details(self, output_id):
"""
return self.get(self.base_url + '/%s' % str(output_id))

class Input(HTTPBackend):
""" Returns information regarding inputs """
def __init__(self, *args, **kwargs):
"""
Contains all API methods relating to Inputs.
"""
kwargs['resource_name'] = 'inputs'
super(Input, self).__init__(*args, **kwargs)

def progress(self, input_id):
"""
Gets the given input id's progress.
"""
return self.get(self.base_url + '/%s/progress' % str(input_id))

def details(self, input_id):
"""
Gets the given input id's details
"""
return self.get(self.base_url + '/%s' % str(input))

class Job(HTTPBackend):
""" Contains all API methods relating to transcoding Jobs. """
def __init__(self, *args, **kwargs):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp