Feature request · Report a bug · Support: Discussions & Telegram Community
Download all media files from all conversations or channels that you are a part of from telegram. A meta of last read/downloaded message is stored in the config file so that in such a way it won't download the same media file again.
Category | Support |
---|---|
Language | Python 3.6 and above |
Download media types | audio, document, photo, video, video_note, voice |
For *nix os distributions with make
availability
$ git clone https://github.com/Dineshkarthik/telegram_media_downloader.git
$ cd telegram_media_downloader
$ make install
For Windows which doesn't have make
inbuilt
$ git clone https://github.com/Dineshkarthik/telegram_media_downloader.git
$ cd telegram_media_downloader
$ pip3 install -r requirements.txt
All the configurations are passed to the Telegram Media Downloader via config.yaml
file.
Getting your API Keys: The very first step requires you to obtain a valid Telegram API key (API id/hash pair):
- Visit https://my.telegram.org/apps and log in with your Telegram Account.
- Fill out the form to register a new Telegram application.
- Done! The API key consists of two parts: api_id and api_hash.
api_hash: your_api_hash
api_id: your_api_id
phone_number: your_phone_number
last_read_message_id: {}
ids_to_retry: {}
media_types:
- audio
- document
- photo
- video
- voice
file_formats:
audio:
- all
document:
- pdf
- epub
video:
- mp4
download_directory: optional_directory_path
- api_hash - The api_hash you got from telegram apps
- api_id - The api_id you got from telegram apps
- phone_number - Your phone number you used to login to telegram
- last_read_message_id - If it is the first time you are going to read the channel let it be
0
or if you have already used this script to download media it will have some numbers which are auto-updated after the scripts successful execution. Don't change it. - ids_to_retry -
Leave it as it is.
This is used by the downloader script to keep track of all skipped downloads so that it can be downloaded during the next execution of the script. - media_types - Type of media to download, you can update which type of media you want to download it can be one or any of the available types.
- file_formats - File types to download for supported media types which are
audio
,document
andvideo
. Default format isall
, downloads all files. - download_directory - Directory to download the media files. Default is the current directory.
Optional environment variables:
DOWNLOAD_DIRECTORY=<path_to_download_directory>
API_ID=<api_id>
API_HASH=<api_hash>
PHONE_NUMBER=<phone_number>
These override the values in the config file.
$ python3 media_downloader.py
All the downloaded media will be stored inside respective directory named in the same path as the python script.
Media type | Download directory |
---|---|
audio | path/to/project/audio |
document | path/to/project/document |
photo | path/to/project/photo |
video | path/to/project/video |
voice | path/to/project/voice |
voice_note | path/to/project/voice_note |
Socks5
proxy is supported in this project currently. To use it, simply create a config.ini
file in the path of this project, and edit it with your proxy server info as follow:
[proxy]
enabled = True
hostname = 127.0.0.1
port = 1080
username =
password =
Then the proxy will automatically be enabled.
Read through our contributing guidelines to learn about our submission process, coding rules and more.
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing.
Help us keep Telegram Media Downloader open and inclusive. Please read and follow our Code of Conduct.