From e8b494f0e63974d21bee43e6d9be07812a265192 Mon Sep 17 00:00:00 2001 From: anasty17 Date: Thu, 25 Jul 2024 02:16:13 +0300 Subject: [PATCH] Fixes - Fix jdownloader device version issue after idle - Fix sample video. Build is required, issue was in ffmpeg version. now it's v7 - Fix rss tage when name have space - Fix aria2 seed Signed-off-by: anasty17 --- .github/workflows/ruff.yml | 8 -- bot/__init__.py | 8 +- bot/__main__.py | 23 +++- bot/helper/common.py | 43 +++++--- bot/helper/ext_utils/bot_utils.py | 8 +- bot/helper/ext_utils/files_utils.py | 2 +- bot/helper/ext_utils/jdownloader_booter.py | 2 +- bot/helper/ext_utils/media_utils.py | 103 ++++++++++++++++-- bot/helper/ext_utils/status_utils.py | 2 +- bot/helper/ext_utils/task_manager.py | 2 +- bot/helper/listeners/aria2_listener.py | 14 +-- bot/helper/listeners/jdownloader_listener.py | 6 +- bot/helper/listeners/qbit_listener.py | 2 +- bot/helper/listeners/task_listener.py | 2 +- .../download_utils/direct_link_generator.py | 20 ++-- .../download_utils/jd_download.py | 4 +- .../download_utils/qbit_download.py | 2 +- .../download_utils/telegram_download.py | 2 +- .../download_utils/yt_dlp_download.py | 2 +- .../mirror_leech_utils/gdrive_utils/helper.py | 2 +- .../mirror_leech_utils/gdrive_utils/list.py | 2 +- .../mirror_leech_utils/gdrive_utils/upload.py | 2 +- .../mirror_leech_utils/rclone_utils/list.py | 2 +- .../mirror_leech_utils/rclone_utils/serve.py | 4 +- .../rclone_utils/transfer.py | 9 +- .../status_utils/direct_status.py | 4 +- .../status_utils/extract_status.py | 4 +- .../status_utils/gdrive_status.py | 4 +- .../status_utils/jdownloader_status.py | 6 +- .../status_utils/nzb_status.py | 2 +- .../status_utils/telegram_status.py | 4 +- .../status_utils/yt_dlp_download_status.py | 2 +- .../status_utils/zip_status.py | 4 +- .../mirror_leech_utils/telegram_uploader.py | 2 +- bot/modules/bot_settings.py | 8 +- bot/modules/clone.py | 2 +- bot/modules/exec.py | 4 +- bot/modules/file_selector.py | 6 +- bot/modules/mirror_leech.py | 2 +- bot/modules/rss.py | 4 +- bot/modules/torrent_search.py | 4 +- bot/modules/ytdlp.py | 4 +- docker-compose.yml | 2 - update.py | 2 +- 44 files changed, 228 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/ruff.yml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml deleted file mode 100644 index c8a0958d..00000000 --- a/.github/workflows/ruff.yml +++ /dev/null @@ -1,8 +0,0 @@ -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/bot/__init__.py b/bot/__init__.py index 5f7e305a..92ef9d8c 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 Exception: +except: 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 Exception: + except: 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 Exception: +except: 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 Exception: + except: log_error(f"Wrong USENET_SERVERS format: {SEARCH_PLUGINS}") SEARCH_PLUGINS = "" diff --git a/bot/__main__.py b/bot/__main__.py index 903a256f..dbbd3aac 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -39,7 +39,26 @@ 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 # noqa: F401 +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): @@ -226,7 +245,7 @@ async def restart_notification(): await bot.edit_message_text( chat_id=chat_id, message_id=msg_id, text="Restarted Successfully!" ) - except Exception: + except: pass await remove(".restartmsg") diff --git a/bot/helper/common.py b/bot/helper/common.py index f78969b6..a884ea40 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 Exception: + except: raise ValueError("Start the bot and try again!") elif (self.userTransmission or self.mixedLeech) and not self.isSuperChat: self.userTransmission = False @@ -345,13 +345,18 @@ class TaskConfig: async def getTag(self, text: list): if len(text) > 1 and text[1].startswith("Tag: "): - self.tag, id_ = text[1].split("Tag: ")[1].split() + user_info = text[1].split("Tag: ") + if len(user_info) >= 3: + id_ = user_info[-1] + self.tag = " ".join(user_info[:-1]) + else: + self.tag, id_ = text[1].split("Tag: ")[1].split() self.user = self.message.from_user = await self.client.get_users(id_) self.userId = self.user.id self.userDict = user_data.get(self.userId, {}) try: await self.message.unpin() - except Exception: + except: pass if self.user: if username := self.user.username: @@ -453,7 +458,7 @@ class TaskConfig: self.multiTag, self.options, ).newEvent() - except Exception: + except: await sendMessage( self.message, "Reply to text file or to telegram message that have links seperated by new line!", @@ -510,7 +515,7 @@ class TaskConfig: if code != 0: try: stderr = stderr.decode().strip() - except Exception: + except: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Unable to extract archive splits!. Path: {f_path}" @@ -525,7 +530,7 @@ class TaskConfig: del_path = ospath.join(dirpath, file_) try: await remove(del_path) - except Exception: + except: self.isCancelled = True return up_path else: @@ -560,13 +565,13 @@ class TaskConfig: if not self.seed: try: await remove(dl_path) - except Exception: + except: self.isCancelled = True return up_path else: try: stderr = stderr.decode().strip() - except Exception: + except: stderr = "Unable to decode the error!" LOGGER.error( f"{stderr}. Unable to extract archive! Uploading anyway. Path: {dl_path}" @@ -642,7 +647,7 @@ class TaskConfig: if await aiopath.exists(f): try: await remove(f) - except Exception: + except: pass ft_delete.clear() return up_path @@ -652,7 +657,7 @@ class TaskConfig: self.newDir = "" try: stderr = stderr.decode().strip() - except Exception: + except: stderr = "Unable to decode the error!" LOGGER.error(f"{stderr}. Unable to zip this path: {dl_path}") return dl_path @@ -684,13 +689,13 @@ class TaskConfig: else: try: await remove(f_path) - except Exception: + except: return continue elif not self.seed or self.newDir: try: await remove(f_path) - except Exception: + except: return else: m_size.append(f_size) @@ -866,7 +871,7 @@ class TaskConfig: else: try: await remove(dl_path) - except Exception: + except: pass return output_file else: @@ -886,7 +891,7 @@ class TaskConfig: else: try: await remove(f_path) - except Exception: + except: pass if checked: cpu_eater_lock.release() @@ -932,7 +937,9 @@ class TaskConfig: up_dir, name = dl_path.rsplit("/", 1) for substitution in self.nameSub: pattern = substitution[0] - res = substitution[1] if len(substitution) > 1 and substitution[1] else "" + 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) @@ -944,7 +951,11 @@ class TaskConfig: f_path = ospath.join(dirpath, file_) for substitution in self.nameSub: pattern = substitution[0] - res = substitution[1] if len(substitution) > 1 and substitution[1] else "" + 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)) diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index f286ba42..e104c265 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: stdout = "Unable to decode the response!" try: stderr = stderr.decode().strip() - except Exception: + except: 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 bc8d3bb3..37faa620 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 Exception: + except: 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 28f3810e..d68f4466 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 Exception: + except: 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 619a1cb4..6a44ec93 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: stderr = "Unable to decode the error!" try: await remove(out_path) - except Exception: + except: pass if multi_streams: LOGGER.warning( @@ -488,14 +488,13 @@ async def split_file( elif code != 0: try: stderr = stderr.decode().strip() - except Exception: + except: stderr = "Unable to decode the error!" LOGGER.error(f"{stderr}. Split Document: {path}") return True async def createSampleVideo(listener, video_file, sample_duration, part_duration): - filter_complex = "" dir, name = video_file.rsplit("/", 1) output_file = f"{dir}/SAMPLE.{name}" segments = [(0, part_duration)] @@ -509,6 +508,7 @@ async def createSampleVideo(listener, video_file, sample_duration, part_duration next_segment += time_interval segments.append((duration - part_duration, duration)) + filter_complex = "" for i, (start, end) in enumerate(segments): filter_complex += ( f"[0:v]trim=start={start}:end={end},setpts=PTS-STARTPTS[v{i}]; " @@ -564,3 +564,90 @@ async def createSampleVideo(listener, video_file, sample_duration, part_duration if await aiopath.exists(output_file): await remove(output_file) return False + + """finished_segments = [] + await makedirs(f"{dir}/mltb_segments/", exist_ok=True) + ext = name.rsplit(".", 1)[-1] + for index, (start_time, end_time) in enumerate(segments, start=1): + output_seg = f"{dir}/mltb_segments/segment{index}.{ext}" + cmd = [ + "ffmpeg", + "-i", + video_file, + "-ss", + f"{start_time}", + "-to", + f"{end_time}", + "-c", + "copy", + output_seg, + ] + if listener.isCancelled: + return False + listener.suproc = await create_subprocess_exec(*cmd, stderr=PIPE) + _, stderr = await listener.suproc.communicate() + if listener.isCancelled: + return False + code = listener.suproc.returncode + if code == -9: + listener.isCancelled = True + return False + elif code != 0: + try: + stderr = stderr.decode().strip() + except: + 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}" + ) + if await aiopath.exists(output_file): + await remove(output_file) + return False + else: + finished_segments.append(f"file '{output_seg}'") + + segments_file = f"{dir}/segments.txt" + + async with aiopen(segments_file, "w+") as f: + await f.write("\n".join(finished_segments)) + + cmd = [ + "ffmpeg", + "-f", + "concat", + "-safe", + "0", + "-i", + segments_file, + "-c:v", + "libx264", + "-c:a", + "aac", + "-threads", + f"{cpu_count() // 2}", + output_file, + ] + if listener.isCancelled: + return False + listener.suproc = await create_subprocess_exec(*cmd, stderr=PIPE) + _, stderr = await listener.suproc.communicate() + if listener.isCancelled: + return False + code = listener.suproc.returncode + if code == -9: + listener.isCancelled = True + return False + elif code != 0: + try: + stderr = stderr.decode().strip() + except: + stderr = "Unable to decode the error!" + LOGGER.error( + f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}" + ) + if await aiopath.exists(output_file): + await remove(output_file) + await gather(remove(segments_file), rmtree(f"{dir}/mltb_segments")) + return False + await gather(remove(segments_file), rmtree(f"{dir}/mltb_segments")) + return output_file""" diff --git a/bot/helper/ext_utils/status_utils.py b/bot/helper/ext_utils/status_utils.py index e932cee0..57d58c64 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 Exception: + except: 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 8deaa9e2..ef8c3a8d 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 Exception: + except: name = None if name is not None: diff --git a/bot/helper/listeners/aria2_listener.py b/bot/helper/listeners/aria2_listener.py index 5e605339..09525a15 100644 --- a/bot/helper/listeners/aria2_listener.py +++ b/bot/helper/listeners/aria2_listener.py @@ -37,7 +37,7 @@ async def _onDownloadStarted(api, gid): if download.is_removed or download.followed_by_ids: await deleteMessage(meta) break - download = await sync_to_async(download.live) + await sync_to_async(download.update) return else: LOGGER.info(f"onDownloadStarted: {download.name} - Gid: {gid}") @@ -46,7 +46,7 @@ async def _onDownloadStarted(api, gid): if task := await getTaskByGid(gid): download = await sync_to_async(api.get_download, gid) await sleep(2) - download = await sync_to_async(download.live) + await sync_to_async(download.update) task.listener.name = download.name msg, button = await stop_duplicate_check(task.listener) if msg: @@ -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 Exception: + except: 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 Exception: + except: pass await clean_unwanted(download.dir) if task.listener.seed: @@ -127,10 +127,10 @@ async def _onBtDownloadComplete(api, gid): await task.listener.onDownloadComplete() if Intervals["stopAll"]: return - download = await sync_to_async(download.live) + await sync_to_async(download.update) if task.listener.seed: if download.is_complete: - if task := await getTaskByGid(gid): + if await getTaskByGid(gid): LOGGER.info(f"Cancelling Seed: {download.name}") await task.listener.onUploadError( f"Seeding stopped with Ratio: {task.ratio()} and Time: {task.seeding_time()}" @@ -170,7 +170,7 @@ async def _onDownloadError(api, gid): return error = download.error_message LOGGER.info(f"Download Error: {error}") - except Exception: + except: 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 70c35b94..4ebe49a5 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 Exception: + except: pass @@ -71,7 +71,7 @@ async def _jd_listener(): await wait_for( retry_function(jdownloader.device.jd.version), timeout=10 ) - except Exception: + except: 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 Exception: + except: 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 06659611..d4778f7d 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 Exception: + except: 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 a1e00546..fabef6c8 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 Exception: + except: 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 eb391400..0421a59d 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 @@ -242,7 +242,9 @@ def mediafire(url, session=None): if html.xpath("//div[@class='passwordPrompt']"): if not _password: session.close() - raise DirectDownloadLinkException(f"ERROR: {PASSWORD_ERROR_MESSAGE}".format(url)) + raise DirectDownloadLinkException( + f"ERROR: {PASSWORD_ERROR_MESSAGE}".format(url) + ) try: html = HTML(session.post(url, data={"downloadp": _password}).text) except Exception as e: @@ -396,7 +398,9 @@ def streamtape(url): html = HTML(session.get(url).text) except Exception as e: raise DirectDownloadLinkException(f"ERROR: {e.__class__.__name__}") from e - script = html.xpath("//script[contains(text(),'ideoooolink')]/text()") or html.xpath("//script[contains(text(),'ideoolink')]/text()") + script = html.xpath( + "//script[contains(text(),'ideoooolink')]/text()" + ) or html.xpath("//script[contains(text(),'ideoolink')]/text()") if not script: raise DirectDownloadLinkException("ERROR: requeries script not found") if not (link := findall(r"(&expires\S+)'", script[0])): @@ -833,7 +837,7 @@ def linkBox(url: str): parsed_url = urlparse(url) try: shareToken = parsed_url.path.split("/")[-1] - except Exception: + except: raise DirectDownloadLinkException("ERROR: invalid URL") details = {"contents": [], "title": "", "total_size": 0} @@ -893,7 +897,7 @@ def linkBox(url: str): try: if data["shareType"] == "singleItem": return __singleItem(session, data["itemId"]) - except Exception: + except: pass if not details["title"]: details["title"] = data["dirName"] @@ -1045,7 +1049,7 @@ def mediafireFolder(url): raw = url.split("/", 4)[-1] folderkey = raw.split("/", 1)[0] folderkey = folderkey.split(",") - except Exception: + except: raise DirectDownloadLinkException("ERROR: Could not parse ") if len(folderkey) == 1: folderkey = folderkey[0] @@ -1100,7 +1104,7 @@ def mediafireFolder(url): def __scraper(url): try: html = HTML(session.get(url).text) - except Exception: + except: return if final_link := html.xpath("//a[@id='downloadButton']/@href"): return final_link[0] @@ -1258,7 +1262,7 @@ def send_cm(url): ) if "Location" in _res.headers: return _res.headers["Location"] - except Exception: + except: pass def __getFiles(html): @@ -1630,7 +1634,7 @@ def mp4upload(url): data["referer"] = url direct_link = session.post(url, data=data).url return direct_link, header - except Exception: + except: 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 a05140ef..78983758 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 Exception: + except: 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 Exception: + except: 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 e81a7aec..32802459 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 Exception: + except: 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 a7d78e91..9a0edbd8 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 Exception: + except: 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 b5c65573..b1f5e712 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 Exception: + except: 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 c3507689..43e3f928 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 Exception: + except: 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 09c094a9..fa649c31 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 Exception: + except: self.id = "Timed Out. Task has been cancelled!" self.listener.isCancelled = True self.event.set() diff --git a/bot/helper/mirror_leech_utils/gdrive_utils/upload.py b/bot/helper/mirror_leech_utils/gdrive_utils/upload.py index 94093d56..9826097e 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 Exception: + except: 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 408f7ef7..4c77549b 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 Exception: + except: 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 e4398680..cf6ec0be 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 Exception: + except: pass return config = ConfigParser() @@ -32,7 +32,7 @@ async def rclone_serve_booter(): try: RcloneServe[0].kill() RcloneServe.clear() - except Exception: + except: 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 1e8b16b3..8b6faa9e 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 Exception: + except: continue if not data: break @@ -401,9 +401,8 @@ class RcloneTransferHelper: return None, None elif return_code != 0: error = ( - (await self._proc.stderr.read()).decode().strip() - or "Use /shell cat rlog.txt to see more information" - ) + await self._proc.stderr.read() + ).decode().strip() or "Use /shell cat rlog.txt to see more information" LOGGER.error(error) await self._listener.onUploadError(error[:4000]) return None, None @@ -492,7 +491,7 @@ class RcloneTransferHelper: if self._proc is not None: try: self._proc.kill() - except Exception: + except: 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 906034ed..f37bc3cf 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 Exception: + except: 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 Exception: + except: 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 76fe3aa7..f96bd95c 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 Exception: + except: 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 Exception: + except: 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 ce3205fd..1c93a42c 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 Exception: + except: 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 Exception: + except: 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 e01e9a2f..9e40cd42 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: 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 74b06039..287b064a 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 Exception: + except: 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 62460098..cdc23859 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 Exception: + except: 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 Exception: + except: 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 5b95c5bd..7256253d 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 Exception: + except: 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 a28ac7e8..03704aba 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 Exception: + except: 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 Exception: + except: 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 27cac6ec..54ba233e 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 Exception: + except: return 0 @property diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py index 0f10d634..5a0d9f38 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: LOGGER.error(f"Wrong SEARCH_PLUGINS fornat {SEARCH_PLUGINS}") SEARCH_PLUGINS = "" diff --git a/bot/modules/clone.py b/bot/modules/clone.py index 0f523ba6..b7a27d3d 100644 --- a/bot/modules/clone.py +++ b/bot/modules/clone.py @@ -81,7 +81,7 @@ class Clone(TaskListener): try: self.multi = int(args["-i"]) - except Exception: + except: self.multi = 0 self.upDest = args["-up"] diff --git a/bot/modules/exec.py b/bot/modules/exec.py index e18c8955..dac91bd4 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 Exception: + except: 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 Exception: + except: pass else: result = f"{value}{func_return}" diff --git a/bot/modules/file_selector.py b/bot/modules/file_selector.py index c7b8a76c..eb704e6d 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 Exception: + except: 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 Exception: + except: 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 Exception: + except: pass if not task.queued: try: diff --git a/bot/modules/mirror_leech.py b/bot/modules/mirror_leech.py index d62a355c..117d2ed8 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 Exception: + except: self.multi = 0 if not isinstance(self.seed, bool): diff --git a/bot/modules/rss.py b/bot/modules/rss.py index f69aa315..41d72202 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 Exception: + except: tries += 1 if tries > 3: raise @@ -677,7 +677,7 @@ async def rssMonitor(): while True: try: await sleep(10) - except Exception: + except: 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 4909b53d..ac56c483 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 Exception: + except: 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 Exception: + except: continue else: msg += f"{escape(result.fileName)}
" diff --git a/bot/modules/ytdlp.py b/bot/modules/ytdlp.py index 096ef6f7..97132030 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 Exception: + except: 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 Exception: + except: self.multi = 0 self.select = args["-s"] diff --git a/docker-compose.yml b/docker-compose.yml index 39120121..5b0d142b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.9" - services: app: build: . diff --git a/update.py b/update.py index 044fb7be..37d21a43 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 Exception: +except: pass BOT_TOKEN = environ.get("BOT_TOKEN", "")