Skip to content

Commit c15f83d

Browse files
committed
end of sync
1 parent 9694eea commit c15f83d

File tree

19 files changed

+175
-135
lines changed

19 files changed

+175
-135
lines changed

bot/core/config_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Config:
3535
HYBRID_LEECH: bool = False
3636
HYDRA_IP: str = ""
3737
HYDRA_API_KEY: str = ""
38-
NAME_SUBSTITUTE: str = ""
38+
NAME_SUBSTITUTE: str = r""
3939
OWNER_ID: int = 0
4040
QUEUE_ALL: int = 0
4141
QUEUE_DOWNLOAD: int = 0

bot/core/telegram_manager.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from asyncio import Lock
22

33
from pyrogram import Client, enums
4-
4+
from pyrogram.types import LinkPreviewOptions
55
from bot import LOGGER
66

77
from .config_manager import Config
@@ -29,6 +29,10 @@ async def start_bot(cls):
2929
workdir="/app",
3030
parse_mode=enums.ParseMode.HTML,
3131
max_concurrent_transmissions=100,
32+
max_message_cache_size=15000,
33+
max_topic_cache_size=15000,
34+
sleep_threshold=0,
35+
link_preview_options=LinkPreviewOptions(is_disabled=True),
3236
)
3337
await cls.bot.start()
3438
cls.NAME = cls.bot.me.username
@@ -44,9 +48,13 @@ async def start_user(cls):
4448
Config.TELEGRAM_HASH,
4549
proxy=Config.TG_PROXY,
4650
session_string=Config.USER_SESSION_STRING,
51+
workdir="/app",
4752
parse_mode=enums.ParseMode.HTML,
4853
no_updates=True,
4954
max_concurrent_transmissions=100,
55+
max_message_cache_size=15000,
56+
max_topic_cache_size=15000,
57+
link_preview_options=LinkPreviewOptions(is_disabled=True),
5058
)
5159
await cls.user.start()
5260
cls.IS_PREMIUM_USER = cls.user.me.is_premium

bot/helper/common.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self):
132132
self.is_file = False
133133
self.bot_trans = False
134134
self.user_trans = False
135+
self.is_rss = False
135136
self.progress = True
136137
self.ffmpeg_cmds = None
137138
self.chat_thread_id = None
@@ -450,6 +451,9 @@ async def before_start(self):
450451
except Exception:
451452
chat = None
452453
if chat is None:
454+
LOGGER.warning(
455+
"Account of user session can't find the the destination chat!"
456+
)
453457
self.user_transmission = False
454458
self.hybrid_leech = False
455459
else:
@@ -462,14 +466,23 @@ async def before_start(self):
462466
]:
463467
self.user_transmission = False
464468
self.hybrid_leech = False
465-
else:
466-
member = await chat.get_member(uploader_id)
469+
elif chat.is_admin:
470+
member = await chat.get_member(TgClient.user.me.id)
467471
if (
468472
not member.privileges.can_manage_chat
469473
or not member.privileges.can_delete_messages
470474
):
471475
self.user_transmission = False
472476
self.hybrid_leech = False
477+
LOGGER.warning(
478+
"Enable manage chat and delete messages to account of the user session from administration settings!"
479+
)
480+
else:
481+
LOGGER.warning(
482+
"Promote the account of the user session to admin in the chat to get the benefit of user transmission!"
483+
)
484+
self.user_transmission = False
485+
self.hybrid_leech = False
473486

