|
2 | 2 | import requests |
3 | 3 | from datetime import datetime |
4 | 4 |
|
5 | | -LIB_VERSION = '0.5.2' |
6 | | - |
7 | 5 | # Note: I've seen this pattern for dealing with json in different versions of |
8 | 6 | # python in a lot of modules -- if there's a better way, I'd love to use it. |
9 | 7 | try: |
|
20 | 18 | from django.utils import simplejson |
21 | 19 | json = simplejson |
22 | 20 |
|
| 21 | +__version__ = '0.5.2' |
| 22 | + |
23 | 23 | class ZencoderError(Exception): |
24 | 24 | pass |
25 | 25 |
|
@@ -62,7 +62,7 @@ def headers(self): |
62 | 62 | 'Content-Type': 'application/json', |
63 | 63 | 'Accept': 'application/json', |
64 | 64 | '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__) |
66 | 66 | } |
67 | 67 |
|
68 | 68 | return headers |
@@ -237,17 +237,16 @@ def __init__(self, *args, **kwargs): |
237 | 237 | kwargs['resource_name'] = 'jobs' |
238 | 238 | super(Job, self).__init__(*args, **kwargs) |
239 | 239 |
|
240 | | - def create(self, input, outputs=None, options=None): |
| 240 | + def create(self, input=None, live_stream=False, outputs=None, options=None): |
241 | 241 | """ |
242 | | - Creates a job |
| 242 | + Creates a transcoding job. |
243 | 243 |
|
244 | 244 | @param input: the input url as string |
| 245 | + @param live_stream: starts an RTMP Live Stream |
245 | 246 | @param outputs: a list of output dictionaries |
246 | 247 | @param options: a dictionary of job options |
247 | 248 | """ |
248 | | - as_test = int(self.test) |
249 | | - |
250 | | - data = {"input": input, "test": as_test} |
| 249 | + data = {"input": input, "test": self.test} |
251 | 250 | if outputs: |
252 | 251 | data['outputs'] = outputs |
253 | 252 |
|
@@ -304,6 +303,10 @@ def delete(self, job_id): |
304 | 303 | """ |
305 | 304 | return self.cancel(job_id) |
306 | 305 |
|
| 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 | + |
307 | 310 | class Report(HTTPBackend): |
308 | 311 | def __init__(self, *args, **kwargs): |
309 | 312 | """ |
@@ -344,3 +347,4 @@ def minutes(self, start_date=None, end_date=None, grouping=None): |
344 | 347 |
|
345 | 348 | url = self.base_url + '/minutes' |
346 | 349 | return self.get(url, data=data) |
| 350 | + |
0 commit comments