2020-04-23 02:20:53 +08:00
# telegram-download-daemon
2020-04-23 02:35:13 +08:00
A Telegram Daemon (not a bot) for file downloading automation
2021-03-21 00:18:18 +08:00
[](https://ko-fi.com/E1E03K0RP)
2021-03-21 00:14:02 +08:00
2020-04-23 02:35:13 +08:00
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
2021-02-18 02:06:24 +08:00
or daemon to allow bigger downloads (limited to 2GB by Telegram APIs).
2020-04-23 02:35:13 +08:00
# Installation
2021-02-09 02:28:54 +08:00
You need Python3 (tested in 3.6).
2020-04-23 02:35:13 +08:00
2020-04-23 23:50:10 +08:00
Install dependencies by running this command:
2020-04-23 02:35:13 +08:00
2020-04-23 23:50:10 +08:00
pip install -r requirements.txt
(If you don't want to install `cryptg` and its dependencies, you just need to install `telethon` )
2020-04-23 02:35:13 +08:00
2021-04-24 19:32:27 +08:00
Warning: If you get a `File size too large message` , check the version of Telethon library you are using. Old versions have got a 1.5Gb file size limit.
2020-04-23 02:35:13 +08:00
Obtain your own api id: https://core.telegram.org/api/obtaining_api_id
2020-04-24 02:33:33 +08:00
# Usage
2020-04-23 02:35:13 +08:00
2020-04-24 02:33:33 +08:00
You need to configure these values:
2020-04-23 02:35:13 +08:00
2020-04-24 02:33:33 +08:00
| Environment Variable | Command Line argument | Description | Default Value |
|--------------------------|:-----------------------:|--------------------------------------------------------------|---------------------|
2020-05-10 12:43:13 +08:00
| `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 | |
2021-01-28 00:58:35 +08:00
| `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 |
2020-11-09 00:25:17 +08:00
| `TELEGRAM_DAEMON_CHANNEL` | `--channel` | Channel id to download from it | |
2020-04-23 02:35:13 +08:00
2020-12-14 15:23:24 +08:00
You can define them as Environment Variables, or put them as a command line arguments, for example:
2020-04-23 02:35:13 +08:00
2020-09-24 18:59:04 +08:00
python telegram-download-daemon.py --api-id < your-id > --api-hash < your-hash > --channel < channel-number >
2020-04-24 17:35:53 +08:00
2021-01-04 00:49:52 +08:00
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.
2021-02-09 02:28:54 +08:00
* Say "clean" to remove stale (*.tdd) files from temporary directory.
2021-01-04 00:49:52 +08:00
2020-04-24 17:35:53 +08:00
# Docker
2020-05-25 01:49:30 +08:00
`docker pull alfem/telegram-download-daemon`
2020-04-24 17:35:53 +08:00
When we use the [`TelegramClient` ](https://docs.telethon.dev/en/latest/quick-references/client-reference.html#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:
```bash
2020-05-10 12:43:13 +08:00
$ docker-compose run --rm telegram-download-daemon
2020-04-24 17:35:53 +08:00
# 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 ](docker-compose.yml ) file.