anasty17 / mirror-leech-telegram-bot

Official Repository: Telegram bot which can download direct links, torrents, nzb, google drive, telegram document, any file/folder from rclone supported clouds, all yt-dlp supported sites and jdownloader supported sites, then upload them to google drive, telegram cloud or to one of rclone supported clouds
https://t.me/mltb_official_channel
GNU General Public License v3.0
3.34k stars 4.74k forks source link
aria2c clone download google-drive jdownloader-2 leech mega mirror nzb python qbittorrent rclone rss-feed sabnzbd seed telegram-bot torrents upload usenet yt-dlp

This Telegram Bot, based on python-aria-mirror-bot, has undergone substantial modifications and is designed for efficiently mirroring or leeching files from the Internet to various destinations, including Google Drive, Telegram, or any rclone-supported cloud. It is built using asynchronous programming in Python.

Features

qBittorrent

Aria2c

Sabnzbd

TG Upload/Download

Google Drive

Status

Yt-dlp

JDownloader

Mongo Database

Torrents Search

Archives

ZIP, RAR, TAR, 7z, ISO, WIM, CAB, GZIP, BZIP2, APM, ARJ, CHM, CPIO, CramFS, DEB, DMG, FAT, HFS, LZH, LZMA, LZMA2,MBR, MSI, MSLZ, NSIS, NTFS, RPM, SquashFS, UDF, VHD, XAR, Z, TAR.XZ

RSS

Rclone

Overall

mediafire (file/folders), hxfile.co (need cookies txt with name) [hxfile.txt], streamtape.com, streamsb.net, streamhub.ink, streamvid.net, doodstream.com, feurl.com, upload.ee, pixeldrain.com, racaty.net, 1fichier.com, 1drv.ms (Only works for file not folder or business account), filelions.com, streamwish.com, send.cm (file/folders), solidfiles.com, linkbox.to (file/folders), shrdsk.me ( sharedisk.io), akmfiles.com, wetransfer.com, pcloud.link, gofile.io (file/folders), easyupload.io, mdisk.me (with ytdl), tmpsend.com, qiwi.gg, berkasdrive.com, mp4upload.com, terabox.com (videos only file/folders).

How to deploy?

Prerequisites

1. Installing requirements

git clone https://github.com/anasty17/mirror-leech-telegram-bot mirrorbot/ && cd mirrorbot
sudo apt install python3 python3-pip

Install Docker by following the official Docker docs

sudo pacman -S docker python
pip3 install -r requirements-cli.txt

2. Setting up config file

cp config_sample.env config.env
_____REMOVE_THIS_LINE_____=True

Fill up rest of the fields. Meaning of each field is discussed below. NOTE: All values must be filled between quotes, even if it's Int, Bool or List.

1. Required Fields

2. Optional Fields

3. GDrive Tools

4. Rclone

5. Update

6. Leech

7. qBittorrent/Aria2c/Sabnzbd

8. JDownloader

9. Sabnzbd

10. RSS

11. Queue System

12. Torrent Search


3. Build And Run the Docker Image

Make sure you still mount the app folder and installed the docker from official documentation.


Build And Run The Docker Image Using Official Docker Commands

sudo dockerd
sudo docker build . -t mltb
sudo docker run -p 80:80 -p 8080:8080 mltb
sudo docker ps
sudo docker stop id

Build And Run The Docker Image Using docker-compose

NOTE: If you want to use ports other than 80 and 8080 for torrent file selection and rclone serve respectively, change it in docker-compose.yml also.

sudo apt install docker-compose-plugin
sudo docker compose up
sudo docker compose up --build
sudo docker compose stop
sudo docker compose start
sudo docker compose logs --follow

IMPORTANT NOTES:

  1. Set BASE_URL_PORT and RCLONE_SERVE_PORT variables to any port you want to use. Default is 80 and 8080 respectively.

  2. Check the number of processing units of your machine with nproc cmd and times it by 4, then edit AsyncIOThreadsCount in qBittorrent.conf.


Extras

Bot commands to be set in @BotFather

mirror - or /m Mirror
qbmirror - or /qm Mirror torrent using qBittorrent
jdmirror - or /jm Mirror using jdownloader
nzbmirror - or /nm Mirror using sabnzbd
ytdl - or /y Mirror yt-dlp supported links
leech - or /l Upload to telegram
qbleech - or /ql Leech torrent using qBittorrent
jdleech - or /jl Leech using jdownloader
nzbleech - or /nl Leech using sabnzbd
ytdlleech - or /yl Leech yt-dlp supported links
clone - Copy file/folder to Drive
count - Count file/folder from GDrive
usetting - or /us User settings
bsetting - or /bs Bot settings
status - Get Mirror Status message
sel - Select files from torrent
rss - Rss menu
list - Search files in Drive
search - Search for torrents with API
cancel - or /c Cancel a task
cancelall - Cancel all tasks
forcestart - or /fs to start task from queue
del - Delete file/folder from GDrive
log - Get the Bot Log
shell - Run commands in Shell
aexec - Execute async function
exec - Execute sync function
restart - Restart the Bot
stats - Bot Usage Stats
ping - Ping the Bot
help - All cmds with description

Getting Google OAuth API credential file and token.pickle

