media_parser.models.medias
#
Module Contents#
Classes#
BaseParser types. Using for identify parsers. |
|
Base class for all medias. |
|
Video media. |
|
Image media. |
|
Audio media. |
|
API#
- class media_parser.models.medias.ParserType[source]#
Bases:
enum.StrEnum
BaseParser types. Using for identify parsers.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- TIKTOK#
‘TikTok’
- TWITTER#
‘Twitter’
- YOUTUBE#
‘YouTube’
- REDDIT#
‘Reddit’
- INSTAGRAM#
‘Instagram’
- VK#
‘VK’
- class media_parser.models.medias.Media(/, **data: typing.Any)[source]#
Bases:
pydantic.BaseModel
Base class for all medias.
- Parameters:
type – Type source of media (TikTok, Twitter, YouTube, Reddit, Instagram)
original_url – Original URL of media
url – URL to media content
caption – Caption of media
thumbnail_url – URL to thumbnail
author – Author of media
extra_description – Extra description
language – Language of media
mime_type – MIME type of media
- Example extra_description:
"Video from YouTube"
- Example language:
"en"
- Example mime_type:
"video/mp4"
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- type: media_parser.models.medias.ParserType#
None
- original_url: str#
None
- url: str = <Multiline-String>#
None
- thumbnail_url: str | None#
None
- author: str | None#
None
- extra_description: str = <Multiline-String>#
- language: str | None#
None
- mime_type: str | None#
None
- headers: dict[str, str]#
‘Field(…)’
- class media_parser.models.medias.Video(/, **data: typing.Any)[source]#
Bases:
media_parser.models.medias.Media
Video media.
- Parameters:
max_quality_url – URL to max quality video.
audio_url – URL to audio from video.
height – Height of video.
width – Width of video.
duration – Duration of video.
- Info max_quality_url:
If max quality video is not available, max_quality_url is equal to url.
- Info audio_url:
Is it necessary?
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- max_quality_url: str | None#
None
- audio_url: str | None#
None
- mime_type: str#
‘video/mp4’
- height: int | None#
None
- width: int | None#
None
- duration: int | None#
None
- class media_parser.models.medias.Image(/, **data: typing.Any)[source]#
Bases:
media_parser.models.medias.Media
Image media.
- Parameters:
max_quality_url – URL to max quality image.
height – Height of image.
width – Width of image.
- Info max_quality_url:
If max quality image is not available, max_quality_url is equal to url.
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- max_quality_url: str | None#
None
- mime_type: str#
‘image/jpeg’
- height: int | None#
None
- width: int | None#
None
- class media_parser.models.medias.Audio(/, **data: typing.Any)[source]#
Bases:
media_parser.models.medias.Media
Audio media.
- Parameters:
mime_type – MIME type of audio.
Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError
][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.self
is explicitly positional-only to allowself
as a field name.- mime_type: str#
‘audio/mpeg’
- class media_parser.models.medias.GroupedMedia(/, **data: typing.Any)[source]#
Bases:
pydantic.BaseModel
- audios: list[media_parser.models.medias.Audio]#
‘Field(…)’
- images: list[media_parser.models.medias.Image]#
‘Field(…)’
- videos: list[media_parser.models.medias.Video]#
‘Field(…)’
- classmethod from_medias(medias: list[media_parser.models.medias.Media]) Self [source]#
Generate GroupedMedia from a list of Media.
- Parameters:
medias – List of Media.
- Returns:
Grouped Media.
- flat() list[media_parser.models.medias.Media] [source]#
Makes a list of Media from GroupedMedia.
- class media_parser.models.medias.GroupedMediaResult(/, **data: typing.Any)[source]#
Bases:
media_parser.models.medias.GroupedMedia
- event_id: str | None#
None
- request_url: str | None#
None