Download the media from a message.
str) – Pass a Message containing the media, the media itself (message.audio, message.video, …) or the file id as string.
str, optional) – A valid file reference obtained by a recently fetched media message. To be used in combination with a file id in case a file reference is needed.
str, optional) – A custom file_name to be used instead of the one provided by Telegram. By default, all files are downloaded in the downloads folder in your working directory. You can also specify a path for downloading files in a custom location: paths that end with “/” are considered directories. All non-existent folders will be created automatically.
bool, optional) – Blocks the code execution until the file has been downloaded. Defaults to True.
callable, optional) – Pass a callback function to view the file transmission progress. The function must take (current, total) as positional arguments (look at Other Parameters below for a detailed description) and will be called back each time a new file chunk has been successfully transmitted.
tuple, optional) – Extra custom arguments for the progress callback function. You can pass anything you need to be available in the progress callback scope; for example, a Message object or a Client instance in order to edit the message with the updated progress status.
- Other Parameters
int) – The amount of bytes transmitted so far.
int) – The total size of the file.
tuple, optional) – Extra custom arguments as defined in the progress_args parameter. You can either keep *args or add every single extra argument in your function signature.
None– On success, the absolute path of the downloaded file is returned, otherwise, in case the download failed or was deliberately stopped with
stop_transmission(), None is returned.
ValueError – if the message doesn’t contain any downloadable media
# Download from Message app.download_media(message) # Download from file id app.download_media("CAADBAADyg4AAvLQYAEYD4F7vcZ43AI")