Add set default rclone path from selection

- Fix same directory feautre with too many links
- fix other minor bugs
close #1467

Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
anasty17 2023-05-25 03:48:54 +03:00
parent b476dcb0e9
commit f4bd6e4c5e
6 changed files with 35 additions and 14 deletions

View File

@ -36,7 +36,7 @@ QbTorrents = {}
DRIVES_NAMES = []
DRIVES_IDS = []
INDEX_URLS = []
GLOBAL_EXTENSION_FILTER = ['aria2']
GLOBAL_EXTENSION_FILTER = ['aria2', '!qB']
user_data = {}
aria2_options = {}
qbit_options = {}

View File

@ -8,7 +8,7 @@ from asyncio import create_subprocess_exec, sleep, Event
from bot import Interval, aria2, DOWNLOAD_DIR, download_dict, download_dict_lock, LOGGER, DATABASE_URL, \
MAX_SPLIT_SIZE, config_dict, status_reply_dict_lock, user_data, non_queued_up, non_queued_dl, queued_up, \
queued_dl, queue_dict_lock
queued_dl, queue_dict_lock, GLOBAL_EXTENSION_FILTER
from bot.helper.ext_utils.bot_utils import sync_to_async, get_readable_file_size
from bot.helper.ext_utils.fs_utils import get_base_name, get_path_size, clean_download, clean_target, \
is_first_archive_split, is_archive, is_archive_split
@ -69,7 +69,12 @@ class MirrorLeechListener:
async def onDownloadComplete(self):
if len(self.sameDir) > 0:
await sleep(8)
await sleep(3)
for _ in range(10):
if len(self.sameDir) > 1:
break
else:
await sleep(1)
multi_links = False
async with download_dict_lock:
if len(self.sameDir) > 1:
@ -118,6 +123,9 @@ class MirrorLeechListener:
'split_size', False) or config_dict['LEECH_SPLIT_SIZE']
cmd = ["7z", f"-v{LEECH_SPLIT_SIZE}b", "a",
"-mx=0", f"-p{self.pswd}", path, m_path]
for ext in GLOBAL_EXTENSION_FILTER:
ex_ext = f'-x!*.{ext}'
cmd.append(ex_ext)
if self.isLeech and int(size) > LEECH_SPLIT_SIZE:
if self.pswd is None:
del cmd[4]

View File

@ -9,7 +9,8 @@ from functools import partial
from json import loads
from time import time
from bot import LOGGER
from bot import LOGGER, config_dict
from bot.helper.ext_utils.db_handler import DbManger
from bot.helper.telegram_helper.button_build import ButtonMaker
from bot.helper.telegram_helper.message_utils import sendMessage, editMessage
from bot.helper.ext_utils.bot_utils import cmd_exec, new_thread, get_readable_file_size, new_task, get_readable_time
@ -70,6 +71,13 @@ async def path_updates(client, query, obj):
elif data[1] == 'cur':
await message.delete()
obj.event.set()
elif data[1] == 'def':
path = f'{obj.remote}{obj.path}' if obj.config_path == 'rclone.conf' else f'mrcc:{obj.remote}{obj.path}'
if path != config_dict['RCLONE_PATH']:
config_dict['RCLONE_PATH'] = path
await obj.get_path_buttons()
if config_dict['DATABASE_URL']:
await DbManger().update_config({'RCLONE_PATH': path})
elif data[1] == 'owner':
obj.config_path = 'rclone.conf'
obj.path = ''
@ -162,6 +170,9 @@ class RcloneList:
if self.list_status == 'rcu' or len(self.path_list) > 0:
buttons.ibutton('Choose Current Path',
'rcq cur', position='footer')
if self.list_status == 'rcu':
buttons.ibutton('Set as Default Path',
'rcq def', position='footer')
if self.path or len(self.__sections) > 1 or self.__rc_user and self.__rc_owner:
buttons.ibutton('Back', 'rcq back pa', position='footer')
if self.path:
@ -170,6 +181,9 @@ class RcloneList:
button = buttons.build_menu(f_cols=2)
msg = 'Choose Path:' + ('\nTransfer Type: <i>Download</i>' if self.list_status ==
'rcd' else '\nTransfer Type: <i>Upload</i>')
if self.list_status == 'rcu':
default_path = config_dict['RCLONE_PATH']
msg += f"\nDefault Rclone Path: {default_path}" if default_path else ''
msg += f'\n\nItems: {items_no}'
if items_no > LIST_LIMIT:
msg += f' | Page: {int(page)}/{pages} | Page Step: {self.page_step}'

View File

@ -174,16 +174,15 @@ async def clone(client, message):
tag = message.from_user.mention
if len(args) > 1:
link = args[1].strip()
arg = args[1].strip()
if not link.startswith(('up:', 'rcf:')):
link = re_split(r' up: | rcf: ', link)[0].strip()
if link.isdigit():
if arg.isdigit():
multi = int(link)
link = ''
if reply_to := message.reply_to_message:
if len(link) == 0:
link = reply_to.text.split('\n', 1)[0].strip()
if len(link) == 0 and (reply_to := message.reply_to_message):
link = reply_to.text.split('\n', 1)[0].strip()
rcf = text.split(' rcf: ', 1)
rcf = re_split(' up: ', rcf[1])[0].strip() if len(rcf) > 1 else None
@ -206,7 +205,7 @@ async def clone(client, message):
__run_multi()
if not link:
if len(link) == 0:
await sendMessage(message, CLONE_HELP_MESSAGE)
return

View File

@ -26,7 +26,7 @@ from bot.helper.ext_utils.bulk_links import extract_bulk_links
@new_task
async def _mirror_leech(client, message, isZip=False, extract=False, isQbit=False, isLeech=False, sameDir={}, bulk=[]):
async def _mirror_leech(client, message, isZip=False, extract=False, isQbit=False, isLeech=False, sameDir=None, bulk=[]):
mesg = message.text.split('\n')
message_args = mesg[0].split(maxsplit=1)
ratio = None
@ -97,7 +97,7 @@ async def _mirror_leech(client, message, isZip=False, extract=False, isQbit=Fals
ratio = None
seed_time = None
if not is_bulk:
if not sameDir:
if sameDir is None:
sameDir = set()
sameDir.add(message.id)

View File

@ -239,7 +239,7 @@ async def _mdisk(link, name):
@new_task
async def _ytdl(client, message, isZip=False, isLeech=False, sameDir={}, bulk=[]):
async def _ytdl(client, message, isZip=False, isLeech=False, sameDir=None, bulk=[]):
mssg = message.text
user_id = message.from_user.id
qual = ''
@ -295,7 +295,7 @@ async def _ytdl(client, message, isZip=False, isLeech=False, sameDir={}, bulk=[]
0].strip()
if len(folder_name) > 0 and not is_bulk:
if not sameDir:
if sameDir is None:
sameDir = set()
sameDir.add(message.id)