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

Commit ccda460

Browse files
vincreatoranasty17
andcommitted
v4.9.1
- Change docker name - Use qbittorrent config file - Fixing Co-authored-by: anas <e.anastayyar@gmail.com>
1 parent dc41314 commit ccda460

File tree

16 files changed

+103
-392
lines changed

16 files changed

+103
-392
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM vincreator/eunha-sdk-python:latest
1+
FROM vincreator/eunhamirror:latest
22

33
WORKDIR /usr/src/app
44
RUN chmod 777 /usr/src/app
@@ -10,6 +10,7 @@ COPY extract /usr/local/bin
1010
COPY pextract /usr/local/bin
1111
RUN chmod +x /usr/local/bin/extract && chmod +x /usr/local/bin/pextract
1212
COPY . .
13+
COPY qBittorrent.conf ./.config/qBittorrent/qBittorrent.conf
1314
COPY .netrc /root/.netrc
1415
RUN chmod 600 /usr/src/app/.netrc
1516
RUN chmod +x aria.sh

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ sudo apt install python3
107107
```
108108
Install Docker by following the [official Docker docs](https://docs.docker.com/engine/install/debian/)
109109

110+
OR
111+
```
112+
sudo snap install docker
113+
```
110114
- For Arch and it's derivatives:
111115
```
112116
sudo pacman -S docker python
@@ -160,8 +164,6 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
160164
- **DOWNLOAD_DIR**: The path to the local folder where the downloads should be downloaded to
161165
- **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)
162166
- **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)
163-
- **UPSTREAM_REPO**: Link for Bot Upstream Repo, if you want default update, fill `https://github.com/vincreator/Eunha-Mirror-bot`.
164-
- **UPSTREAM_BRANCH**: Branch name for Bot Upstream Repo, fill `master`.
165167
### Optional Field
166168
- **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.
167169
- **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.
@@ -188,9 +190,9 @@ Fill up rest of the fields. Meaning of each fields are discussed below:
188190
- **HEROKU_APP_NAME**: (Only if you deploying on Heroku) Your Heroku app name.
189191
- **IGNORE_PENDING_REQUESTS**: If you want the bot to ignore pending requests after it restarts, set this to `True`.
190192
- **STATUS_LIMIT**: Status limit with buttons (**NOTE**: Recommend limit status to `4` tasks max).
191-
- **IS_VPS**: Set it to `True` if you use VPS
192-
- **SERVER_PORT**: Your VPS port
193-
- **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`.
193+
- **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.
194+
- **SERVER_PORT**: (Only if IS_VPS is `True`) Base URL Port
195+
- **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)
194196
- **SHORTENER_API**: Fill your Shortener api key if you are using Shortener.
195197
- **SHORTENER**: if you want to use Shortener in Gdrive and index link, fill Shortener url here. Examples:
196198
```

alive.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
import time
66
import requests
77
import os
8-
import subprocess
9-
from dotenv import load_dotenv
10-
11-
CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL', None)
12-
if CONFIG_FILE_URL is not None:
13-
out = subprocess.run(["wget", "-q", "-O", "config.env", CONFIG_FILE_URL])
14-
15-
load_dotenv('config.env')
168

179
BASE_URL = os.environ.get('BASE_URL_OF_BOT', None)
1810
if len(BASE_URL) == 0:

aria.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
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' ',')
22
aria2c --enable-rpc --check-certificate=false \
33
--max-connection-per-server=10 --rpc-max-request-size=1024M --bt-max-peers=0 \
4-
--bt-stop-timeout=1200 --min-split-size=10M --follow-torrent=mem --split=10 \
4+
--bt-stop-timeout=0 --min-split-size=10M --follow-torrent=mem --split=10 \
55
--daemon=true --allow-overwrite=true --max-overall-download-limit=0 --bt-tracker="[$tracker_list]"\
66
--max-overall-upload-limit=1K --max-concurrent-downloads=15 --continue=true \
77
--peer-id-prefix=-qB4360- --user-agent=qBittorrent/4.3.6 --peer-agent=qBittorrent/4.3.6 \

bot/__init__.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@
3333

