Skip to content

Instantly share code, notes, and snippets.

@lgg lgg/README.md
Last active Jan 23, 2019

Embed
What would you like to do?
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: https://github.com/telegramdesktop/tdesktop/issues/1382#issuecomment-362860530 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
You can’t perform that action at this time.