diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 00000000..c8a0958d --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,8 @@ +name: Ruff +on: [ push, pull_request ] +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 \ No newline at end of file diff --git a/aria-nox-nzb.sh b/aria-nox-nzb.sh old mode 100755 new mode 100644 diff --git a/bot/__init__.py b/bot/__init__.py index 92ef9d8c..5f7e305a 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -73,7 +73,7 @@ try: if bool(environ.get("_____REMOVE_THIS_LINE_____")): log_error("The README.md file there to be read! Exiting now!") exit(1) -except: +except Exception: pass task_dict_lock = Lock() @@ -192,7 +192,7 @@ if len(USER_SESSION_STRING) != 0: max_concurrent_transmissions=10, ).start() IS_PREMIUM_USER = user.me.is_premium - except: + except Exception: log_error("Failed to start client from USER_SESSION_STRING") IS_PREMIUM_USER = False user = "" @@ -255,7 +255,7 @@ try: USENET_SERVERS = [] else: USENET_SERVERS = eval(USENET_SERVERS) -except: +except Exception: log_error(f"Wrong USENET_SERVERS format: {USENET_SERVERS}") USENET_SERVERS = [] @@ -285,7 +285,7 @@ if len(SEARCH_PLUGINS) == 0: else: try: SEARCH_PLUGINS = eval(SEARCH_PLUGINS) - except: + except Exception: log_error(f"Wrong USENET_SERVERS format: {SEARCH_PLUGINS}") SEARCH_PLUGINS = "" diff --git a/bot/__main__.py b/bot/__main__.py index dc23d7e6..903a256f 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -39,26 +39,7 @@ from .helper.telegram_helper.bot_commands import BotCommands from .helper.telegram_helper.button_build import ButtonMaker from .helper.telegram_helper.filters import CustomFilters from .helper.telegram_helper.message_utils import sendMessage, editMessage, sendFile -from .modules import ( - authorize, - cancel_task, - clone, - exec, - file_selector, - gd_count, - gd_delete, - gd_search, - mirror_leech, - status, - torrent_search, - ytdlp, - rss, - shell, - users_settings, - bot_settings, - help, - force_start, -) +from .modules import authorize, cancel_task, clone, exec, file_selector, gd_count, gd_delete, gd_search, mirror_leech, status, torrent_search, ytdlp, rss, shell, users_settings, bot_settings, help, force_start # noqa: F401 async def stats(_, message): @@ -245,7 +226,7 @@ async def restart_notification(): await bot.edit_message_text( chat_id=chat_id, message_id=msg_id, text="Restarted Successfully!" ) - except: + except Exception: pass await remove(".restartmsg") diff --git a/bot/helper/common.py b/bot/helper/common.py index 5533ca18..f78969b6 100644 --- a/bot/helper/common.py +++ b/bot/helper/common.py @@ -310,7 +310,7 @@ class TaskConfig: await self.client.send_chat_action( self.upDest, ChatAction.TYPING ) - except: + except Exception: raise ValueError("Start the bot and try again!") elif (self.userTransmission or self.mixedLeech) and not self.isSuperChat: self.userTransmission = False @@ -351,7 +351,7 @@ class TaskConfig: self.userDict = user_data.get(self.userId, {}) try: await self.message.unpin() - except: + except Exception: pass if self.user: if username := self.user.username: @@ -453,7 +453,7 @@ class TaskConfig: self.multiTag, self.options, ).newEvent() - except: + except Exception: await sendMessage( self.message, "Reply to text file or to telegram message that have links seperated by new line!", @@ -510,7 +510,7 @@ class TaskConfig: 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}" @@ -525,7 +525,7 @@ class TaskConfig: del_path = ospath.join(dirpath, file_) try: await remove(del_path) - except: + except Exception: self.isCancelled = True return up_path else: @@ -560,13 +560,13 @@ class TaskConfig: if not self.seed: try: await remove(dl_path) - except: + except Exception: self.isCancelled = True return up_path else: 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}" @@ -642,7 +642,7 @@ class TaskConfig: if await aiopath.exists(f): try: await remove(f) - except: + except Exception: pass ft_delete.clear() return up_path @@ -652,7 +652,7 @@ class TaskConfig: self.newDir = "" 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 @@ -684,13 +684,13 @@ class TaskConfig: else: try: await remove(f_path) - except: + except Exception: return continue elif not self.seed or self.newDir: try: await remove(f_path) - except: + except Exception: return else: m_size.append(f_size) @@ -866,7 +866,7 @@ class TaskConfig: else: try: await remove(dl_path) - except: + except Exception: pass return output_file else: @@ -886,7 +886,7 @@ class TaskConfig: else: try: await remove(f_path) - except: + except Exception: pass if checked: cpu_eater_lock.release() @@ -930,10 +930,10 @@ class TaskConfig: async def substitute(self, dl_path): if await aiopath.isfile(dl_path): up_dir, name = dl_path.rsplit("/", 1) - for l in self.nameSub: - pattern = l[0] - res = l[1] if len(l) > 1 and l[1] else "" - sen = len(l) > 2 and l[2] == "s" + for substitution in self.nameSub: + pattern = substitution[0] + res = substitution[1] if len(substitution) > 1 and substitution[1] else "" + sen = len(substitution) > 2 and substitution[2] == "s" new_name = sub(rf"{pattern}", res, name, flags=I if sen else 0) new_path = ospath.join(up_dir, new_name) await move(dl_path, new_path) @@ -942,10 +942,10 @@ class TaskConfig: for dirpath, _, files in await sync_to_async(walk, dl_path, topdown=False): for file_ in files: f_path = ospath.join(dirpath, file_) - for l in self.nameSub: - pattern = l[0] - res = l[1] if len(l) > 1 and l[1] else "" - sen = len(l) > 2 and l[2] == "s" + for substitution in self.nameSub: + pattern = substitution[0] + res = substitution[1] if len(substitution) > 1 and substitution[1] else "" + sen = len(substitution) > 2 and substitution[2] == "s" new_name = sub(rf"{pattern}", res, file_, flags=I if sen else 0) await move(f_path, ospath.join(dirpath, new_name)) return dl_path diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index e104c265..f286ba42 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -163,7 +163,7 @@ async def get_content_type(url): async with AsyncClient() as client: response = await client.get(url, allow_redirects=True, verify=False) return response.headers.get("Content-Type") - except: + except Exception: return None @@ -175,7 +175,7 @@ def update_user_ldata(id_, key, value): async def retry_function(func, *args, **kwargs): try: return await func(*args, **kwargs) - except: + except Exception: return await retry_function(func, *args, **kwargs) @@ -187,11 +187,11 @@ async def cmd_exec(cmd, shell=False): stdout, stderr = await proc.communicate() try: stdout = stdout.decode().strip() - except: + except Exception: stdout = "Unable to decode the response!" try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" return stdout, stderr, proc.returncode diff --git a/bot/helper/ext_utils/files_utils.py b/bot/helper/ext_utils/files_utils.py index 37faa620..bc8d3bb3 100644 --- a/bot/helper/ext_utils/files_utils.py +++ b/bot/helper/ext_utils/files_utils.py @@ -95,7 +95,7 @@ def clean_all(): try: LOGGER.info("Cleaning Download Directory") rmtree(DOWNLOAD_DIR, ignore_errors=True) - except: + except Exception: pass makedirs(DOWNLOAD_DIR, exist_ok=True) diff --git a/bot/helper/ext_utils/jdownloader_booter.py b/bot/helper/ext_utils/jdownloader_booter.py index d68f4466..28f3810e 100644 --- a/bot/helper/ext_utils/jdownloader_booter.py +++ b/bot/helper/ext_utils/jdownloader_booter.py @@ -124,7 +124,7 @@ class JDownloader(Myjdapi): break else: continue - except: + except Exception: continue break await self.device.enable_direct_connection() diff --git a/bot/helper/ext_utils/media_utils.py b/bot/helper/ext_utils/media_utils.py index 1274d667..619a1cb4 100644 --- a/bot/helper/ext_utils/media_utils.py +++ b/bot/helper/ext_utils/media_utils.py @@ -57,7 +57,7 @@ async def convert_video(listener, video_file, ext, retry=False): else: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Something went wrong while converting video, mostly file need specific codec. Path: {video_file}" @@ -91,7 +91,7 @@ async def convert_audio(listener, audio_file, ext): else: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Something went wrong while converting audio, mostly file need specific codec. Path: {audio_file}" @@ -261,7 +261,7 @@ async def take_ss(video_file, ss_nb) -> bool: ) await rmtree(dirpath, ignore_errors=True) return False - except: + except Exception: LOGGER.error( f"Error while creating sreenshots from video. Path: {video_file}. Error: Timeout some issues with ffmpeg with specific arch!" ) @@ -330,7 +330,7 @@ async def create_thumbnail(video_file, duration): f"Error while extracting thumbnail from video. Name: {video_file} stderr: {err}" ) return None - except: + except Exception: LOGGER.error( f"Error while extracting thumbnail from video. Name: {video_file}. Error: Timeout some issues with ffmpeg with specific arch!" ) @@ -404,11 +404,11 @@ async def split_file( elif code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" try: await remove(out_path) - except: + except Exception: pass if multi_streams: LOGGER.warning( @@ -488,7 +488,7 @@ async def split_file( elif code != 0: try: stderr = stderr.decode().strip() - except: + except Exception: stderr = "Unable to decode the error!" LOGGER.error(f"{stderr}. Split Document: {path}") return True @@ -556,7 +556,7 @@ async def createSampleVideo(listener, video_file, sample_duration, part_duration else: 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/ext_utils/status_utils.py b/bot/helper/ext_utils/status_utils.py index 57d58c64..e932cee0 100644 --- a/bot/helper/ext_utils/status_utils.py +++ b/bot/helper/ext_utils/status_utils.py @@ -193,7 +193,7 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step= if hasattr(task, "seeders_num"): try: msg += f"\nSeeders: {task.seeders_num()} | Leechers: {task.leechers_num()}" - except: + except Exception: pass elif tstatus == MirrorStatus.STATUS_SEEDING: msg += f"\nSize: {task.size()}" diff --git a/bot/helper/ext_utils/task_manager.py b/bot/helper/ext_utils/task_manager.py index ef8c3a8d..8deaa9e2 100644 --- a/bot/helper/ext_utils/task_manager.py +++ b/bot/helper/ext_utils/task_manager.py @@ -38,7 +38,7 @@ async def stop_duplicate_check(listener): elif listener.extract: try: name = get_base_name(name) - except: + except Exception: name = None if name is not None: diff --git a/bot/helper/listeners/aria2_listener.py b/bot/helper/listeners/aria2_listener.py index 25717fb3..5e605339 100644 --- a/bot/helper/listeners/aria2_listener.py +++ b/bot/helper/listeners/aria2_listener.py @@ -59,7 +59,7 @@ async def _onDownloadStarted(api, gid): async def _onDownloadComplete(api, gid): try: download = await sync_to_async(api.get_download, gid) - except: + except Exception: return if download.options.follow_torrent == "false": return @@ -107,7 +107,7 @@ async def _onBtDownloadComplete(api, gid): if not file_o.selected and await aiopath.exists(f_path): try: await remove(f_path) - except: + except Exception: pass await clean_unwanted(download.dir) if task.listener.seed: @@ -170,7 +170,7 @@ async def _onDownloadError(api, gid): return error = download.error_message LOGGER.info(f"Download Error: {error}") - except: + except Exception: pass if task := await getTaskByGid(gid): await task.listener.onDownloadError(error) diff --git a/bot/helper/listeners/jdownloader_listener.py b/bot/helper/listeners/jdownloader_listener.py index 4ebe49a5..70c35b94 100644 --- a/bot/helper/listeners/jdownloader_listener.py +++ b/bot/helper/listeners/jdownloader_listener.py @@ -17,7 +17,7 @@ async def update_download(gid, value): task._gid = new_gid async with jd_lock: del jd_downloads[gid] - except: + except Exception: pass @@ -71,7 +71,7 @@ async def _jd_listener(): await wait_for( retry_function(jdownloader.device.jd.version), timeout=10 ) - except: + except Exception: is_connected = await jdownloader.jdconnect() if not is_connected: LOGGER.error(jdownloader.error) @@ -84,7 +84,7 @@ async def _jd_listener(): packages = await jdownloader.device.downloads.query_packages( [{"finished": True}] ) - except: + except Exception: continue finished = [ pack["uuid"] for pack in packages if pack.get("finished", False) diff --git a/bot/helper/listeners/qbit_listener.py b/bot/helper/listeners/qbit_listener.py index d4778f7d..06659611 100644 --- a/bot/helper/listeners/qbit_listener.py +++ b/bot/helper/listeners/qbit_listener.py @@ -83,7 +83,7 @@ async def _onDownloadComplete(tor): if f.priority == 0 and await aiopath.exists(f"{path}/{f.name}"): try: await remove(f"{path}/{f.name}") - except: + except Exception: pass await task.listener.onDownloadComplete() if Intervals["stopAll"]: diff --git a/bot/helper/listeners/task_listener.py b/bot/helper/listeners/task_listener.py index fabef6c8..a1e00546 100644 --- a/bot/helper/listeners/task_listener.py +++ b/bot/helper/listeners/task_listener.py @@ -57,7 +57,7 @@ class TaskListener(TaskConfig): intvl.cancel() Intervals["status"].clear() await gather(sync_to_async(aria2.purge), delete_status()) - except: + except Exception: pass def removeFromSameDir(self): 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 899b5923..6adc5b6e 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 @@ -816,7 +816,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} @@ -876,7 +876,7 @@ def linkBox(url: str): try: if data["shareType"] == "singleItem": return __singleItem(session, data["itemId"]) - except: + except Exception: pass if not details["title"]: details["title"] = data["dirName"] @@ -1028,7 +1028,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] @@ -1083,7 +1083,7 @@ def mediafireFolder(url): def __scraper(url): try: html = HTML(session.get(url).text) - except: + except Exception: return if final_link := html.xpath("//a[@id='downloadButton']/@href"): return final_link[0] @@ -1241,7 +1241,7 @@ def send_cm(url): ) if "Location" in _res.headers: return _res.headers["Location"] - except: + except Exception: pass def __getFiles(html): @@ -1613,7 +1613,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/jd_download.py b/bot/helper/mirror_leech_utils/download_utils/jd_download.py index 78983758..a05140ef 100644 --- a/bot/helper/mirror_leech_utils/download_utils/jd_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/jd_download.py @@ -67,7 +67,7 @@ class JDownloaderHelper: ) try: await wait_for(self.event.wait(), timeout=self._timeout) - except: + except Exception: await editMessage(self._reply_to, "Timed Out. Task has been cancelled!") self.listener.isCancelled = True self.event.set() @@ -97,7 +97,7 @@ async def add_jd_download(listener, path): try: await wait_for(retry_function(jdownloader.device.jd.version), timeout=10) - except: + except Exception: is_connected = await jdownloader.jdconnect() if not is_connected: await listener.onDownloadError(jdownloader.error) 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 32802459..e81a7aec 100644 --- a/bot/helper/mirror_leech_utils/download_utils/qbit_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/qbit_download.py @@ -110,7 +110,7 @@ async def add_qb_torrent(listener, path, ratio, seed_time): ]: await deleteMessage(meta) break - except: + except Exception: await deleteMessage(meta) return diff --git a/bot/helper/mirror_leech_utils/download_utils/telegram_download.py b/bot/helper/mirror_leech_utils/download_utils/telegram_download.py index 9a0edbd8..a7d78e91 100644 --- a/bot/helper/mirror_leech_utils/download_utils/telegram_download.py +++ b/bot/helper/mirror_leech_utils/download_utils/telegram_download.py @@ -64,7 +64,7 @@ class TelegramDownloadHelper: async with global_lock: try: GLOBAL_GID.remove(self._id) - except: + except Exception: pass await self._listener.onDownloadError(error) 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 b1f5e712..b5c65573 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 @@ -115,7 +115,7 @@ class YoutubeDLHelper: self._eta = d.get("eta", "-") or "-" try: self._progress = (self._downloaded_bytes / self._listener.size) * 100 - except: + except Exception: pass async def _onDownloadStart(self, from_queue=False): diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/helper.py b/bot/helper/mirror_leech_utils/gdrive_utils/helper.py index 43e3f928..c3507689 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/helper.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/helper.py @@ -52,7 +52,7 @@ class GoogleDriveHelper: 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 e23987f3..09c094a9 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/list.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/list.py @@ -145,7 +145,7 @@ class gdriveList(GoogleDriveHelper): ) try: await wait_for(self.event.wait(), timeout=self._timeout) - except: + except Exception: self.id = "Timed Out. Task has been cancelled!" self.listener.isCancelled = True self.event.set() @@ -263,6 +263,7 @@ class gdriveList(GoogleDriveHelper): await self.get_items() elif len(drives) == 0: msg = "Service accounts Doesn't have access to any drive!" + buttons = ButtonMaker() if self._token_user and self._token_owner: buttons.ibutton("Back", "gdq back dr", position="footer") buttons.ibutton("Cancel", "gdq cancel", position="footer") diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/upload.py b/bot/helper/mirror_leech_utils/gdrive_utils/upload.py index 9826097e..94093d56 100644 --- a/bot/helper/mirror_leech_utils/gdrive_utils/upload.py +++ b/bot/helper/mirror_leech_utils/gdrive_utils/upload.py @@ -223,7 +223,7 @@ class gdUpload(GoogleDriveHelper): if not self.listener.seed or self.listener.newDir or file_path in ft_delete: try: remove(file_path) - except: + except Exception: pass self.file_processed_bytes = 0 # Insert new permissions diff --git a/bot/helper/mirror_leech_utils/rclone_utils/list.py b/bot/helper/mirror_leech_utils/rclone_utils/list.py index 4c77549b..408f7ef7 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/list.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/list.py @@ -140,7 +140,7 @@ class RcloneList: ) 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.isCancelled = True diff --git a/bot/helper/mirror_leech_utils/rclone_utils/serve.py b/bot/helper/mirror_leech_utils/rclone_utils/serve.py index cf6ec0be..e4398680 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/serve.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/serve.py @@ -14,7 +14,7 @@ async def rclone_serve_booter(): try: RcloneServe[0].kill() RcloneServe.clear() - except: + except Exception: pass return config = ConfigParser() @@ -32,7 +32,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 9304e201..1e8b16b3 100644 --- a/bot/helper/mirror_leech_utils/rclone_utils/transfer.py +++ b/bot/helper/mirror_leech_utils/rclone_utils/transfer.py @@ -59,7 +59,7 @@ class RcloneTransferHelper: while not (self._proc is None or self._listener.isCancelled): try: data = (await self._proc.stdout.readline()).decode() - except: + except Exception: continue if not data: break @@ -492,7 +492,7 @@ class RcloneTransferHelper: if self._proc is not None: try: self._proc.kill() - except: + except Exception: pass if self._is_download: LOGGER.info(f"Cancelling Download: {self._listener.name}") 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 f37bc3cf..906034ed 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 @@ class DirectStatus: def progress_raw(self): try: return self._obj.processed_bytes / self.listener.size * 100 - except: + except Exception: return 0 def progress(self): @@ -36,7 +36,7 @@ class DirectStatus: try: seconds = (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/extract_status.py b/bot/helper/mirror_leech_utils/status_utils/extract_status.py index f96bd95c..76fe3aa7 100644 --- a/bot/helper/mirror_leech_utils/status_utils/extract_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/extract_status.py @@ -27,7 +27,7 @@ class ExtractStatus: await self.processed_raw() try: return self._proccessed_bytes / self._size * 100 - except: + except Exception: return 0 async def progress(self): @@ -46,7 +46,7 @@ class ExtractStatus: 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/gdrive_status.py b/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py index 1c93a42c..ce3205fd 100644 --- a/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/gdrive_status.py @@ -36,7 +36,7 @@ class GdriveStatus: def progress_raw(self): try: return self._obj.processed_bytes / self._size * 100 - except: + except Exception: return 0 def progress(self): @@ -49,7 +49,7 @@ class GdriveStatus: 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/jdownloader_status.py b/bot/helper/mirror_leech_utils/status_utils/jdownloader_status.py index 9e40cd42..e01e9a2f 100644 --- a/bot/helper/mirror_leech_utils/status_utils/jdownloader_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/jdownloader_status.py @@ -26,7 +26,7 @@ def _get_combined_info(result): status = "UnknownError" try: eta = (bytesTotal - bytesLoaded) / speed - except: + except Exception: eta = 0 return { "name": name, @@ -56,7 +56,7 @@ async def get_download(gid, old_info): ] ) return _get_combined_info(result) if len(result) > 1 else result[0] - except: + except Exception: return old_info @@ -72,7 +72,7 @@ class JDownloaderStatus: def progress(self): try: return f"{round((self._info.get('bytesLoaded', 0) / self._info.get('bytesTotal', 0)) * 100, 2)}%" - except: + except Exception: return "0%" def processed_bytes(self): diff --git a/bot/helper/mirror_leech_utils/status_utils/nzb_status.py b/bot/helper/mirror_leech_utils/status_utils/nzb_status.py index 287b064a..74b06039 100644 --- a/bot/helper/mirror_leech_utils/status_utils/nzb_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/nzb_status.py @@ -47,7 +47,7 @@ class SabnzbdStatus: def speed_raw(self): try: return int(float(self._info["mb"]) * 1048576) / self.eta_raw() - except: + except Exception: return 0 def speed(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 cdc23859..62460098 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 @@ class TelegramStatus: 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 @@ class TelegramStatus: 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_download_status.py b/bot/helper/mirror_leech_utils/status_utils/yt_dlp_download_status.py index 7256253d..5b95c5bd 100644 --- a/bot/helper/mirror_leech_utils/status_utils/yt_dlp_download_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/yt_dlp_download_status.py @@ -49,7 +49,7 @@ class YtDlpDownloadStatus: 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/status_utils/zip_status.py b/bot/helper/mirror_leech_utils/status_utils/zip_status.py index 03704aba..a28ac7e8 100644 --- a/bot/helper/mirror_leech_utils/status_utils/zip_status.py +++ b/bot/helper/mirror_leech_utils/status_utils/zip_status.py @@ -27,7 +27,7 @@ class ZipStatus: await self.processed_raw() try: return self._proccessed_bytes / self._size * 100 - except: + except Exception: return 0 async def progress(self): @@ -46,7 +46,7 @@ class ZipStatus: 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/telegram_uploader.py b/bot/helper/mirror_leech_utils/telegram_uploader.py index 54ba233e..27cac6ec 100644 --- a/bot/helper/mirror_leech_utils/telegram_uploader.py +++ b/bot/helper/mirror_leech_utils/telegram_uploader.py @@ -497,7 +497,7 @@ class TgUploader: def speed(self): try: return self._processed_bytes / (time() - self._start_time) - except: + except Exception: return 0 @property diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py index 5a0d9f38..0f10d634 100644 --- a/bot/modules/bot_settings.py +++ b/bot/modules/bot_settings.py @@ -412,7 +412,7 @@ async def edit_nzb_server(_, message, pre_message, key, index=0): if key == "newser": try: value = eval(value) - except: + except Exception: await sendMessage(message, "Invalid dict format!") await update_buttons(pre_message, "nzbserver") return @@ -446,7 +446,7 @@ async def sync_jdownloader(): return try: await wait_for(retry_function(jdownloader.update_devices), timeout=10) - except: + except Exception: is_connected = await jdownloader.jdconnect() if not is_connected: LOGGER.error(jdownloader.error) @@ -999,7 +999,7 @@ async def load_config(): USENET_SERVERS = [] else: USENET_SERVERS = eval(USENET_SERVERS) - except: + except Exception: LOGGER.error(f"Wrong USENET_SERVERS format: {USENET_SERVERS}") USENET_SERVERS = [] @@ -1029,7 +1029,7 @@ async def load_config(): else: try: SEARCH_PLUGINS = eval(SEARCH_PLUGINS) - except: + except Exception: LOGGER.error(f"Wrong SEARCH_PLUGINS fornat {SEARCH_PLUGINS}") SEARCH_PLUGINS = "" diff --git a/bot/modules/clone.py b/bot/modules/clone.py index 21c6573e..0f523ba6 100644 --- a/bot/modules/clone.py +++ b/bot/modules/clone.py @@ -8,7 +8,6 @@ from bot import LOGGER, task_dict, task_dict_lock, bot from bot.helper.ext_utils.bot_utils import ( new_task, sync_to_async, - new_task, cmd_exec, arg_parser, COMMAND_USAGE, @@ -82,7 +81,7 @@ class Clone(TaskListener): try: self.multi = int(args["-i"]) - except: + except Exception: self.multi = 0 self.upDest = args["-up"] diff --git a/bot/modules/exec.py b/bot/modules/exec.py index dac91bd4..e18c8955 100644 --- a/bot/modules/exec.py +++ b/bot/modules/exec.py @@ -88,7 +88,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: @@ -100,7 +100,7 @@ async def do(func, message): else: try: result = f"{repr(await sync_to_async(eval, body, env))}" - except: + except Exception: pass else: result = f"{value}{func_return}" diff --git a/bot/modules/file_selector.py b/bot/modules/file_selector.py index eb704e6d..c7b8a76c 100644 --- a/bot/modules/file_selector.py +++ b/bot/modules/file_selector.py @@ -93,7 +93,7 @@ async def select(_, message): f"{e} Error in pause, this mostly happens after abuse aria2" ) task.listener.select = True - except: + except Exception: await sendMessage(message, "This is not a bittorrent or sabnzbd task!") return @@ -136,7 +136,7 @@ async def get_confirm(_, query): if await aiopath.exists(f_path): try: await remove(f_path) - except: + except Exception: pass if not task.queued: await sync_to_async( @@ -148,7 +148,7 @@ async def get_confirm(_, query): if f["selected"] == "false" and await aiopath.exists(f["path"]): try: await remove(f["path"]) - except: + except Exception: pass if not task.queued: try: diff --git a/bot/modules/mirror_leech.py b/bot/modules/mirror_leech.py index 117d2ed8..d62a355c 100644 --- a/bot/modules/mirror_leech.py +++ b/bot/modules/mirror_leech.py @@ -148,7 +148,7 @@ class Mirror(TaskListener): try: self.multi = int(args["-i"]) - except: + except Exception: self.multi = 0 if not isinstance(self.seed, bool): diff --git a/bot/modules/rss.py b/bot/modules/rss.py index 41d72202..f69aa315 100644 --- a/bot/modules/rss.py +++ b/bot/modules/rss.py @@ -658,7 +658,7 @@ async def rssMonitor(): res = await client.get(data["link"]) html = res.text break - except: + except Exception: tries += 1 if tries > 3: raise @@ -677,7 +677,7 @@ async def rssMonitor(): 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/torrent_search.py b/bot/modules/torrent_search.py index ac56c483..4909b53d 100644 --- a/bot/modules/torrent_search.py +++ b/bot/modules/torrent_search.py @@ -162,7 +162,7 @@ async def _getResult(search_results, key, message, method): msg += f"Size: {result['size']}
" try: msg += f"Seeders: {result['seeders']} | Leechers: {result['leechers']}
" - except: + except Exception: pass if "torrent" in result.keys(): msg += f"Direct Link

