- Added option to block mega folder support
This commit is contained in:
Hafitz Setya 2021-03-10 08:46:46 +07:00 committed by GitHub
parent c07b135e12
commit 1d809560d5
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 21 deletions

View File

@ -82,6 +82,10 @@
"description": "Your password for your mega.nz account.",
"required": false
},
"BLOCK_MEGA_FOLDER": {
"description": "If you want to remove mega.nz folder support, set it to True.",
"required": false
},
"BLOCK_MEGA_LINKS": {
"description": "If you want to remove mega.nz mirror support, set it to True.",
"required": false

View File

@ -194,6 +194,14 @@ try:
USE_SERVICE_ACCOUNTS = False
except KeyError:
USE_SERVICE_ACCOUNTS = False
try:
BLOCK_MEGA_FOLDER = getConfig('BLOCK_MEGA_FOLDER')
if BLOCK_MEGA_FOLDER.lower() == 'true':
BLOCK_MEGA_FOLDER = True
else:
BLOCK_MEGA_FOLDER = False
except KeyError:
BLOCK_MEGA_FOLDER = False
try:
BLOCK_MEGA_LINKS = getConfig('BLOCK_MEGA_LINKS')
if BLOCK_MEGA_LINKS.lower() == 'true':

View File

@ -104,8 +104,8 @@ def get_readable_message():
msg += f"\n<b>Speed :</b> {download.speed()}, \n<b>ETA:</b> {download.eta()} "
# if hasattr(download, 'is_torrent'):
try:
msg += f"\n<b>Info:- Seeders:</b> {download.aria_download().num_seeders}" \
f" & <b>Peers :</b> {download.aria_download().connections}"
msg += f"\n<b>Seeders:</b> {download.aria_download().num_seeders}" \
f" | <b>Peers:</b> {download.aria_download().connections}"
except:
pass
if download.status() == MirrorStatus.STATUS_DOWNLOADING:

View File

@ -68,9 +68,9 @@ def delete_all_messages():
def update_all_messages():
msg = get_readable_message()
msg += f"<b>CPU:</b> {psutil.cpu_percent()}%" \
f" <b>DISK:</b> {psutil.disk_usage('/').percent}%" \
f" <b>RAM:</b> {psutil.virtual_memory().percent}%"
msg += f"<b>CPU:</b> {psutil.cpu_percent()}%\n" \
f"<b>RAM:</b> {psutil.virtual_memory().percent}%\n" \
f"<b>DISK:</b> {psutil.disk_usage('/').percent}%\n"
with download_dict_lock:
dlspeed_bytes = 0
uldl_bytes = 0
@ -88,7 +88,7 @@ def update_all_messages():
uldl_bytes += float(speedy.split('M')[0]) * 1048576
dlspeed = get_readable_file_size(dlspeed_bytes)
ulspeed = get_readable_file_size(uldl_bytes)
msg += f"\n<b>DL:</b> {dlspeed}ps 🔻| <b>UL:</b> {ulspeed}ps 🔺\n"
msg += f"\n<b>DL:</b> {dlspeed}ps | <b>UL:</b> {ulspeed}ps \n"
with status_reply_dict_lock:
for chat_id in list(status_reply_dict.keys()):
if status_reply_dict[chat_id] and msg != status_reply_dict[chat_id].text:
@ -104,9 +104,9 @@ def update_all_messages():
def sendStatusMessage(msg, bot):
progress = get_readable_message()
progress += f"<b>CPU:</b> {psutil.cpu_percent()}%" \
f" <b>DISK:</b> {psutil.disk_usage('/').percent}%" \
f" <b>RAM:</b> {psutil.virtual_memory().percent}%"
progress += f"<b>CPU:</b> {psutil.cpu_percent()}%\n" \
f"<b>RAM:</b> {psutil.virtual_memory().percent}%\n" \
f"<b>DISK:</b> {psutil.disk_usage('/').percent}%\n"
with download_dict_lock:
dlspeed_bytes = 0
uldl_bytes = 0
@ -124,7 +124,7 @@ def sendStatusMessage(msg, bot):
uldl_bytes += float(speedy.split('M')[0]) * 1048576
dlspeed = get_readable_file_size(dlspeed_bytes)
ulspeed = get_readable_file_size(uldl_bytes)
progress += f"\n<b>DL:</b>{dlspeed}ps 🔻| <b>UL:</b>{ulspeed}ps 🔺\n"
progress += f"\n<b>DL: </b>{dlspeed}ps | <b>UL: </b>{ulspeed}ps \n"
with status_reply_dict_lock:
if msg.message.chat.id in list(status_reply_dict.keys()):
try:

View File

@ -2,10 +2,10 @@ import requests
from telegram.ext import CommandHandler, run_async
from telegram import InlineKeyboardMarkup
from bot import Interval, INDEX_URL, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BLOCK_MEGA_LINKS
from bot import Interval, INDEX_URL, BUTTON_THREE_NAME, BUTTON_THREE_URL, BUTTON_FOUR_NAME, BUTTON_FOUR_URL, BUTTON_FIVE_NAME, BUTTON_FIVE_URL, BLOCK_MEGA_LINKS, BLOCK_MEGA_FOLDER
from bot import dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock, SHORTENER, SHORTENER_API
from bot.helper.ext_utils import fs_utils, bot_utils
from bot.helper.ext_utils.bot_utils import setInterval
from bot.helper.ext_utils.bot_utils import setInterval, get_mega_link_type
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException, NotSupportedExtractionArchive
from bot.helper.mirror_utils.download_utils.aria2_download import AriaDownloadHelper
from bot.helper.mirror_utils.download_utils.mega_downloader import MegaDownloadHelper
@ -238,7 +238,10 @@ def _mirror(bot, update, isTar=False, extract=False):
listener = MirrorListener(bot, update, isTar, tag, extract)
if bot_utils.is_mega_link(link):
if BLOCK_MEGA_LINKS:
link_type = get_mega_link_type(link)
if link_type == "folder" and BLOCK_MEGA_FOLDER:
sendMessage("Mega folder are blocked!", bot, update)
elif BLOCK_MEGA_LINKS:
sendMessage("Mega links are blocked bcoz mega downloading is too much unstable and buggy. mega support will be added back after fix", bot, update)
else:
mega_dl = MegaDownloadHelper()

View File

@ -19,6 +19,7 @@ UPTOBOX_TOKEN = ""
MEGA_API_KEY = ""
MEGA_EMAIL_ID = ""
MEGA_PASSWORD = ""
BLOCK_MEGA_FOLDER = ""
BLOCK_MEGA_LINKS = ""
STOP_DUPLICATE_MIRROR = ""
SHORTENER = ""