-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp4_types.py
48 lines (35 loc) · 1.32 KB
/
mp4_types.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
if sys.version_info >= (3, 8):
from typing import TypedDict # >=3.8
else:
from mypy_extensions import TypedDict # <=3.7
if sys.version_info < (3, 10):
from typing_extensions import ParamSpec, Concatenate # <3.10
else:
from typing import ParamSpec, Concatenate # =3.10
from pathlib import Path
from enum import Enum
import httpx
import ffmpeg
from typing import Callable, Type, TypeVar, Union
class DownloadArgs(TypedDict):
file_name: Path
video_url: str
is_concurrent: bool
class ConvertArgs(TypedDict):
video_file: Path
overwrite: bool
quiet: bool
DownloadStatus = Enum("DownloadStatus", "OK NOT_FOUND ERROR")
ConvertStatus = Enum("ConvertStatus", "OK EXIST ERROR")
TPath = TypeVar("TPath", str, Path)
ParamType = ParamSpec("ParamType")
RetType = TypeVar("RetType", DownloadStatus, ConvertStatus)
OriginalFunc = Callable[ParamType, RetType]
DecoratedFunc = Callable[Concatenate[Union[DownloadArgs, ConvertArgs], ParamType], RetType]
DownloadVideoFunc = Callable[[DownloadArgs], DownloadStatus]
ConvertVideoFunc = Callable[[ConvertArgs], ConvertStatus]
InnerFunc = Union[DownloadStatus, ConvertStatus]
DecoratorFunc = Union[DownloadVideoFunc, ConvertVideoFunc]
RetryRetFunc = Callable[[DecoratorFunc], DecoratorFunc]
ExceptionArgs = Union[Type[httpx.HTTPStatusError], Type[ffmpeg.Error]]