|
2 | 2 | importrequests
|
3 | 3 | fromdatetimeimportdatetime
|
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 | fromdjango.utilsimportsimplejson
|
21 | 19 | json=simplejson
|
22 | 20 |
|
| 21 | +__version__='0.5.2' |
| 22 | + |
23 | 23 | classZencoderError(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 | returnheaders
|
@@ -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 |
| -defcreate(self,input,outputs=None,options=None): |
| 240 | +defcreate(self,input=None,live_stream=False,outputs=None,options=None): |
241 | 241 | """
|
242 |
| - Creates a job |
| 242 | + Creates atranscodingjob. |
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 | ifoutputs:
|
252 | 251 | data['outputs']=outputs
|
253 | 252 |
|
@@ -304,6 +303,10 @@ def delete(self, job_id):
|
304 | 303 | """
|
305 | 304 | returnself.cancel(job_id)
|
306 | 305 |
|
| 306 | +deffinish(self,job_id): |
| 307 | +""" Finishes the live stream for `job_id`. """ |
| 308 | +returnself.put(self.base_url+'/%s/finish'%str(job_id)) |
| 309 | + |
307 | 310 | classReport(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 | returnself.get(url,data=data)
|
| 350 | + |