474487
if not self.user_transmission or self.hybrid_leech:
475488
try:
@@ -482,23 +495,28 @@ async def before_start(self):
482495
else:
483496
raise ValueError("Chat not found!")
484497
else:
485-
uploader_id = self.client.me.id
486498
if chat.type.name in [
487499
"SUPERGROUP",
488500
"CHANNEL",
489501
"GROUP",
490502
"FORUM",
491503
]:
492-
member = await chat.get_member(uploader_id)
493-
if (
494-
not member.privileges.can_manage_chat
495-
or not member.privileges.can_delete_messages
496-
):
497-
if not self.user_transmission:
498-
raise ValueError(
499-
"You don't have enough privileges in this chat!",
500-
)
501-
self.hybrid_leech = False
504+
if not chat.is_admin:
505+
raise ValueError(
506+
"Bot is not admin in the destination chat!"
507+
)
508+
else:
509+
member = await chat.get_member(self.client.me.id)
510+
if (
511+
not member.privileges.can_manage_chat
512+
or not member.privileges.can_delete_messages
513+
):
514+
if not self.user_transmission:
515+
raise ValueError(
516+
"You don't have enough privileges in this chat! Enable manage chat and delete messages for this bot!"
517+
)
518+
else:
519+
self.hybrid_leech = False
502520
else:
503521
try:
504522
await self.client.send_chat_action(
@@ -632,6 +650,7 @@ def get_cleaned_value(value, default, allowed=None, to_lower=False):
632650

633651
async def get_tag(self, text: list):
634652
if len(text) > 1 and text[1].startswith("Tag: "):
653+
self.is_rss = True
635654
user_info = text[1].split("Tag: ")
636655
if len(user_info) >= 3:
637656
id_ = user_info[-1]
@@ -1014,6 +1033,8 @@ def perform_substitution(name, substitutions):
10141033
for substitution in substitutions:
10151034
sen = False
10161035
pattern = substitution[0]
1036+
if pattern.startswith('"') and pattern.endswith('"'):
1037+
pattern = pattern.strip('"')
10171038
if len(substitution) > 1:
10181039
if len(substitution) > 2:
10191040
sen = substitution[2] == "s"
@@ -1026,7 +1047,7 @@ def perform_substitution(name, substitutions):
10261047
res = ""
10271048
try:
10281049
name = sub(
1029-
rf"{pattern}",
1050+
pattern,
10301051
res,
10311052
name,
10321053
flags=IGNORECASE if sen else 0,

bot/helper/ext_utils/files_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ async def _sevenz_progress(self):
340340
except Exception:
341341
break
342342
line = line.decode().strip()
343+
if "%" in line:
344+
perc = line.split("%", 1)[0]
345+
if perc.isdigit():
346+
self._percentage = f"{perc}%"
347+
self._processed_bytes = (int(perc) / 100) * self._listener.subsize
348+
else:
349+
self._percentage = "0%"
350+
continue
343351
if match := re_search(pattern, line):
344352
self._listener.subsize = int(match[1] or match[2] or match[3])
345353
s = b""

bot/helper/ext_utils/media_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,11 @@ async def convert_video(self, video_file, ext, retry=False):
504504
output,
505505
]
506506
if ext == "mp4":
507-
cmd[14:14] = ["-c:s", "mov_text"]
507+
cmd[17:17] = ["-c:s", "mov_text"]
508508
elif ext == "mkv":
509-
cmd[14:14] = ["-c:s", "ass"]
509+
cmd[17:17] = ["-c:s", "ass"]
510510
else:
511-
cmd[14:14] = ["-c:s", "copy"]
511+
cmd[17:17] = ["-c:s", "copy"]
512512
else:
513513
cmd = [
514514
"taskset",
@@ -735,8 +735,8 @@ async def split(self, f_path, file_, parts, split_size):
735735
out_path,
736736
]
737737
if not multi_streams:
738-
del cmd[12]
739-
del cmd[12]
738+
del cmd[15]
739+
del cmd[15]
740740
if self._listener.is_cancelled:
741741
return False
742742
self._listener.subproc = await create_subprocess_exec(

bot/helper/listeners/task_listener.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ async def on_download_complete(self):
264264
self.clear()
265265

266266
if self.name_sub:
267+
LOGGER.info(f"Start Name Substitution {up_path}")
267268
up_path = await self.substitute(up_path)
268269
if self.is_cancelled:
269270
return

bot/helper/mirror_leech_utils/download_utils/aria2_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def add_aria2_download(listener, dpath, header, ratio, seed_time):
7171
LOGGER.info(f"Added to Queue/Download: {name}. Gid: {gid}")
7272
if (
7373
not listener.select or "bittorrent" not in download
74-
) and listener.multi <= 1:
74+
) and listener.multi <= 1 and not listener.is_rss:
7575
await send_status_message(listener.message)
7676
else:
7777
LOGGER.info(f"Aria2Download started: {name}. Gid: {gid}")
@@ -81,7 +81,7 @@ async def add_aria2_download(listener, dpath, header, ratio, seed_time):
8181
if (
8282
not add_to_queue
8383
and (not listener.select or not Config.BASE_URL)
84-
and listener.multi <= 1
84+
and listener.multi <= 1 and not listener.is_rss
8585
):
8686
await send_status_message(listener.message)
8787
elif listener.select and "bittorrent" in download and not is_metadata(download):

bot/helper/mirror_leech_utils/download_utils/direct_downloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def add_direct_download(listener, path):
3434
async with task_dict_lock:
3535
task_dict[listener.mid] = QueueStatus(listener, gid, "dl")
3636
await listener.on_download_start()
37-
if listener.multi <= 1:
37+
if listener.multi <= 1 and not listener.is_rss:
3838
await send_status_message(listener.message)
3939
await event.wait()
4040
if listener.is_cancelled:
@@ -54,7 +54,7 @@ async def add_direct_download(listener, path):
5454
else:
5555
LOGGER.info(f"Download from Direct Download: {listener.name}")
5656
await listener.on_download_start()
57-
if listener.multi <= 1:
57+
if listener.multi <= 1 and not listener.is_rss:
5858
await send_status_message(listener.message)
5959

6060
await directListener.download(contents)

bot/helper/mirror_leech_utils/download_utils/jd_download.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ async def add_jd_download(listener, path):
166166
)
167167

168168
await sleep(1)
169+
LOGGER.info(f"JDownloader Collecting Data: {listener.link}")
169170
while await jdownloader.device.linkgrabber.is_collecting():
170-
pass
171+
await sleep(0.5)
172+
LOGGER.info(f"JDownloader Finished Collecting Data: {listener.link}")
171173
start_time = time()
172174
online_packages = []
173175
corrupted_packages = []

bot/helper/mirror_leech_utils/download_utils/qbit_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async def add_qb_torrent(listener, path, ratio, seed_time):
111111
SBUTTONS = bt_selection_buttons(ext_hash)
112112
msg = "Your download paused. Choose files then press Done Selecting button to start downloading."
113113
await send_message(listener.message, msg, SBUTTONS)
114-
elif listener.multi <= 1:
114+
elif listener.multi <= 1 and not listener.is_rss:
115115
await send_status_message(listener.message)
116116

117117
if event is not None:

0 commit comments

Comments
 (0)