diff --git a/bot/core/handlers.py b/bot/core/handlers.py index 0613735b7..13b145f69 100644 --- a/bot/core/handlers.py +++ b/bot/core/handlers.py @@ -1,3 +1,4 @@ +# ruff: noqa: F405 from pyrogram.filters import command, regex from pyrogram.handlers import ( CallbackQueryHandler, diff --git a/bot/helper/common.py b/bot/helper/common.py index ace24bbae..46ab1277d 100644 --- a/bot/helper/common.py +++ b/bot/helper/common.py @@ -319,7 +319,7 @@ async def before_start(self): if self.user_transmission: try: chat = await TgClient.user.get_chat(self.up_dest) - except: + except Exception: chat = None if chat is None: self.user_transmission = False @@ -341,7 +341,7 @@ async def before_start(self): if not self.user_transmission or self.mixed_leech: try: chat = await self.client.get_chat(self.up_dest) - except: + except Exception: chat = None if chat is None: if self.user_transmission: @@ -367,7 +367,7 @@ async def before_start(self): self.up_dest, ChatAction.TYPING, ) - except: + except Exception: raise ValueError("Start the bot and try again!") elif ( self.user_transmission or self.mixed_leech @@ -536,7 +536,7 @@ async def init_bulk(self, input_list, bulk_start, bulk_end, obj): self.multi_tag, self.options, ).new_event() - except: + except Exception: await send_message( self.message, "Reply to text file or to telegram message that have links seperated by new line!", @@ -568,7 +568,7 @@ async def decompress_zst(self, dl_path, is_dir=False): if code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Unable to extract zst file!. Path: {f_path}", @@ -590,7 +590,7 @@ async def decompress_zst(self, dl_path, is_dir=False): if code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Unable to extract zst file!. Path: {dl_path}", @@ -655,7 +655,7 @@ async def proceed_extract(self, dl_path, gid): if code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Unable to extract archive splits!. Path: {f_path}", @@ -670,7 +670,7 @@ async def proceed_extract(self, dl_path, gid): del_path = ospath.join(dirpath, file_) try: await remove(del_path) - except: + except Exception: self.is_cancelled = True return up_path dl_path = await self.decompress_zst(dl_path) @@ -705,12 +705,12 @@ async def proceed_extract(self, dl_path, gid): if not self.seed: try: await remove(dl_path) - except: + except Exception: self.is_cancelled = True return up_path try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Unable to extract archive! Uploading anyway. Path: {dl_path}", @@ -793,7 +793,7 @@ async def proceed_compress(self, dl_path, gid, o_files, ft_delete): self.new_dir = "" try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error(f"{stderr}. Unable to zip this path: {dl_path}") return dl_path @@ -830,13 +830,13 @@ async def proceed_split(self, up_dir, m_size, o_files, gid): else: try: await remove(f_path) - except: + except Exception: return continue if not self.seed or self.new_dir: try: await remove(f_path) - except: + except Exception: return else: m_size.append(f_size) diff --git a/bot/helper/ext_utils/files_utils.py b/bot/helper/ext_utils/files_utils.py index c687fc3c4..afc2eebd6 100644 --- a/bot/helper/ext_utils/files_utils.py +++ b/bot/helper/ext_utils/files_utils.py @@ -104,7 +104,7 @@ def clean_all(): try: LOGGER.info("Cleaning Download Directory") rmtree(Config.DOWNLOAD_DIR, ignore_errors=True) - except: + except Exception: pass makedirs(Config.DOWNLOAD_DIR, exist_ok=True) diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py index e49a5f209..94f0ae59e 100644 --- a/bot/helper/ext_utils/media_utils.py +++ b/bot/helper/ext_utils/media_utils.py @@ -683,7 +683,7 @@ async def create_sample_video(listener, video_file, sample_duration, part_durati elif code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Something went wrong while splitting file for sample video, mostly file is corrupted. Path: {video_file}" @@ -731,7 +731,7 @@ async def create_sample_video(listener, video_file, sample_duration, part_durati elif code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}" diff --git a/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py b/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py index 91b17f4aa..2641c05e2 100644 --- a/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py +++ b/bot/helper/mirror_leech_utils/download_utils/direct_link_generator.py @@ -875,7 +875,7 @@ def linkBox(url: str): parsed_url = urlparse(url) try: shareToken = parsed_url.path.split("/")[-1] - except: + except Exception: raise DirectDownloadLinkException("ERROR: invalid URL") details = {"contents": [], "title": "", "total_size": 0} @@ -939,7 +939,7 @@ def __fetch_links(session, _id=0, folderPath=""): try: if data["shareType"] == "singleItem": return __singleItem(session, data["itemId"]) - except: + except Exception: pass if not details["title"]: details["title"] = data["dirName"] @@ -1097,7 +1097,7 @@ def mediafireFolder(url): raw = url.split("/", 4)[-1] folderkey = raw.split("/", 1)[0] folderkey = folderkey.split(",") - except: + except Exception: raise DirectDownloadLinkException("ERROR: Could not parse ") if len(folderkey) == 1: folderkey = folderkey[0] @@ -1159,12 +1159,12 @@ def __repair_download(url): html = HTML(session.get(url).text) if new_link := html.xpath('//a[@id="continue-btn"]/@href'): return __scraper(f"https://mediafire.com/{new_link[0]}") - except: + except Exception: return None try: html = HTML(session.get(url).text) - except: + except Exception: return None if html.xpath("//div[@class='passwordPrompt']"): if not _password: @@ -1173,7 +1173,7 @@ def __repair_download(url): ) try: html = HTML(session.post(url, data={"downloadp": _password}).text) - except: + except Exception: return None if html.xpath("//div[@class='passwordPrompt']"): return None @@ -1344,7 +1344,7 @@ def __getFile_link(file_id): ) if "Location" in _res.headers: return _res.headers["Location"] - except: + except Exception: pass def __getFiles(html): @@ -1735,7 +1735,7 @@ def mp4upload(url): data["referer"] = url direct_link = session.post(url, data=data).url return direct_link, header - except: + except Exception: raise DirectDownloadLinkException("ERROR: File Not Found!") diff --git a/bot/helper/mirror_leech_utils/download_utils/qbit_download.py b/bot/helper/mirror_leech_utils/download_utils/qbit_download.py index a0f72e2ea..a3586b01d 100644 --- a/bot/helper/mirror_leech_utils/download_utils/qbit_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/qbit_download.py @@ -114,7 +114,7 @@ async def add_qb_torrent(listener, path, ratio, seed_time): ]: await delete_message(meta) break - except: + except Exception: await delete_message(meta) return diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/helper.py b/bot/helper/mirror_leech_utils/gdrive_utils/helper.py index d6d333cde..540f5c5e9 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/helper.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/helper.py @@ -56,7 +56,7 @@ def __init__(self): def speed(self): try: return self.proc_bytes / self.total_time - except: + except Exception: return 0 @property diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/list.py b/bot/helper/mirror_leech_utils/gdrive_utils/list.py index 4f2684747..5bb845645 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/list.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/list.py @@ -150,7 +150,7 @@ async def _event_handler(self): ) try: await wait_for(self.event.wait(), timeout=self._timeout) - except: + except Exception: self.id = "Timed Out. Task has been cancelled!" self.listener.is_cancelled = True self.event.set() diff --git a/bot/helper/mirror_leech_utils/rclone_utils/list.py b/bot/helper/mirror_leech_utils/rclone_utils/list.py index 252f6f57c..f367d7b59 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/list.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/list.py @@ -169,7 +169,7 @@ async def _event_handler(self): ) try: await wait_for(self.event.wait(), timeout=self._timeout) - except: + except Exception: self.path = "" self.remote = "Timed Out. Task has been cancelled!" self.listener.is_cancelled = True diff --git a/bot/helper/mirror_leech_utils/rclone_utils/serve.py b/bot/helper/mirror_leech_utils/rclone_utils/serve.py index 05d7e7d53..342f5a9a8 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/serve.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/serve.py @@ -15,7 +15,7 @@ async def rclone_serve_booter(): try: RcloneServe[0].kill() RcloneServe.clear() - except: + except Exception: pass return config = RawConfigParser() @@ -33,7 +33,7 @@ async def rclone_serve_booter(): try: RcloneServe[0].kill() RcloneServe.clear() - except: + except Exception: pass cmd = [ "rclone", diff --git a/bot/helper/mirror_leech_utils/rclone_utils/transfer.py b/bot/helper/mirror_leech_utils/rclone_utils/transfer.py index 1fff29b14..8c053ce99 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/transfer.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/transfer.py @@ -63,7 +63,7 @@ async def _progress(self): while not (self._proc is None or self._listener.is_cancelled): try: data = (await self._proc.stdout.readline()).decode() - except: + except Exception: continue if not data: break diff --git a/bot/helper/mirror_leech_utils/status_utils/direct_status.py b/bot/helper/mirror_leech_utils/status_utils/direct_status.py index 33aff3021..8a11d63b2 100644 --- a/bot/helper/mirror_leech_utils/status_utils/direct_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/direct_status.py @@ -17,7 +17,7 @@ def gid(self): def progress_raw(self): try: return self._obj.processed_bytes / self.listener.size * 100 - except: + except Exception: return 0 def progress(self): @@ -38,7 +38,7 @@ def eta(self): self.listener.size - self._obj.processed_bytes ) / self._obj.speed return get_readable_time(seconds) - except: + except Exception: return "-" def status(self): diff --git a/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py b/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py index 03bb1bca2..87c03a67c 100644 --- a/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py @@ -35,7 +35,7 @@ def gid(self) -> str: def progress_raw(self): try: return self._obj.processed_bytes / self._size * 100 - except: + except Exception: return 0 def progress(self): @@ -48,7 +48,7 @@ def eta(self): try: seconds = (self._size - self._obj.processed_bytes) / self._obj.speed return get_readable_time(seconds) - except: + except Exception: return "-" def task(self): diff --git a/bot/helper/mirror_leech_utils/status_utils/sevenz_status.py b/bot/helper/mirror_leech_utils/status_utils/sevenz_status.py index 1ef42f41d..e2e92e9bf 100644 --- a/bot/helper/mirror_leech_utils/status_utils/sevenz_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/sevenz_status.py @@ -28,7 +28,7 @@ async def progress_raw(self): await self.processed_raw() try: return self._proccessed_bytes / self._size * 100 - except: + except Exception: return 0 async def progress(self): @@ -47,7 +47,7 @@ def eta(self): try: seconds = (self._size - self._proccessed_bytes) / self.speed_raw() return get_readable_time(seconds) - except: + except Exception: return "-" def status(self): diff --git a/bot/helper/mirror_leech_utils/status_utils/telegram_status.py b/bot/helper/mirror_leech_utils/status_utils/telegram_status.py index 4030ac64c..4ee7c22c2 100644 --- a/bot/helper/mirror_leech_utils/status_utils/telegram_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/telegram_status.py @@ -30,7 +30,7 @@ def name(self): def progress(self): try: progress_raw = self._obj.processed_bytes / self._size * 100 - except: + except Exception: progress_raw = 0 return f"{round(progress_raw, 2)}%" @@ -41,7 +41,7 @@ def eta(self): try: seconds = (self._size - self._obj.processed_bytes) / self._obj.speed return get_readable_time(seconds) - except: + except Exception: return "-" def gid(self): diff --git a/bot/helper/mirror_leech_utils/status_utils/yt_dlp_status.py b/bot/helper/mirror_leech_utils/status_utils/yt_dlp_status.py index 53fa52124..cc180e7b7 100644 --- a/bot/helper/mirror_leech_utils/status_utils/yt_dlp_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/yt_dlp_status.py @@ -49,7 +49,7 @@ def eta(self): self._obj.size - self._proccessed_bytes ) / self._obj.download_speed return get_readable_time(seconds) - except: + except Exception: return "-" def task(self): diff --git a/bot/helper/mirror_leech_utils/telegram_uploader.py b/bot/helper/mirror_leech_utils/telegram_uploader.py index e08912f7e..512eeb420 100644 --- a/bot/helper/mirror_leech_utils/telegram_uploader.py +++ b/bot/helper/mirror_leech_utils/telegram_uploader.py @@ -556,7 +556,7 @@ async def _upload_file(self, cap_mono, file, o_path, force_document=False): def speed(self): try: return self._processed_bytes / (time() - self._start_time) - except: + except Exception: return 0 @property diff --git a/bot/modules/clone.py b/bot/modules/clone.py index 8cee9ce5c..e246c81d9 100644 --- a/bot/modules/clone.py +++ b/bot/modules/clone.py @@ -80,7 +80,7 @@ async def new_event(self): try: self.multi = int(args["-i"]) - except: + except Exception: self.multi = 0 self.up_dest = args["-up"] diff --git a/bot/modules/exec.py b/bot/modules/exec.py index 5f63d776f..bcd370d8b 100644 --- a/bot/modules/exec.py +++ b/bot/modules/exec.py @@ -87,7 +87,7 @@ async def do(func, message): func_return = ( await sync_to_async(rfunc) if func == "exec" else await rfunc() ) - except: + except Exception: value = stdout.getvalue() return f"{value}{format_exc()}" else: diff --git a/bot/modules/file_selector.py b/bot/modules/file_selector.py index 78efb5f34..920bbaf1d 100644 --- a/bot/modules/file_selector.py +++ b/bot/modules/file_selector.py @@ -91,7 +91,7 @@ async def select(_, message): f"{e} Error in pause, this mostly happens after abuse aria2", ) task.listener.select = True - except: + except Exception: await send_message(message, "This is not a bittorrent task!") return diff --git a/bot/modules/mirror_leech.py b/bot/modules/mirror_leech.py index 9473c04eb..0fae1b5e3 100644 --- a/bot/modules/mirror_leech.py +++ b/bot/modules/mirror_leech.py @@ -151,7 +151,7 @@ async def new_event(self): try: self.multi = int(args["-i"]) - except: + except Exception: self.multi = 0 try: diff --git a/bot/modules/rss.py b/bot/modules/rss.py index aff154394..34a86862f 100644 --- a/bot/modules/rss.py +++ b/bot/modules/rss.py @@ -696,7 +696,7 @@ async def rss_monitor(): res = await client.get(data["link"]) html = res.text break - except: + except Exception: tries += 1 if tries > 3: raise @@ -718,7 +718,7 @@ async def rss_monitor(): while True: try: await sleep(10) - except: + except Exception: raise RssShutdownException("Rss Monitor Stopped!") try: item_title = rss_d.entries[feed_count]["title"] diff --git a/bot/modules/search.py b/bot/modules/search.py index 4acb6ae89..fb5cc927a 100644 --- a/bot/modules/search.py +++ b/bot/modules/search.py @@ -177,7 +177,7 @@ async def get_result(search_results, key, message, method): msg += f"Telegram

