-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathapi.py
More file actions
25 lines (17 loc) · 724 Bytes
/
api.py
File metadata and controls
25 lines (17 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import convertapi
from .task import Task
from .result import Result
from .exceptions import AsyncConversionInProgress
def convert(to_format, params, from_format = None, timeout = None):
task = Task(from_format, to_format, params, timeout = timeout)
return task.run()
def user(timeout = None):
return convertapi.client.get('user', timeout = timeout)
def async_convert(to_format, params, from_format = None, timeout = None):
task = Task(from_format, to_format, params, timeout = timeout, is_async = True)
return task.run()
def async_poll(job_id):
response = convertapi.client.get('async/job/%s' % job_id)
if not response:
raise AsyncConversionInProgress
return Result(response)