A simple MTProto-based bot that can download various types of media (>10MB) on a local storage

Overview

TG Media Downloader Bot 🤖

Preview

A telegram bot based on Pyrogram that downloads on a local storage the following media files: animation, audio, document, photo, video, voice.

The bot is inspired from the Telethon-based bot by rodriguezst.

TO-DO

  • It runs
  • It downloads supported media
  • Use a fallback for missing metadata
  • Allow custom names for un-named files instead of file_unique_id
  • Improve error handling related to Telegram's service

Why should I use a MTProto bot? 🧐

MTProto clients connect directly to Telegram’s servers, which means there is no HTTP connection, no “polling” or “web hooks”. This means less overhead, since the protocol used between you and the server is much more compact than HTTP requests with responses in wasteful JSON.

Since there is a direct connection to Telegram’s servers, even if their Bot API endpoint is down, you can still have connection to Telegram directly.

Using a MTProto client, you are also not limited to the public API that they expose, and instead, you have full control of what your bot can do.

HTTP Bots can't download file bigger than 10mb meanwhile MTProto can download files of 1.5~2GB!

How to use 🧠

After the setup the bot is ready to use, send/forward any supported media to the bot to download on local storage.

The bot supports the following commands:

Command Role
/start Initial command (invoked by Telegram) when you start the chat with the bot for the first time.
/help Gives you the available commands list.
/about Gives you information about the project.
/abort Cancel all the pending downloads.
/status Gives you the current configuration.
/usage Gives you the usage instructions.

Setup ⚙️

The bot requires the following env-vars o work properly:

Variable Name Role
TG_API_ID Telegram API ID obtained via developer settings (see here)
TG_API_HASH Telegram API HASH obtained via developer settings (see here)
TG_BOT_TOKEN Telegram Bot Token obtained via BotFather (see here)
TG_MAX_PARALLEL [OPTIONAL] Maximum number of parallel downloads allowed (default: 4)
A big number can cause flood bocks
TG_DL_TIMEOUT [OPTIONAL] Maximum time (in seconds) to wait for a download to complete (default: 5400)
In case of timeout the download is aborted and a error is triggered
TG_DOWNLOAD_PATH Download folder on the local storage/docker mount where the files will be downloaded
The files will appear inside the folder only after download completation
TG_AUTHORIZED_USER_ID List separated by comma of authorized users' id, you can get them using the userinfobot
It can't be empty

You can run the bot inside a Docker container or directly on your PC/Server OS.

Docker 🐋

If you want to containerize the bot, just pull or build a image and provide the requires env-vars.

A official GitHub Packages is available here.

Make sure that the download path is a mounted as a volume to allow the host system to access the downloaded files.

Barebone 🖥️

If you want to run the bot directly on your PC/Server OS, do the following:

  1. Make sure to have Python 3.6+ installed on your system;

  2. Create a folder anywhere on your pc and clone the repository there:

    git clone https://github.com/LightDestory/TG_MediaDownloader

  3. Install the requirements using pip:

    pip install -r requirements.txt

  4. Execute the bot and follow the wizard to provide the env-vars:

    python ./tg_downloader.py

Generating Telegram API keys

Before working with Telegram's API, you need to get your own API ID and hash:

  1. Go to My Telegram and login with your phone number;
  2. Click under API Development tools;
  3. A Create new application window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later;
  4. Click on Create application at the end. Remember that your API ID and API Hash are secrets and Telegram won't let you revoke it. Don't post it anywhere!

