handlers
Contains factories for creating extraction objects and handlers for executing the extraction process.
ExtractionHandler
Handles the extraction process by creating the necessary objects used to perform any extraction.
Attributes:
`method` (ExtractionMethod):
The extraction method Enum to use (e.g., `ExtractionMethod.AUDIO`).
Public Methods:
`execute` -> `Result`:
Execute the video extraction process and return a `Result` object.
Set the objects to be used for extraction based on the chosen method.
Source code in videoxt/handlers.py
execute
Make the necessary objects used to perform the extraction and execute the extraction process.
Args:
`filepath` (Path | str):
Path to the video file with extension.
`options` (dict[str, Any] | None):
Extraction options specific to the chosen extraction method. If None,
default options will be used.
`skip_validation` (bool):
If True, skips validation of the extraction options. This can slightly
improve speed, but it is not recommended unless you are sure that the
options are valid.
Returns:
`Result`: A dataclass containing the extraction details.
Source code in videoxt/handlers.py
ObjectFactory
Factory for creating the necessary objects used to perform any extraction.
Attributes:
`method` (ExtractionMethod):
The extraction method Enum to use (e.g., `ExtractionMethod.AUDIO`).
Class Attributes:
`REQUEST_MAP` (dict[ExtractionMethod, Type[Request]]):
Mapping of extraction methods to their corresponding request classes.
`PREPARED_REQUEST_MAP` (dict[ExtractionMethod, Type[PreparedRequest]]):
Mapping of extraction methods to their corresponding prepared request
classes.
`EXTRACTOR_MAP` (dict[ExtractionMethod, Type[Extractor]]):
Mapping of extraction methods to their corresponding extractor classes.
Public Methods:
`make_video` -> `Video`:
Create a `Video` object.
`make_prepared_request` -> `PreparedRequest`:
Create a `PreparedRequest` object.
`make_extractor` -> `Extractor`:
Create an `Extractor` object.
`make_result` -> `Result`:
Create a `Result` object.
Set the objects to be used for extraction based on the chosen method.
Source code in videoxt/handlers.py
REQUEST_MAP
class-attribute
instance-attribute
REQUEST_MAP = {ExtractionMethod.AUDIO: AudioRequest, ExtractionMethod.CLIP: ClipRequest, ExtractionMethod.FRAMES: FramesRequest, ExtractionMethod.GIF: GifRequest}
PREPARED_REQUEST_MAP
class-attribute
instance-attribute
PREPARED_REQUEST_MAP = {ExtractionMethod.AUDIO: PreparedAudioRequest, ExtractionMethod.CLIP: PreparedClipRequest, ExtractionMethod.FRAMES: PreparedFramesRequest, ExtractionMethod.GIF: PreparedGifRequest}
EXTRACTOR_MAP
class-attribute
instance-attribute
EXTRACTOR_MAP = {ExtractionMethod.AUDIO: AudioExtractor, ExtractionMethod.CLIP: ClipExtractor, ExtractionMethod.FRAMES: FramesExtractor, ExtractionMethod.GIF: GifExtractor}
make_video
Use the given video filepath to create a Video object.
Args:
`filepath` (Path | str): Path to the video file with extension.
Returns:
`Video`: A dataclass containing the video details.
Source code in videoxt/handlers.py
make_prepared_request
Use the given video and options to create a PreparedRequest object.
Args:
`video` (Video):
The video object to use.
`options` (dict[str, Any] | None):
Extraction options specific to the chosen extraction method. If None,
default options will be used.
`skip_validation` (bool):
If True, skips validation of the extraction options. This can slightly
improve speed, but it is not recommended unless you are sure that the
options are valid.
Returns:
`PreparedRequest`: A dataclass containing the prepared request details.
Source code in videoxt/handlers.py
make_extractor
Use the given prepared request to create an Extractor object.
Args:
`prepared_request` (PreparedRequest): A type of prepared request to use.
Returns:
`Extractor`: A type of extractor object.