" @@ -171,7 +171,7 @@ async def _getResult(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 97132030..096ef6f7 100644 --- a/bot/modules/ytdlp.py +++ b/bot/modules/ytdlp.py @@ -87,7 +87,7 @@ class YtSelection: ) try: await wait_for(self.event.wait(), timeout=self._timeout) - except: + except Exception: await editMessage(self._reply_to, "Timed Out. Task has been cancelled!") self.qual = None self.listener.isCancelled = True @@ -318,7 +318,7 @@ class YtDlp(TaskListener): try: self.multi = int(args["-i"]) - except: + except Exception: self.multi = 0 self.select = args["-s"] diff --git a/myjd/__init__.py b/myjd/__init__.py index 678c8a49..05e536e7 100644 --- a/myjd/__init__.py +++ b/myjd/__init__.py @@ -35,3 +35,39 @@ from .exception import ( from .myjdapi import Myjdapi __version__ = "1.1.7" + +__all__ = [ + "MYJDException", + "MYJDConnectionException", + "MYJDDeviceNotFoundException", + "MYJDDecodeException", + "MYJDApiException", + "MYJDApiCommandNotFoundException", + "MYJDApiInterfaceNotFoundException", + "MYJDAuthFailedException", + "MYJDBadParametersException", + "MYJDBadRequestException", + "MYJDChallengeFailedException", + "MYJDEmailForbiddenException", + "MYJDEmailInvalidException", + "MYJDErrorEmailNotConfirmedException", + "MYJDFailedException", + "MYJDFileNotFoundException", + "MYJDInternalServerErrorException", + "MYJDMaintenanceException", + "MYJDMethodForbiddenException", + "MYJDOfflineException", + "MYJDOutdatedException", + "MYJDOverloadException", + "MYJDSessionException", + "MYJDStorageAlreadyExistsException", + "MYJDStorageInvalidKeyException", + "MYJDStorageInvalidStorageIdException", + "MYJDStorageKeyNotFoundException", + "MYJDStorageLimitReachedException", + "MYJDStorageNotFoundException", + "MYJDTokenInvalidException", + "MYJDTooManyRequestsException", + "MYJDUnknownException", + "Myjdapi", +] diff --git a/sabnzbdapi/__init__.py b/sabnzbdapi/__init__.py index ab60ab48..2e8e7bfb 100644 --- a/sabnzbdapi/__init__.py +++ b/sabnzbdapi/__init__.py @@ -1 +1,5 @@ from sabnzbdapi.requests import sabnzbdClient + +__all__ = [ + "sabnzbdClient" +] diff --git a/start.sh b/start.sh old mode 100755 new mode 100644 diff --git a/update.py b/update.py index 37d21a43..044fb7be 100644 --- a/update.py +++ b/update.py @@ -35,7 +35,7 @@ try: if bool(environ.get("_____REMOVE_THIS_LINE_____")): log_error("The README.md file there to be read! Exiting now!") exit(1) -except: +except Exception: pass BOT_TOKEN = environ.get("BOT_TOKEN", "")