Skip to content

Instantly share code, notes, and snippets.

@meoww-bot
Forked from lgg/README.md
Created April 24, 2021 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meoww-bot/14918a49b0c17a24e06182b7aa27f461 to your computer and use it in GitHub Desktop.
Save meoww-bot/14918a49b0c17a24e06182b7aa27f461 to your computer and use it in GitHub Desktop.
Telegram save all media from chat/user/channel

Quick tip. It is possible to download media with small python script.

Goto https://my.telegram.org and generate api id and api hash Install Telethon library with pip3 install telethon Run saveAllMedia.py (replace api_id, api_hash and username with your values).

If you need proxy install https://github.com/Anorov/PySocks pip install PySocks

This code downloads all media from the dialog with username user/chat/channel in current directory.

LICENSE: Based on: telegramdesktop/tdesktop#1382 (comment) and https://github.com/LonamiWebs/Telethon

#uncomment line below if you need proxy
#import socks
from telethon import TelegramClient, sync
#import logging
api_id=400000
api_hash='supersecreethash'
#logging.basicConfig(level=logging.DEBUG)
client = TelegramClient('test_session123123123',
api_id, api_hash,
# You may want to use proxy to connect to Telegram
#proxy=(socks.SOCKS5, 'PROXYHOST', PORT, 'PROXYUSERNAME', 'PROXYPASSWORD')
)
client.start()
for message in client.iter_messages('CHATNAME/CHANNELNAME/USERNAME'):
client.download_media(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment