From 7f9855f13c7d96616d9ead52dc9b50c01d81c4a9 Mon Sep 17 00:00:00 2001 From: anasty17 Date: Thu, 14 Nov 2024 14:23:52 +0200 Subject: [PATCH] minor changes Signed-off-by: anasty17 --- .../download_utils/yt_dlp_download.py | 5 +--- .../mirror_leech_utils/telegram_uploader.py | 26 +++++++++---------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py b/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py index f5b96c813eb..e2c01381391 100644 --- a/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/yt_dlp_download.py @@ -49,7 +49,6 @@ def __init__(self, listener): self._eta = "-" self._listener = listener self._gid = "" - self._downloading = False self._ext = "" self.is_playlist = False self.opts = { @@ -93,7 +92,6 @@ def eta(self): return self._eta def _on_download_progress(self, d): - self._downloading = True if self._listener.is_cancelled: raise ValueError("Cancelling...") if d["status"] == "finished": @@ -336,8 +334,7 @@ async def add_download(self, path, qual, playlist, options): async def cancel_task(self): self._listener.is_cancelled = True LOGGER.info(f"Cancelling Download: {self._listener.name}") - if not self._downloading: - await self._listener.on_download_error("Download Cancelled by User!") + await self._listener.on_download_error("Download Cancelled by User!") def _set_options(self, options): options = options.split("|") diff --git a/bot/helper/mirror_leech_utils/telegram_uploader.py b/bot/helper/mirror_leech_utils/telegram_uploader.py index b20dfed69e8..7b0b3d796ba 100644 --- a/bot/helper/mirror_leech_utils/telegram_uploader.py +++ b/bot/helper/mirror_leech_utils/telegram_uploader.py @@ -314,20 +314,18 @@ async def upload(self, o_files, ft_delete): self._corrupted += 1 if self._listener.is_cancelled: return - continue - finally: - if ( - not self._listener.is_cancelled - and await aiopath.exists(self._up_path) - and ( - not self._listener.seed - or self._listener.new_dir - or dirpath.endswith("/splited_files_mltb") - or "/copied_mltb/" in self._up_path - or delete_file - ) - ): - await remove(self._up_path) + if ( + not self._listener.is_cancelled + and await aiopath.exists(self._up_path) + and ( + not self._listener.seed + or self._listener.new_dir + or dirpath.endswith("/splited_files_mltb") + or "/copied_mltb/" in self._up_path + or delete_file + ) + ): + await remove(self._up_path) for key, value in list(self._media_dict.items()): for subkey, msgs in list(value.items()): if len(msgs) > 1: