Skip to content

Commit

Permalink
Minor fixex
Browse files Browse the repository at this point in the history
- Fix queue force

Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Jan 28, 2024
1 parent 41bac13 commit 515702f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
1 change: 0 additions & 1 deletion bot/helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def __init__(self):
self.rcFlags = ""
self.tag = ""
self.name = ""
self.session = ""
self.newDir = ""
self.splitSize = 0
self.maxSplitSize = 0
Expand Down
6 changes: 2 additions & 4 deletions bot/helper/ext_utils/media_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ async def convert_video(listener, video_file, ext, retry=False):
"libx264",
"-c:a",
"aac",
"-map",
"0",
"-threads",
f"{cpu_count() // 2}",
output,
Expand All @@ -34,6 +32,8 @@ async def convert_video(listener, video_file, ext, retry=False):
cmd[7:7] = ["-c:s", "mov_text"]
elif ext == "mkv":
cmd[7:7] = ["-c:s", "ass"]
else:
cmd[7:7] = ["-c:s", "copy"]
else:
cmd = ["ffmpeg", "-i", video_file, "-map", "0", "-c", "copy", output]
if listener.cancelled:
Expand Down Expand Up @@ -67,8 +67,6 @@ async def convert_audio(listener, audio_file, ext):
"ffmpeg",
"-i",
audio_file,
"-map",
"0",
"-threads",
f"{cpu_count() // 2}",
output,
Expand Down
1 change: 1 addition & 0 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def get_readable_message(sid, is_user, page_no=1, status="All", page_step=1):
MirrorStatus.STATUS_SEEDING,
MirrorStatus.STATUS_SAMVID,
MirrorStatus.STATUS_CONVERTING,
MirrorStatus.STATUS_QUEUEUP,
]:
msg += f"\n{get_progress_bar_string(task.progress())} {task.progress()}"
msg += f"\n<b>Processed:</b> {task.processed_bytes()} of {task.size()}"
Expand Down
6 changes: 5 additions & 1 deletion bot/helper/listeners/task_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ async def onDownloadComplete(self):
self.size = await get_path_size(up_dir)

if self.compress:
up_path = await self.proceedCompress(up_path, gid, unwanted_files, files_to_delete)
up_path = await self.proceedCompress(
up_path, gid, unwanted_files, files_to_delete
)
if self.cancelled:
return

Expand All @@ -196,6 +198,8 @@ async def onDownloadComplete(self):
return
LOGGER.info(f"Start from Queued/Upload: {self.name}")
async with queue_dict_lock:
if self.mid in non_queued_dl:
non_queued_dl.remove(self.mid)
non_queued_up.add(self.mid)

if self.isLeech:
Expand Down
17 changes: 8 additions & 9 deletions bot/helper/mirror_utils/download_utils/telegram_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, listener):
self._start_time = time()
self._listener = listener
self._id = ""
self.session = ""
self._is_cancelled = False

@property
Expand Down Expand Up @@ -55,7 +56,7 @@ async def _onDownloadStart(self, file_id, from_queue):

async def _onDownloadProgress(self, current, total):
if self._is_cancelled:
if self._listener.session == "user":
if self.session == "user":
user.stop_transmission()
else:
bot.stop_transmission()
Expand Down Expand Up @@ -91,17 +92,15 @@ async def _download(self, message, path):
elif not self._is_cancelled:
await self._onDownloadError("Internal error occurred")

async def add_download(self, message, path):
if (
self._listener.session not in ["user", "bot"]
and self._listener.userTransmission
):
self._listener.session = "user"
async def add_download(self, message, path, session):
self.session = session
if self.session not in ["user", "bot"] and self._listener.userTransmission:
self.session.session = "user"
message = await user.get_messages(
chat_id=message.chat.id, message_ids=message.id
)
elif self._listener.session != "user":
self._listener.session = "bot"
elif self.session != "user":
self.session = "bot"

media = (
message.document
Expand Down
5 changes: 3 additions & 2 deletions bot/modules/mirror_leech.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ async def newEvent(self):
seed_time = None
reply_to = None
file_ = None
session = ""

try:
self.multi = int(args["-i"])
Expand Down Expand Up @@ -185,7 +186,7 @@ async def newEvent(self):
self.link = reply_to.text.split("\n", 1)[0].strip()
if is_telegram_link(self.link):
try:
reply_to, self.session = await get_tg_link_message(self.link)
reply_to, session = await get_tg_link_message(self.link)
except Exception as e:
await sendMessage(self.message, f"ERROR: {e}")
self.removeFromSameDir()
Expand Down Expand Up @@ -299,7 +300,7 @@ async def newEvent(self):
return

if file_ is not None:
await TelegramDownloadHelper(self).add_download(reply_to, f"{path}/")
await TelegramDownloadHelper(self).add_download(reply_to, f"{path}/", session)
elif isinstance(self.link, dict):
await add_direct_download(self, path)
elif self.isJd:
Expand Down
4 changes: 4 additions & 0 deletions bot/modules/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ async def status_pages(_, query):
"CheckUp": 0,
"Pause": 0,
"SamVid": 0,
"ConvertMedia": 0
}
dl_speed = 0
up_speed = 0
Expand Down Expand Up @@ -129,13 +130,16 @@ async def status_pages(_, query):
tasks["Pause"] += 1
case MirrorStatus.STATUS_SAMVID:
tasks["SamVid"] += 1
case MirrorStatus.STATUS_CONVERTING:
tasks["ConvertMedia"] += 1
case _:
tasks["Download"] += 1
dl_speed += speed_string_to_bytes(download.speed())

msg = f"""DL: {tasks['Download']} | UP: {tasks['Upload']} | SD: {tasks['Seed']} | AR: {tasks['Archive']}
EX: {tasks['Extract']} | SP: {tasks['Split']} | QD: {tasks['QueueDl']} | QU: {tasks['QueueUp']}
CL: {tasks['Clone']} | CH: {tasks['CheckUp']} | PA: {tasks['Pause']} | SV: {tasks['SamVid']}
CM: {tasks['ConvertMedia']}
ODLS: {get_readable_file_size(dl_speed)}/s
OULS: {get_readable_file_size(up_speed)}/s
Expand Down

0 comments on commit 515702f

Please sign in to comment.