Media#
- class pywa.types.media.Image#
Represents an received image.
- class pywa.types.media.Video#
Represents a video.
- class pywa.types.media.Audio#
Represents an audio.
- class pywa.types.media.Document#
Represents a document.
- class pywa.types.media.Sticker#
Represents a sticker.
Every media type has the following properties and methods:
- BaseMedia.download(path: str | None = None, filename: str | None = None, in_memory: bool = False, **kwargs) bytes | str #
- Download a media file from WhatsApp servers.
Same as
download_media()
withmedia_url=media.get_media_url()
>>> message.image.download()
- Parameters:
path – The path where to save the file (if not provided, the current working directory will be used).
filename – The name of the file (if not provided, it will be guessed from the URL + extension).
in_memory – Whether to return the file as bytes instead of saving it to disk (default: False).
**kwargs – Additional arguments to pass to requests.get.
- Returns:
The path of the saved file if
in_memory
is False, the file as bytes otherwise.
- class pywa.types.media.MediaUrlResponse#
Represents a media response.