NOTES

  1. Visit the Google Cloud Console
  2. Go to the OAuth Consent tab, fill it, and save.
  3. Go to the Credentials tab and click Create Credentials -> OAuth Client ID
  4. Choose Desktop and Create.
  5. Publish your OAuth consent screen App to prevent token.pickle from expire
  6. Use the download button to download your credentials.
  7. Move that file to the root of mirrorbot, and rename it to credentials.json
  8. Visit Google API page
  9. Search for Google Drive Api and enable it
  10. Finally, run the script to generate token.pickle file for Google Drive:
pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib
python3 generate_drive_token.py

Getting rclone.conf

  1. Install rclone from Official Site
  2. Create new remote(s) using rclone config command.
  3. Copy rclone.conf from .config/rclone/rclone.conf to repo folder

Upload


UPSTREAM REPO (Recommended)


Bittorrent Seed

Qbittorrent

Aria2c


Using Service Accounts for uploading to avoid user rate limit

For Service Account to work, you must set USE_SERVICE_ACCOUNTS = "True" in config file or environment variables. NOTE: Using Service Accounts is only recommended while uploading to a Team Drive.

1. Generate Service Accounts. What is Service Account?

Let us create only the Service Accounts that we need.

Warning: Abuse of this feature is not the aim of this project and we do NOT recommend that you make a lot of projects, just one project and 100 SAs allow you plenty of use, its also possible that over abuse might get your projects banned by Google.

NOTE: If you have created SAs in past from this script, you can also just re download the keys by running:

python3 gen_sa_accounts.py --download-keys $PROJECTID

NOTE: 1 Service Account can upload/copy around 750 GB a day, 1 project can make 100 Service Accounts so you can upload 75 TB a day.

NOTE: All people can copy 2TB/DAY from each file creator (uploader account), so if you got error userRateLimitExceeded that doesn't mean your limit exceeded but file creator limit have been exceeded which is 2TB/DAY.

Two methods to create service accounts

Choose one of these methods

1. Create Service Accounts in existed Project (Recommended Method)
python3 gen_sa_accounts.py --list-projects
python3 gen_sa_accounts.py --enable-services $PROJECTID
python3 gen_sa_accounts.py --create-sas $PROJECTID
python3 gen_sa_accounts.py --download-keys $PROJECTID
2. Create Service Accounts in New Project
python3 gen_sa_accounts.py --quick-setup 1 --new-only

A folder named accounts will be created which will contain keys for the Service Accounts.

2. Add Service Accounts

Two methods to add service accounts

Choose one of these methods

1. Add Them To Google Group then to Team Drive (Recommended)
cd accounts
$emails = Get-ChildItem .\**.json |Get-Content -Raw |ConvertFrom-Json |Select -ExpandProperty client_email >>emails.txt
grep -oPh '"client_email": "\K[^"]+' *.json > emails.txt
cd ..

Then add emails from emails.txt to Google Group, after that add this Google Group to your Shared Drive and promote it to manager and delete email.txt file from accounts folder

2. Add Them To Team Drive Directly
python3 add_to_team_drive.py -d SharedTeamDriveSrcID

Generate Database

  1. Go to https://mongodb.com/ and sign-up.
  2. Create Shared Cluster.
  3. Press on Database under Deployment Header, your created cluster will be there.
  4. Press on connect, choose Allow Access From Anywhere and press on Add IP Address without editing the ip, then create user.
  5. After creating user press on Choose a connection, then press on Connect your application. Choose Driver python and version 3.12 or later**.
  6. Copy your connection string and replace <password> with the password of your user, then press close.

Multi Drive List

To use list from multi TD/folder. Run driveid.py in your terminal and follow it. It will generate list_drives.txt file or u can simply create list_drives.txt file in working directory and fill it, check below format:

DriveName folderID/tdID or `root` IndexLink(if available)
DriveName folderID/tdID or `root` IndexLink(if available)

Example:

TD1 root https://example.dev
TD2 0AO1JDB1t3i5jUk9PVA https://example.dev

Yt-dlp and Aria2c Authentication Using .netrc File

For using your premium accounts in yt-dlp or for protected Index Links, create .netrc file according to following format:

Note: Create .netrc and not netrc, this file will be hidden, so view hidden files to edit it after creation.

Format:

machine host login username password my_password

Example:

machine instagram login anas.tayyar password mypassword

Instagram Note: You must login even if you want to download public posts and after first try you must confirm that this was you logged in from different ip(you can confirm from phone app).

Youtube Note: For youtube authentication use cookies.txt file.

Using Aria2c you can also use built in feature from bot with or without username. Here example for index link without username.

machine example.workers.dev password index_password

Where host is the name of extractor (eg. instagram, Twitch). Multiple accounts of different hosts can be added each separated by a new line.


All Thanks To Our Contributors

Donations

If you feel like showing your appreciation for this project, then how about buying me a coffee.

"Buy Me A Coffee"

Binance ID:

52187862

USDT Address:

TEzjjfkxLKQqndpsdpkA7jgiX7QQCL5p4f

Network:

TRC20

TRX Address:

TEzjjfkxLKQqndpsdpkA7jgiX7QQCL5p4f

Network:

TRC20

BTC Address:

17dkvxjqdc3yiaTs6dpjUB1TjV3tD7ScWe

ETH Address:

0xf798a8a1c72d593e16d8f3bb619ebd1a093c7309