3434
LOGGER = logging.getLogger(__name__)
3535

36+
CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL', None)
37+
if CONFIG_FILE_URL is not None:
38+
out = subprocess.run(["wget", "-q", "-O", "config.env", CONFIG_FILE_URL])
39+
if out.returncode != 0:
40+
logging.error(out)
41+
3642
load_dotenv('config.env')
3743

44+
alive = subprocess.Popen(["python3", "alive.py"])
45+
3846
Interval = []
3947

4048

@@ -73,7 +81,7 @@ def get_client() -> qba.TorrentsAPIMixIn:
7381
qb_client = qba.Client(host="localhost", port=8090, username="admin", password="adminadmin")
7482
try:
7583
qb_client.auth_log_in()
76-
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})
84+
#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})
7785
return qb_client
7886
except qba.LoginFailed as e:
7987
LOGGER.error(str(e))
@@ -129,8 +137,6 @@ def get_client() -> qba.TorrentsAPIMixIn:
129137
AUTO_DELETE_MESSAGE_DURATION = int(getConfig('AUTO_DELETE_MESSAGE_DURATION'))
130138
TELEGRAM_API = getConfig('TELEGRAM_API')
131139
TELEGRAM_HASH = getConfig('TELEGRAM_HASH')
132-
UPSTREAM_REPO = getConfig('UPSTREAM_REPO')
133-
UPSTREAM_BRANCH = getConfig('UPSTREAM_BRANCH')
134140
except KeyError as e:
135141
LOGGER.error("One or more env variables missing! Exiting now")
136142
exit(1)
@@ -196,13 +202,12 @@ def get_client() -> qba.TorrentsAPIMixIn:
196202
MEGA_PASSWORD = None
197203
try:
198204
HEROKU_API_KEY = getConfig('HEROKU_API_KEY')
199-
except KeyError:
200-
logging.warning('HEROKU API KEY not provided!')
201-
HEROKU_API_KEY = None
202-
try:
203205
HEROKU_APP_NAME = getConfig('HEROKU_APP_NAME')
206+
if len(HEROKU_API_KEY) == 0 or len(HEROKU_APP_NAME) == 0:
207+
HEROKU_API_KEY = None
208+
HEROKU_APP_NAME = None
204209
except KeyError:
205-
logging.warning('HEROKU APP NAME not provided!')
210+
HEROKU_API_KEY = None
206211
HEROKU_APP_NAME = None
207212
try:
208213
UPTOBOX_TOKEN = getConfig('UPTOBOX_TOKEN')
@@ -319,22 +324,21 @@ def get_client() -> qba.TorrentsAPIMixIn:
319324
except KeyError:
320325
SHORTENER = None
321326
SHORTENER_API = None
322-
323-
IGNORE_PENDING_REQUESTS = False
324327
try:
325-
if getConfig("IGNORE_PENDING_REQUESTS").lower() == "true":
328+
IGNORE_PENDING_REQUESTS = getConfig("IGNORE_PENDING_REQUESTS")
329+
if IGNORE_PENDING_REQUESTS.lower() == 'true':
326330
IGNORE_PENDING_REQUESTS = True
331+
else:
332+
IGNORE_PENDING_REQUESTS = False
327333
except KeyError:
328-
pass
329-
334+
IGNORE_PENDING_REQUESTS = False
330335
try:
331336
BASE_URL = getConfig('BASE_URL_OF_BOT')
332337
if len(BASE_URL) == 0:
333338
BASE_URL = None
334339
except KeyError:
335340
logging.warning('BASE_URL_OF_BOT not provided!')
336341
BASE_URL = None
337-
338342
try:
339343
IS_VPS = getConfig('IS_VPS')
340344
if IS_VPS.lower() == 'true':
@@ -343,15 +347,13 @@ def get_client() -> qba.TorrentsAPIMixIn:
343347
IS_VPS = False
344348
except KeyError:
345349
IS_VPS = False
346-
347350
try:
348351
SERVER_PORT = getConfig('SERVER_PORT')
349352
if len(SERVER_PORT) == 0:
350353
SERVER_PORT = None
351354
except KeyError:
352355
logging.warning('SERVER_PORT not provided!')
353356
SERVER_PORT = None
354-
355357
try:
356358
TOKEN_PICKLE_URL = getConfig('TOKEN_PICKLE_URL')
357359
if len(TOKEN_PICKLE_URL) == 0:
@@ -362,7 +364,6 @@ def get_client() -> qba.TorrentsAPIMixIn:
362364
logging.error(out)
363365
except KeyError:
364366
TOKEN_PICKLE_URL = None
365-
366367
try:
367368
ACCOUNTS_ZIP_URL = getConfig('ACCOUNTS_ZIP_URL')
368369
if len(ACCOUNTS_ZIP_URL) == 0:

