A simple script to automate telegram download of big files
Find a file
2021-03-08 21:54:24 +02:00
.github/workflows fix 'deamon' typo in docker publish action 2020-05-24 18:34:44 +02:00
.gitignore Use volume for authentication with docker 2020-04-24 12:35:53 +03:00
docker-compose.yml change "DEAMON" to "DAEMON" 2020-05-10 07:43:13 +03:00
Dockerfile Use volume for authentication with docker 2020-04-24 12:35:53 +03:00
LICENSE.txt First working version 2020-04-22 20:35:13 +02:00
README.md Telegram file size limit is 2Gb 2021-02-17 19:06:24 +01:00
requirements.txt pip3 freeze > requirements.txt 2020-04-23 18:50:10 +03:00
runtime.txt Added minimal config for Heroku deployment 2020-11-21 11:32:38 +01:00
sessionManager.py Even more fixes for Python 3.5 compatibility 2021-02-23 12:55:17 +01:00
telegram-download-daemon.py use shutil.move to support Docker Volumes 2021-03-08 21:54:24 +02:00

telegram-download-daemon

A Telegram Daemon (not a bot) for file downloading automation

If you have got an Internet connected computer or NAS and you want to automate file downloading from Telegram channels, this daemon is for you.

Telegram bots are limited to 20Mb file size downloads. So I wrote this agent or daemon to allow bigger downloads (limited to 2GB by Telegram APIs).

Installation

You need Python3 (tested in 3.6).

Install dependencies by running this command:

pip install -r requirements.txt

(If you don't want to install cryptg and its dependencies, you just need to install telethon)

Obtain your own api id: https://core.telegram.org/api/obtaining_api_id

Usage

You need to configure these values:

Environment Variable Command Line argument Description Default Value
TELEGRAM_DAEMON_API_ID --api-id api_id from https://core.telegram.org/api/obtaining_api_id
TELEGRAM_DAEMON_API_HASH --api-hash api_hash from https://core.telegram.org/api/obtaining_api_id
TELEGRAM_DAEMON_DEST --dest Destination path for downloaded files /telegram-downloads
TELEGRAM_DAEMON_TEMP --temp Destination path for temporary (download in progress) files use --dest
TELEGRAM_DAEMON_CHANNEL --channel Channel id to download from it

You can define them as Environment Variables, or put them as a command line arguments, for example:

python telegram-download-daemon.py --api-id <your-id> --api-hash <your-hash> --channel <channel-number>

Finally, resend any file link to the channel to start the downloading. This daemon can manage many downloads simultaneously.

You can also 'talk' to this daemon using your Telegram client:

  • Say "list" and get a list of available files in the destination path.
  • Say "status" to the daemon yo check the current status.
  • Say "clean" to remove stale (*.tdd) files from temporary directory.

Docker

docker pull alfem/telegram-download-daemon

When we use the TelegramClient method, it requires us to interact with the Console to give it our phone number and confirm with a security code.

To do this, when using Docker, you need to interactively run the container for the first time.

When you use docker-compose, the .session file, where the login is stored is kept in Volume outside the container. Therefore, when using docker-compose you are required to:

$ docker-compose run --rm telegram-download-daemon
# Interact with the console to authenticate yourself.
# See the message "Signed in successfully as {youe name}"
# Close the container
$ docker-compose up -d

See the sessions volume in the docker-compose.yml file.