-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66850b9
commit ced4cd3
Showing
6 changed files
with
109 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .client import * | ||
from .client import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
from typing import Optional | ||
|
||
from convertio.types import ConversionStatusResult | ||
|
||
|
||
class Conversion: | ||
def __init__(self, data) -> None: | ||
def __init__(self, data: ConversionStatusResult) -> None: | ||
self.code = data['code'] | ||
self.status = data['status'] | ||
self.id = data['data']['id'] | ||
self.step = data['data']['step'] | ||
self.step_percent = data['data']['step_percent'] | ||
self.minutes = data['data']['minutes'] | ||
try: | ||
self.output_url = data['data']['output']['url'] | ||
self.output_size = data['data']['output']['size'] | ||
except: | ||
self.output_url = "Url not available yet" | ||
self.output_url: str = data['data']['output']['url'] | ||
self.output_size: Optional[int] = data['data']['output']['size'] | ||
except Exception: | ||
self.output_url: str = "Url not available yet" | ||
self.output_size = None | ||
|
||
def __repr__(self): | ||
return f'<Response [{self.code}]> {self.status} | {self.step} - {self.step_percent} % \n {self.output_url}' | ||
return f'<Response [{self.code}]> {self.status} | {self.step} - {self.step_percent} % \n {self.output_url}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Any, Optional, TypedDict | ||
|
||
|
||
class ConversionPostResult(TypedDict): | ||
code: int | ||
status: str | ||
data: 'ConversionPostResultDictData' | ||
|
||
|
||
class ConversionPostResultDictData(TypedDict): | ||
id: str | ||
minutes: str | ||
|
||
|
||
class ConversionPostDict(TypedDict, total=False): | ||
apikey: str | ||
input: str | ||
file: str | ||
filename: Optional[str] | ||
outputformat: str | ||
options: Optional['ConversionPostDictOptions'] | ||
|
||
|
||
class ConversionPostDictOptions(TypedDict): | ||
ocr_enabled: bool | ||
ocr_settings: 'ConversionPostDictOptionsOcrSettings' | ||
|
||
|
||
class ConversionPostDictOptionsOcrSettings(TypedDict, total=False): | ||
langs: list[str] | ||
page_nums: Optional[str] | ||
|
||
|
||
class ConversionStatusResult(TypedDict): | ||
code: int | ||
status: str | ||
data: 'ConversionStatusResultData' | ||
|
||
|
||
class ConversionStatusResultData(TypedDict): | ||
id: str | ||
step: str | ||
step_percent: int | ||
minutes: int | ||
output: 'ConversionStatusResultDataOutPut' | ||
|
||
|
||
class ConversionStatusResultDataOutPut(TypedDict): | ||
url: str | ||
size: int | ||
files: dict[Any, Any] |