Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
v4.9.1
Browse files Browse the repository at this point in the history
- Change docker name
- Use qbittorrent config file
- Fixing

Co-authored-by: anas <[email protected]>
  • Loading branch information
vincreator and anasty17 committed Aug 26, 2021
1 parent dc41314 commit ccda460
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 392 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM vincreator/eunha-sdk-python:latest
FROM vincreator/eunhamirror:latest

WORKDIR /usr/src/app
RUN chmod 777 /usr/src/app
Expand All @@ -10,6 +10,7 @@ COPY extract /usr/local/bin
COPY pextract /usr/local/bin
RUN chmod +x /usr/local/bin/extract && chmod +x /usr/local/bin/pextract
COPY . .
COPY qBittorrent.conf ./.config/qBittorrent/qBittorrent.conf
COPY .netrc /root/.netrc
RUN chmod 600 /usr/src/app/.netrc
RUN chmod +x aria.sh
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ sudo apt install python3
```
Install Docker by following the [official Docker docs](https://docs.docker.com/engine/install/debian/)

OR
```
sudo snap install docker
```
- For Arch and it's derivatives:
```
sudo pacman -S docker python
Expand Down Expand Up @@ -160,8 +164,6 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
- **DOWNLOAD_DIR**: The path to the local folder where the downloads should be downloaded to
- **DOWNLOAD_STATUS_UPDATE_INTERVAL**: A short interval of time in seconds after which the Mirror progress message is updated. (I recommend to keep it `5` seconds at least)
- **AUTO_DELETE_MESSAGE_DURATION**: Interval of time (in seconds), after which the bot deletes it's message (and command message) which is expected to be viewed instantly. (**Note**: Set to `-1` to never automatically delete messages)
- **UPSTREAM_REPO**: Link for Bot Upstream Repo, if you want default update, fill `https://github.com/vincreator/Eunha-Mirror-bot`.
- **UPSTREAM_BRANCH**: Branch name for Bot Upstream Repo, fill `master`.
### Optional Field
- **ACCOUNTS_ZIP_URL**: Only if you want to load your Service Account externally from an Index Link. Archive your Service Account json files to a zip file directly (don't archive the accounts folder. Select all the jsons inside and zip them only instead. Name the zip file with whatever you want, it doesn't matter). Fill this with the direct link of that file.
- **TOKEN_PICKLE_URL**: Only if you want to load your **token.pickle** externally from an Index Link. Fill this with the direct link of that file.
Expand All @@ -188,9 +190,9 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
- **HEROKU_APP_NAME**: (Only if you deploying on Heroku) Your Heroku app name.
- **IGNORE_PENDING_REQUESTS**: If you want the bot to ignore pending requests after it restarts, set this to `True`.
- **STATUS_LIMIT**: Status limit with buttons (**NOTE**: Recommend limit status to `4` tasks max).
- **IS_VPS**: Set it to `True` if you use VPS
- **SERVER_PORT**: Your VPS port
- **BASE_URL_OF_BOT**: Valid BASE URL of where the bot is deploy. Ip/domain of your bot like `http://myip` or if you have chosen other port then `80` then `http://myip:port`. No slash at the end, for Heroku fill `https://yourappname.herokuapp.com`.
- **IS_VPS**: (Only for VPS) Don't set this to `True` even if you are using vps, unless facing error with web server. Also go to start.sh and replace `$PORT` by `80` or any port you want to use.
- **SERVER_PORT**: (Only if IS_VPS is `True`) Base URL Port
- **BASE_URL_OF_BOT**: (Required for Heroku) Valid BASE URL of where the bot is deploy. Ip/domain of your bot like `http://myip` or if you have chosen other port then `80` then `http://myip:port`, for Heroku fill `https://yourappname.herokuapp.com` (**NOTE**: No slash at the end)
- **SHORTENER_API**: Fill your Shortener api key if you are using Shortener.
- **SHORTENER**: if you want to use Shortener in Gdrive and index link, fill Shortener url here. Examples:
```
Expand Down
8 changes: 0 additions & 8 deletions alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
import time
import requests
import os
import subprocess
from dotenv import load_dotenv

CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL', None)
if CONFIG_FILE_URL is not None:
out = subprocess.run(["wget", "-q", "-O", "config.env", CONFIG_FILE_URL])

load_dotenv('config.env')

BASE_URL = os.environ.get('BASE_URL_OF_BOT', None)
if len(BASE_URL) == 0:
Expand Down
2 changes: 1 addition & 1 deletion aria.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tracker_list=$(curl -Ns https://raw.githubusercontent.com/XIU2/TrackersListCollection/master/all.txt https://ngosang.github.io/trackerslist/trackers_all_http.txt https://newtrackon.com/api/all https://raw.githubusercontent.com/DeSireFire/animeTrackerList/master/AT_all.txt https://raw.githubusercontent.com/hezhijie0327/Trackerslist/main/trackerslist_tracker.txt https://raw.githubusercontent.com/hezhijie0327/Trackerslist/main/trackerslist_exclude.txt | awk '$0' | tr '\n\n' ',')
aria2c --enable-rpc --check-certificate=false \
--max-connection-per-server=10 --rpc-max-request-size=1024M --bt-max-peers=0 \
--bt-stop-timeout=1200 --min-split-size=10M --follow-torrent=mem --split=10 \
--bt-stop-timeout=0 --min-split-size=10M --follow-torrent=mem --split=10 \
--daemon=true --allow-overwrite=true --max-overall-download-limit=0 --bt-tracker="[$tracker_list]"\
--max-overall-upload-limit=1K --max-concurrent-downloads=15 --continue=true \
--peer-id-prefix=-qB4360- --user-agent=qBittorrent/4.3.6 --peer-agent=qBittorrent/4.3.6 \
Expand Down
35 changes: 18 additions & 17 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@

LOGGER = logging.getLogger(__name__)

CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL', None)
if CONFIG_FILE_URL is not None:
out = subprocess.run(["wget", "-q", "-O", "config.env", CONFIG_FILE_URL])
if out.returncode != 0:
logging.error(out)

load_dotenv('config.env')

alive = subprocess.Popen(["python3", "alive.py"])

Interval = []


Expand Down Expand Up @@ -73,7 +81,7 @@ def get_client() -> qba.TorrentsAPIMixIn:
qb_client = qba.Client(host="localhost", port=8090, username="admin", password="adminadmin")
try:
qb_client.auth_log_in()
qb_client.application.set_preferences({"disk_cache":64, "incomplete_files_ext":True, "max_connec":3000, "max_connec_per_torrent":300, "async_io_threads":32, "preallocate_all":True, "upnp":True, "dl_limit":-1, "up_limit":-1, "dht":True, "pex":True, "lsd":True, "encryption":0, "queueing_enabled":True, "max_active_downloads":15, "max_active_torrents":50, "dont_count_slow_torrents":True, "bittorrent_protocol":0, "recheck_completed_torrents":True, "enable_multi_connections_from_same_ip":True, "slow_torrent_dl_rate_threshold":100,"slow_torrent_inactive_timer":600})
#qb_client.application.set_preferences({"disk_cache":64, "incomplete_files_ext":True, "max_connec":3000, "max_connec_per_torrent":300, "async_io_threads":8, "preallocate_all":True, "upnp":True, "dl_limit":-1, "up_limit":-1, "dht":True, "pex":True, "lsd":True, "encryption":0, "queueing_enabled":True, "max_active_downloads":15, "max_active_torrents":50, "dont_count_slow_torrents":True, "bittorrent_protocol":0, "recheck_completed_torrents":True, "enable_multi_connections_from_same_ip":True, "slow_torrent_dl_rate_threshold":100,"slow_torrent_inactive_timer":600})
return qb_client
except qba.LoginFailed as e:
LOGGER.error(str(e))
Expand Down Expand Up @@ -129,8 +137,6 @@ def get_client() -> qba.TorrentsAPIMixIn:
AUTO_DELETE_MESSAGE_DURATION = int(getConfig('AUTO_DELETE_MESSAGE_DURATION'))
TELEGRAM_API = getConfig('TELEGRAM_API')
TELEGRAM_HASH = getConfig('TELEGRAM_HASH')
UPSTREAM_REPO = getConfig('UPSTREAM_REPO')
UPSTREAM_BRANCH = getConfig('UPSTREAM_BRANCH')
except KeyError as e:
LOGGER.error("One or more env variables missing! Exiting now")
exit(1)
Expand Down Expand Up @@ -196,13 +202,12 @@ def get_client() -> qba.TorrentsAPIMixIn:
MEGA_PASSWORD = None
try:
HEROKU_API_KEY = getConfig('HEROKU_API_KEY')
except KeyError:
logging.warning('HEROKU API KEY not provided!')
HEROKU_API_KEY = None
try:
HEROKU_APP_NAME = getConfig('HEROKU_APP_NAME')
if len(HEROKU_API_KEY) == 0 or len(HEROKU_APP_NAME) == 0:
HEROKU_API_KEY = None
HEROKU_APP_NAME = None
except KeyError:
logging.warning('HEROKU APP NAME not provided!')
HEROKU_API_KEY = None
HEROKU_APP_NAME = None
try:
UPTOBOX_TOKEN = getConfig('UPTOBOX_TOKEN')
Expand Down Expand Up @@ -319,22 +324,21 @@ def get_client() -> qba.TorrentsAPIMixIn:
except KeyError:
SHORTENER = None
SHORTENER_API = None

IGNORE_PENDING_REQUESTS = False
try:
if getConfig("IGNORE_PENDING_REQUESTS").lower() == "true":
IGNORE_PENDING_REQUESTS = getConfig("IGNORE_PENDING_REQUESTS")
if IGNORE_PENDING_REQUESTS.lower() == 'true':
IGNORE_PENDING_REQUESTS = True
else:
IGNORE_PENDING_REQUESTS = False
except KeyError:
pass

IGNORE_PENDING_REQUESTS = False
try:
BASE_URL = getConfig('BASE_URL_OF_BOT')
if len(BASE_URL) == 0:
BASE_URL = None
except KeyError:
logging.warning('BASE_URL_OF_BOT not provided!')
BASE_URL = None

try:
IS_VPS = getConfig('IS_VPS')
if IS_VPS.lower() == 'true':
Expand All @@ -343,15 +347,13 @@ def get_client() -> qba.TorrentsAPIMixIn:
IS_VPS = False
except KeyError:
IS_VPS = False

try:
SERVER_PORT = getConfig('SERVER_PORT')
if len(SERVER_PORT) == 0:
SERVER_PORT = None
except KeyError:
logging.warning('SERVER_PORT not provided!')
SERVER_PORT = None

try:
TOKEN_PICKLE_URL = getConfig('TOKEN_PICKLE_URL')
if len(TOKEN_PICKLE_URL) == 0:
Expand All @@ -362,7 +364,6 @@ def get_client() -> qba.TorrentsAPIMixIn:
logging.error(out)
except KeyError:
TOKEN_PICKLE_URL = None

try:
ACCOUNTS_ZIP_URL = getConfig('ACCOUNTS_ZIP_URL')
if len(ACCOUNTS_ZIP_URL) == 0:
Expand Down
9 changes: 3 additions & 6 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

from pyrogram import idle
from bot import app
from bot import app, alive
from sys import executable

from telegram import ParseMode
Expand All @@ -15,7 +15,7 @@
from .helper.ext_utils.bot_utils import get_readable_file_size, get_readable_time
from .helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper import button_build
from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, torrent_search, delete, speedtest, count, config, updates
from .modules import authorize, list, cancel_mirror, mirror_status, mirror, clone, watch, shell, eval, torrent_search, delete, speedtest, count, reboot


def stats(update, context):
Expand Down Expand Up @@ -68,6 +68,7 @@ def restart(update, context):
f.truncate(0)
f.write(f"{restart_message.chat.id}\n{restart_message.message_id}\n")
fs_utils.clean_all()
alive.terminate()
os.execl(executable, executable, "-m", "bot")


Expand Down Expand Up @@ -130,10 +131,6 @@ def bot_help(update, context):
/{BotCommands.LogCommand}: Get a log file of the bot. Handy for getting crash reports
/{BotCommands.ConfigMenuCommand}: Get Info Menu about bot config (Owner Only)
/{BotCommands.UpdateCommand}: Update Bot from Upstream Repo (Owner Only)
/{BotCommands.SpeedCommand}: Check Internet Speed of the Host
/{BotCommands.ShellCommand}: Run commands in Shell (Terminal)
Expand Down
24 changes: 0 additions & 24 deletions bot/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,3 @@ async def heroku_cli(client, message):
await func(client, message, heroku_app)

return heroku_cli

# Preparing For Update Bot
# Implement by https://github.com/jusidama18 and Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/updater.py

def fetch_heroku_git_url(api_key, app_name):
if not api_key:
return None
if not app_name:
return None
heroku = heroku3.from_key(api_key)
try:
heroku_applications = heroku.apps()
except:
return None
heroku_app = None
for app in heroku_applications:
if app.name == app_name:
heroku_app = app
break
if not heroku_app:
return None
return heroku_app.git_url.replace("https://", "https://api:" + api_key + "@")

HEROKU_URL = fetch_heroku_git_url(HEROKU_API_KEY, HEROKU_APP_NAME)
4 changes: 2 additions & 2 deletions bot/helper/mirror_utils/download_utils/qbit_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def update(self):
tor_info = tor_info[0]
if tor_info.state == "metaDL":
self.stalled_time = time.time()
if time.time() - self.meta_time >= 600:
if time.time() - self.meta_time >= 999999999: # timeout while downloading metadata
self.listener.onDownloadError("Dead Torrent!")
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
self.client.auth_log_out()
Expand All @@ -162,7 +162,7 @@ def update(self):
self.updater.cancel()
return
elif tor_info.state == "stalledDL":
if time.time() - self.stalled_time >= 900:
if time.time() - self.stalled_time >= 999999999: # timeout after downloading metadata
self.listener.onDownloadError("Dead Torrent!")
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
self.client.auth_log_out()
Expand Down
1 change: 0 additions & 1 deletion bot/helper/telegram_helper/bot_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __init__(self):
self.TarWatchCommand = 'tarwatch'
self.DeleteCommand = 'del'
self.ShellCommand = 'shell'
self.UpdateCommand = 'update'
self.ExecHelpCommand = 'exechelp'
self.TsHelpCommand = 'tshelp'

Expand Down
Loading

0 comments on commit ccda460

Please sign in to comment.