bot/__main__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
from pyrogram import idle
6-
from bot import app
6+
from bot import app, alive
77
from sys import executable
88

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

2020

2121
def stats(update, context):
@@ -68,6 +68,7 @@ def restart(update, context):
6868
f.truncate(0)
6969
f.write(f"{restart_message.chat.id}\n{restart_message.message_id}\n")
7070
fs_utils.clean_all()
71+
alive.terminate()
7172
os.execl(executable, executable, "-m", "bot")
7273

7374

@@ -130,10 +131,6 @@ def bot_help(update, context):
130131
131132
/{BotCommands.LogCommand}: Get a log file of the bot. Handy for getting crash reports
132133
133-
/{BotCommands.ConfigMenuCommand}: Get Info Menu about bot config (Owner Only)
134-
135-
/{BotCommands.UpdateCommand}: Update Bot from Upstream Repo (Owner Only)
136-
137134
/{BotCommands.SpeedCommand}: Check Internet Speed of the Host
138135
139136
/{BotCommands.ShellCommand}: Run commands in Shell (Terminal)

bot/helper/__init__.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,3 @@ async def heroku_cli(client, message):
2828
await func(client, message, heroku_app)
2929

3030
return heroku_cli
31-
32-
# Preparing For Update Bot
33-
# Implement by https://github.com/jusidama18 and Based on this https://github.com/DevsExpo/FridayUserbot/blob/master/plugins/updater.py
34-
35-
def fetch_heroku_git_url(api_key, app_name):
36-
if not api_key:
37-
return None
38-
if not app_name:
39-
return None
40-
heroku = heroku3.from_key(api_key)
41-
try:
42-
heroku_applications = heroku.apps()
43-
except:
44-
return None
45-
heroku_app = None
46-
for app in heroku_applications:
47-
if app.name == app_name:
48-
heroku_app = app
49-
break
50-
if not heroku_app:
51-
return None
52-
return heroku_app.git_url.replace("https://", "https://api:" + api_key + "@")
53-
54-
HEROKU_URL = fetch_heroku_git_url(HEROKU_API_KEY, HEROKU_APP_NAME)

bot/helper/mirror_utils/download_utils/qbit_downloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def update(self):
137137
tor_info = tor_info[0]
138138
if tor_info.state == "metaDL":
139139
self.stalled_time = time.time()
140-
if time.time() - self.meta_time >= 600:
140+
if time.time() - self.meta_time >= 999999999: # timeout while downloading metadata
141141
self.listener.onDownloadError("Dead Torrent!")
142142
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
143143
self.client.auth_log_out()
@@ -162,7 +162,7 @@ def update(self):
162162
self.updater.cancel()
163163
return
164164
elif tor_info.state == "stalledDL":
165-
if time.time() - self.stalled_time >= 900:
165+
if time.time() - self.stalled_time >= 999999999: # timeout after downloading metadata
166166
self.listener.onDownloadError("Dead Torrent!")
167167
self.client.torrents_delete(torrent_hashes=self.ext_hash, delete_files=True)
168168
self.client.auth_log_out()

bot/helper/telegram_helper/bot_commands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def __init__(self):
2626
self.TarWatchCommand = 'tarwatch'
2727
self.DeleteCommand = 'del'
2828
self.ShellCommand = 'shell'
29-
self.UpdateCommand = 'update'
3029
self.ExecHelpCommand = 'exechelp'
3130
self.TsHelpCommand = 'tshelp'
3231

0 commit comments

Comments
 (0)