Python script to sync images in a Telegram chat with a local folder (one-way download).
-
Register new api id and hash at https://my.telegram.org
-
Run the following command to build the docker container
docker build -t telegram-image-downloader .
- Set Credentials in file
./credentials.env
(file is ignored via .gitignore)
TELEGRAM_API_ID=<API_ID>
TELEGRAM_API_HASH=<API_HASH>
TELEGRAM_PHONE=<PHONE_NUMBER>
TELEGRAM_DOWNLOAD_FOLDER=<DOWNLOAD_FOLDER_PATH>
TELEGRAM_CHATS=<CHAT_LIST> # comma separated list of chat names
- Source the file
source credentials.env
- Start downloading:
docker run -v $(pwd)/contents:/contents -it telegram-image-downloader /bin/bash -c "python /contents/download.py $TELEGRAM_API_ID $TELEGRAM_API_HASH $TELEGRAM_PHONE_NUMBER $TELEGRAM_DOWNLOAD_FOLDER \"$TELEGRAM_CHATS\""
You will be prompted to enter the PIN you received in telegram (another device/app) and password (if enabled). After that the download starts.