Creating a Telegram Bot

  1. Open a conversation with @BotFather in Telegram

  2. Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authorization token for your new bot.

    • The name of your bot is displayed in contact details and elsewhere.
    • The Username is a short name, to be used in mentions and telegram.me links. Usernames are 5-32 characters long and are case-insensitive, but may only include Latin characters, numbers, and underscores. Your bot`s username must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.
    • The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot.

Support

Coindrop

⚠️ License

This collection is under GNU GPL-3.0 License.

You might also like...
A Simple Telegram Bot that can Download Files From Mega.nz and Upload It to Telegram

MegaDL-Bot A Simple Telegram Bot By @mrkpbots to Download Files From Mega.nz and Upload It to Telegram Features No Login Required All Mega.nz File Lin

The algorithm performs a simple user registration (Name, CPF, E-mail and Telephone) in an Amazon RDS database and also performs the storage, training and facial recognition of the user's face to identify the users already registered in the system in a next time the user is seen.
Simple Bot With Python 3.8+ For Converstaion Your Media

Media-Conversation Simple Bot With Python 3.8+ For Converstaion Your Media

Telegram bot to provide links of different types of files you send

File To Link Bot - IDN-C-X Telegram bot to provide links of different types of files you send. WHAT CAN THIS BOT DO Is it a nuisance to send huge file

A simple and modular Discord bot with various functionalities.

All-In-Bot for Discord A simple and modular Discord bot with various functionalities. How to use the bot? Simple! Just invite the bot to your server u

A simple bot to upload file to various cloud servers.

Cloudsy Bot A simple bot to upload file to various cloud servers. Variables API_HASH Your API Hash from my.telegram.org API_ID Your API ID from my.tel

arweave-nft-uploader is a Python tool to improve the experience of uploading NFTs to the Arweave storage for use with the Metaplex Candy Machine.

arweave-nft-uploader arweave-nft-uploader is a Python tool to improve the experience of uploading NFTs to the Arweave storage for use with the Metaple

 Herramienta para transferir eventos de Sucuri WAF hacia Azure Blob Storage.
Herramienta para transferir eventos de Sucuri WAF hacia Azure Blob Storage.

Transfiere eventos de Sucuri hacia Azure Blob Storage Script para transferir eventos del Sucuri Web Application Firewall (WAF) hacia Azure Blob Storag

An NFTGenerator to generate NFTs and send them to nft.storage
An NFTGenerator to generate NFTs and send them to nft.storage

NFTGenerator Table of Contents Overview Installation Introduction Features Reflection Issues & bug reports Show your support Credits Overview The NFTG

Owner
Alessio Tudisco
Italian Computer Science Student, Tech Addicted, Casual Gamer, Manga/Comic Reader
Alessio Tudisco
Pure Python 3 MTProto API Telegram client library, for bots too!

Telethon ⭐️ Thanks everyone who has starred the project, it means a lot! Telethon is an asyncio Python 3 MTProto library to interact with Telegram's A

LonamiWebs 7.3k Jan 1, 2023
Simple Telegram Bot to extract various types of archives from a telegram file or a direct link

Unzipper Bot A Telegram Bot to Extract Various Types Of Archives Features Extract various types of archives like rar, zip, tar, 7z, tar.xz etc. Passwo

I'm Not A Bot #Left_TG 93 Dec 27, 2022
A telegram bot that can upload telegram media files to anonfiles.com and give you direct download link

✯ AnonFilesBot ✯ Telegram Files to AnonFiles Upload Bot It will Also Give Direct Download Link Process : Fork This Repositry And Simply Cick On Heroku

Avishkar Patil 38 Dec 30, 2022
A simple Telegram bot that can broadcast messages and media to the bot subscribers. with mongo DB support

?????????????????? ?????? A simple Telegram bot that can broadcast messages and media to the bot subscribers using MongoDB. Features Support mongodb.c

N A C BOTS 70 Jan 2, 2023
A simple telegram Bot, Upload Media File| video To telegram using the direct download link. (youtube, Mediafire, google drive, mega drive, etc)

URL-Uploader (Bot) A Bot Upload file|video To Telegram using given Links. Features: ?? Only Auth Users (AUTH_USERS) Can Use The Bot ?? Upload YTDL Sup

Hash Minner 18 Dec 17, 2022
A simple Telegram bot that can add caption to any media on your channel

Channel Auto Caption This bot can add a caption for any media/document sent to a channel. Just deploy bot and add bot as admin to a channel. Deploy to

null 22 Nov 14, 2022
Frwdit-V1 - A Simple Bot can copy any media to a private channel provided

?? Auto Forward V2 A Simple Bot can copy any media to a private channel provided

FUCK OFF ANE 3 Dec 3, 2022
Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API.

Tg_PHub_Bot Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API. OS Support All linu

TheProgrammerCat 13 Oct 21, 2022
A bot can be used to broadcast your messages ( Text & Media ) to the Subscribers

Broadcast Bot A Telegram bot to send messages and medias to the subscribers directly through bot. Authorized users of the bot can send messages (Texts

Shabin-k 8 Oct 21, 2022
ShoukoKomiRobot - An anime themed telegram bot that can convert telegram media

ShoukoKomiRobot • ?????????????? ???? Python3 • ?????????????? ???????? Pyrogram

null 25 Aug 14, 2022