Skip to content

Commit 05d0d18

Browse files
author
Alex Schworer
committed
Add live_stream kwarg to Job.create
1 parent a6479eb commit 05d0d18

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

test/fixtures/job_create_live.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"stream_url": "rtmp://foo:1935/live",
3+
"stream_name": "bar",
4+
"outputs": [
5+
{
6+
"label": null,
7+
"url": "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com",
8+
"id": 97931084
9+
}
10+
],
11+
"id": 47010105
12+
}

test/test_jobs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ def test_job_create(self, post):
1919
self.assertTrue(resp.body['id'] > 0)
2020
self.assertEquals(len(resp.body['outputs']), 1)
2121

22+
@patch("requests.Session.post")
23+
def test_job_create_list(self, post):
24+
post.return_value = load_response(201, 'fixtures/job_create_live.json')
25+
26+
resp = self.zen.job.create(live_stream=True)
27+
28+
self.assertEquals(resp.code, 201)
29+
self.assertTrue(resp.body['id'] > 0)
30+
self.assertEquals(len(resp.body['outputs']), 1)
31+
2232
@patch("requests.Session.get")
2333
def test_job_details(self, get):
2434
get.return_value = load_response(200, 'fixtures/job_details.json')

zencoder/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def create(self, input=None, live_stream=False, outputs=None, options=None):
242242
Creates a transcoding job.
243243
244244
@param input: the input url as string
245-
@param live_stream: starts an RTMP Live Stream
245+
@param live_stream: starts a Live Stream job (input must be None)
246246
@param outputs: a list of output dictionaries
247247
@param options: a dictionary of job options
248248
"""
@@ -253,6 +253,9 @@ def create(self, input=None, live_stream=False, outputs=None, options=None):
253253
if options:
254254
data.update(options)
255255

256+
if live_stream:
257+
data['live_stream'] = live_stream
258+
256259
return self.post(self.base_url, body=json.dumps(data))
257260

258261
def list(self, page=1, per_page=50):

0 commit comments

Comments
 (0)