junedkh / jmdkh-mltb

Unofficial Repository: Telegram bot which can download torrents, mega, google drive, telegram file and direct links + all yt-dlp supported sites, then upload them to google drive or telegram cloud. This bot supports more features like zip or extract before upload, seed after upload using qBittorrent or aria2c and many more, read features below.
https://t.me/+5d2_gaR0QwwyNGE1
GNU General Public License v3.0
11 stars 11 forks source link
google-drive mltb telegram telegram-bot torrent torrent-downloader torrent-to-drive

This is a Telegram Bot written in Python for mirroring files on the Internet to your Google Drive, Telegram or to any rclone supported cloud. Based on python-aria-mirror-bot

Features

By anasty17

In each single file there is a major change from base code, it's almost totaly different. Here some of features and fixes that I remember.

qBittorrent

Aria2c

TG Upload/Download

Google

Status

Yt-dlp

Database

Torrents Search

Archives

RSS

Rclone

Overall

From Base and other Repositories

By Junedkh

Repo is design for big groups

In each single file there is a major change inspire from base code by my friend Anasty17 ❤️.

Limits

Group Features

Extra

How to deploy?

Prerequisites

1. Installing requirements

git clone https://github.com/junedkh/jmdkh-mltb 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

GDrive Tools

Rclone

Update

Leech

qBittorrent/Aria2c

RSS

MEGA

Queue System

Torrent Search

Limits

Group Features

Extra Features


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
sudo docker-compose up
sudo docker-compose up --build
sudo docker-compose stop
sudo docker-compose start
sudo docker-compose up


Docker Notes

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. You should stop the running image before deleting the container and you should delete the container before the image.
  3. To delete the container (this will not affect on the image):
sudo docker container prune
  1. To delete the images:
sudo docker image prune -a
  1. 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
leech - or /l Leech
qbleech - or /ql Leech torrent using qBittorrent
clone - Copy file/folder to Drive
count - Count file/folder from Drive
ytdl - or /y Mirror yt-dlp supported link
ytdlleech - or /yl Leech through yt-dlp supported link
clone - Copy file/folder to Drive
count - Count file/folder from Drive
usetting - User settings
status - Get Mirror Status message
btsel - Select files from torrent
rss - Rss menu
list - Search files in Drive
search - Search for torrents with API
cancel - Cancel a task
cancelall - Cancel all tasks
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 Acces 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.6 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

Multi Category IDs

image

To use upload in categorywise TD/folder. Run driveid.py in your terminal and follow it. It will generate drive_folder file than rename it to categories.txt or u can simply create categories.txt file in working directory and fill it, check below format:

categoryName folderID/tdID IndexLink(if available)
categoryName folderID/tdID IndexLink(if available)

Example:

Root 0AO1JDB1t3i5jUk9PVA https://example.dev/0:
Movies 1H4w824ZhOt4rs14XPajDja0dAdFp1glI https://example.dev/0:/movies
Series 1H4w434ZhOt4rs14XPajDja0dAdFp1glI https://example.dev/0:/series

Now when you use /mirror or /clone cmd, you will see category options. Using that u can upload files categorywise in TD/Folder.

Multi Shortener

To use multiple shorteners to maintain CPM! it will use random shorteners to generate short links. you can simply create shorteners.txt file in working directory and fill it, check below format:

shortener_Domain shortener_Api

Example:

urlshortx.com 91fc872f9882144c27eecdc22d16f7369766f297
ouo.io LYT0zBn1

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.


Donations

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

"Buy Me A Coffee"

Binance ID:

52187862

USDT Address: TEzjjfkxLKQqndpsdpkA7jgiX7QQCL5p4f Network: TRC20

BTC Addrese: 17dkvxjqdc3yiaTs6dpjUB1TjV3tD7ScWe

ETH Address: 0xf798a8a1c72d593e16d8f3bb619ebd1a093c7309