" else: msg += "
" - except: + except Exception: continue else: msg += f"{escape(result.fileName)}
" diff --git a/bot/modules/ytdlp.py b/bot/modules/ytdlp.py index 0c33190ab..6f595e152 100644 --- a/bot/modules/ytdlp.py +++ b/bot/modules/ytdlp.py @@ -91,7 +91,7 @@ async def _event_handler(self): ) try: await wait_for(self.event.wait(), timeout=self._timeout) - except: + except Exception: await edit_message(self._reply_to, "Timed Out. Task has been cancelled!") self.qual = None self.listener.is_cancelled = True @@ -332,7 +332,7 @@ async def new_event(self): try: self.multi = int(args["-i"]) - except: + except Exception: self.multi = 0 try: diff --git a/web/nodes.py b/web/nodes.py index 68e5b2d1c..7d2dddd42 100644 --- a/web/nodes.py +++ b/web/nodes.py @@ -115,7 +115,7 @@ def make_tree(res, tool=False): (int(i["completedLength"]) / int(i["length"])) * 100, 5, ) - except: + except Exception: progress = 0 TorNode( folders[-1], @@ -132,7 +132,7 @@ def make_tree(res, tool=False): (int(i["completedLength"]) / int(i["length"])) * 100, 5, ) - except: + except Exception: progress = 0 TorNode( folders[-1],