Skip to content

Commit 38d1e4e

Browse files
author
Alex Schworer
committed
Merge branch 'master' into requests-http
Conflicts: zencoder/__init__.py
2 parents 754b3b4 + 7907cfd commit 38d1e4e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

zencoder/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from .core import Zencoder
22
from .core import ZencoderResponseError
3-
43
from .core import Account
4+
from .core import __version__
55

6-
__version__ = '0.5.2'
76
__title__ = 'zencoder'
87
__author__ = 'Alex Schworer'
98

zencoder/core.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import requests
33
from datetime import datetime
44

5-
LIB_VERSION = '0.5.2'
6-
75
# Note: I've seen this pattern for dealing with json in different versions of
86
# python in a lot of modules -- if there's a better way, I'd love to use it.
97
try:
@@ -20,6 +18,8 @@
2018
from django.utils import simplejson
2119
json = simplejson
2220

21+
__version__ = '0.5.2'
22+
2323
class ZencoderError(Exception):
2424
pass
2525

@@ -62,7 +62,7 @@ def headers(self):
6262
'Content-Type': 'application/json',
6363
'Accept': 'application/json',
6464
'Zencoder-Api-Key': self.api_key,
65-
'User-Agent': 'zencoder-py v{0}'.format(LIB_VERSION)
65+
'User-Agent': 'zencoder-py v{0}'.format(__version__)
6666
}
6767

6868
return headers
@@ -237,17 +237,16 @@ def __init__(self, *args, **kwargs):
237237
kwargs['resource_name'] = 'jobs'
238238
super(Job, self).__init__(*args, **kwargs)
239239

240-
def create(self, input, outputs=None, options=None):
240+
def create(self, input=None, live_stream=False, outputs=None, options=None):
241241
"""
242-
Creates a job
242+
Creates a transcoding job.
243243
244244
@param input: the input url as string
245+
@param live_stream: starts an RTMP Live Stream
245246
@param outputs: a list of output dictionaries
246247
@param options: a dictionary of job options
247248
"""
248-
as_test = int(self.test)
249-
250-
data = {"input": input, "test": as_test}
249+
data = {"input": input, "test": self.test}
251250
if outputs:
252251
data['outputs'] = outputs
253252

@@ -304,6 +303,10 @@ def delete(self, job_id):
304303
"""
305304
return self.cancel(job_id)
306305

306+
def finish(self, job_id):
307+
""" Finishes the live stream for `job_id`. """
308+
return self.put(self.base_url + '/%s/finish' % str(job_id))
309+
307310
class Report(HTTPBackend):
308311
def __init__(self, *args, **kwargs):
309312
"""
@@ -344,3 +347,4 @@ def minutes(self, start_date=None, end_date=None, grouping=None):
344347

345348
url = self.base_url + '/minutes'
346349
return self.get(url, data=data)
350+

0 commit comments

Comments
 (0)