added missing buttons = Button maker() in list.py and added ruff checkout.

This commit is contained in:
5hojib 2024-07-15 11:56:27 +06:00
parent d18c00a394
commit 66483eaf96
47 changed files with 153 additions and 124 deletions

8
.github/workflows/ruff.yml vendored Normal file
View File

@ -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

0
aria-nox-nzb.sh Executable file → Normal file
View File

View File

@ -73,7 +73,7 @@ try:
if bool(environ.get("_____REMOVE_THIS_LINE_____")): if bool(environ.get("_____REMOVE_THIS_LINE_____")):
log_error("The README.md file there to be read! Exiting now!") log_error("The README.md file there to be read! Exiting now!")
exit(1) exit(1)
except: except Exception:
pass pass
task_dict_lock = Lock() task_dict_lock = Lock()
@ -192,7 +192,7 @@ if len(USER_SESSION_STRING) != 0:
max_concurrent_transmissions=10, max_concurrent_transmissions=10,
).start() ).start()
IS_PREMIUM_USER = user.me.is_premium IS_PREMIUM_USER = user.me.is_premium
except: except Exception:
log_error("Failed to start client from USER_SESSION_STRING") log_error("Failed to start client from USER_SESSION_STRING")
IS_PREMIUM_USER = False IS_PREMIUM_USER = False
user = "" user = ""
@ -255,7 +255,7 @@ try:
USENET_SERVERS = [] USENET_SERVERS = []
else: else:
USENET_SERVERS = eval(USENET_SERVERS) USENET_SERVERS = eval(USENET_SERVERS)
except: except Exception:
log_error(f"Wrong USENET_SERVERS format: {USENET_SERVERS}") log_error(f"Wrong USENET_SERVERS format: {USENET_SERVERS}")
USENET_SERVERS = [] USENET_SERVERS = []
@ -285,7 +285,7 @@ if len(SEARCH_PLUGINS) == 0:
else: else:
try: try:
SEARCH_PLUGINS = eval(SEARCH_PLUGINS) SEARCH_PLUGINS = eval(SEARCH_PLUGINS)
except: except Exception:
log_error(f"Wrong USENET_SERVERS format: {SEARCH_PLUGINS}") log_error(f"Wrong USENET_SERVERS format: {SEARCH_PLUGINS}")
SEARCH_PLUGINS = "" SEARCH_PLUGINS = ""

View File

@ -39,26 +39,7 @@ from .helper.telegram_helper.bot_commands import BotCommands
from .helper.telegram_helper.button_build import ButtonMaker from .helper.telegram_helper.button_build import ButtonMaker
from .helper.telegram_helper.filters import CustomFilters from .helper.telegram_helper.filters import CustomFilters
from .helper.telegram_helper.message_utils import sendMessage, editMessage, sendFile from .helper.telegram_helper.message_utils import sendMessage, editMessage, sendFile
from .modules import ( 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
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,
)
async def stats(_, message): async def stats(_, message):
@ -245,7 +226,7 @@ async def restart_notification():
await bot.edit_message_text( await bot.edit_message_text(
chat_id=chat_id, message_id=msg_id, text="Restarted Successfully!" chat_id=chat_id, message_id=msg_id, text="Restarted Successfully!"
) )
except: except Exception:
pass pass
await remove(".restartmsg") await remove(".restartmsg")

View File

@ -310,7 +310,7 @@ class TaskConfig:
await self.client.send_chat_action( await self.client.send_chat_action(
self.upDest, ChatAction.TYPING self.upDest, ChatAction.TYPING
) )
except: except Exception:
raise ValueError("Start the bot and try again!") raise ValueError("Start the bot and try again!")
elif (self.userTransmission or self.mixedLeech) and not self.isSuperChat: elif (self.userTransmission or self.mixedLeech) and not self.isSuperChat:
self.userTransmission = False self.userTransmission = False
@ -351,7 +351,7 @@ class TaskConfig:
self.userDict = user_data.get(self.userId, {}) self.userDict = user_data.get(self.userId, {})
try: try:
await self.message.unpin() await self.message.unpin()
except: except Exception:
pass pass
if self.user: if self.user:
if username := self.user.username: if username := self.user.username:
@ -453,7 +453,7 @@ class TaskConfig:
self.multiTag, self.multiTag,
self.options, self.options,
).newEvent() ).newEvent()
except: except Exception:
await sendMessage( await sendMessage(
self.message, self.message,
"Reply to text file or to telegram message that have links seperated by new line!", "Reply to text file or to telegram message that have links seperated by new line!",
@ -510,7 +510,7 @@ class TaskConfig:
if code != 0: if code != 0:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error( LOGGER.error(
f"{stderr}. Unable to extract archive splits!. Path: {f_path}" f"{stderr}. Unable to extract archive splits!. Path: {f_path}"
@ -525,7 +525,7 @@ class TaskConfig:
del_path = ospath.join(dirpath, file_) del_path = ospath.join(dirpath, file_)
try: try:
await remove(del_path) await remove(del_path)
except: except Exception:
self.isCancelled = True self.isCancelled = True
return up_path return up_path
else: else:
@ -560,13 +560,13 @@ class TaskConfig:
if not self.seed: if not self.seed:
try: try:
await remove(dl_path) await remove(dl_path)
except: except Exception:
self.isCancelled = True self.isCancelled = True
return up_path return up_path
else: else:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error( LOGGER.error(
f"{stderr}. Unable to extract archive! Uploading anyway. Path: {dl_path}" f"{stderr}. Unable to extract archive! Uploading anyway. Path: {dl_path}"
@ -642,7 +642,7 @@ class TaskConfig:
if await aiopath.exists(f): if await aiopath.exists(f):
try: try:
await remove(f) await remove(f)
except: except Exception:
pass pass
ft_delete.clear() ft_delete.clear()
return up_path return up_path
@ -652,7 +652,7 @@ class TaskConfig:
self.newDir = "" self.newDir = ""
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error(f"{stderr}. Unable to zip this path: {dl_path}") LOGGER.error(f"{stderr}. Unable to zip this path: {dl_path}")
return dl_path return dl_path
@ -684,13 +684,13 @@ class TaskConfig:
else: else:
try: try:
await remove(f_path) await remove(f_path)
except: except Exception:
return return
continue continue
elif not self.seed or self.newDir: elif not self.seed or self.newDir:
try: try:
await remove(f_path) await remove(f_path)
except: except Exception:
return return
else: else:
m_size.append(f_size) m_size.append(f_size)
@ -866,7 +866,7 @@ class TaskConfig:
else: else:
try: try:
await remove(dl_path) await remove(dl_path)
except: except Exception:
pass pass
return output_file return output_file
else: else:
@ -886,7 +886,7 @@ class TaskConfig:
else: else:
try: try:
await remove(f_path) await remove(f_path)
except: except Exception:
pass pass
if checked: if checked:
cpu_eater_lock.release() cpu_eater_lock.release()
@ -930,10 +930,10 @@ class TaskConfig:
async def substitute(self, dl_path): async def substitute(self, dl_path):
if await aiopath.isfile(dl_path): if await aiopath.isfile(dl_path):
up_dir, name = dl_path.rsplit("/", 1) up_dir, name = dl_path.rsplit("/", 1)
for l in self.nameSub: for substitution in self.nameSub:
pattern = l[0] pattern = substitution[0]
res = l[1] if len(l) > 1 and l[1] else "" res = substitution[1] if len(substitution) > 1 and substitution[1] else ""
sen = len(l) > 2 and l[2] == "s" sen = len(substitution) > 2 and substitution[2] == "s"
new_name = sub(rf"{pattern}", res, name, flags=I if sen else 0) new_name = sub(rf"{pattern}", res, name, flags=I if sen else 0)
new_path = ospath.join(up_dir, new_name) new_path = ospath.join(up_dir, new_name)
await move(dl_path, new_path) 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 dirpath, _, files in await sync_to_async(walk, dl_path, topdown=False):
for file_ in files: for file_ in files:
f_path = ospath.join(dirpath, file_) f_path = ospath.join(dirpath, file_)
for l in self.nameSub: for substitution in self.nameSub:
pattern = l[0] pattern = substitution[0]
res = l[1] if len(l) > 1 and l[1] else "" res = substitution[1] if len(substitution) > 1 and substitution[1] else ""
sen = len(l) > 2 and l[2] == "s" sen = len(substitution) > 2 and substitution[2] == "s"
new_name = sub(rf"{pattern}", res, file_, flags=I if sen else 0) new_name = sub(rf"{pattern}", res, file_, flags=I if sen else 0)
await move(f_path, ospath.join(dirpath, new_name)) await move(f_path, ospath.join(dirpath, new_name))
return dl_path return dl_path

View File

@ -163,7 +163,7 @@ async def get_content_type(url):
async with AsyncClient() as client: async with AsyncClient() as client:
response = await client.get(url, allow_redirects=True, verify=False) response = await client.get(url, allow_redirects=True, verify=False)
return response.headers.get("Content-Type") return response.headers.get("Content-Type")
except: except Exception:
return None return None
@ -175,7 +175,7 @@ def update_user_ldata(id_, key, value):
async def retry_function(func, *args, **kwargs): async def retry_function(func, *args, **kwargs):
try: try:
return await func(*args, **kwargs) return await func(*args, **kwargs)
except: except Exception:
return await retry_function(func, *args, **kwargs) return await retry_function(func, *args, **kwargs)
@ -187,11 +187,11 @@ async def cmd_exec(cmd, shell=False):
stdout, stderr = await proc.communicate() stdout, stderr = await proc.communicate()
try: try:
stdout = stdout.decode().strip() stdout = stdout.decode().strip()
except: except Exception:
stdout = "Unable to decode the response!" stdout = "Unable to decode the response!"
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
return stdout, stderr, proc.returncode return stdout, stderr, proc.returncode

View File

@ -95,7 +95,7 @@ def clean_all():
try: try:
LOGGER.info("Cleaning Download Directory") LOGGER.info("Cleaning Download Directory")
rmtree(DOWNLOAD_DIR, ignore_errors=True) rmtree(DOWNLOAD_DIR, ignore_errors=True)
except: except Exception:
pass pass
makedirs(DOWNLOAD_DIR, exist_ok=True) makedirs(DOWNLOAD_DIR, exist_ok=True)

View File

@ -124,7 +124,7 @@ class JDownloader(Myjdapi):
break break
else: else:
continue continue
except: except Exception:
continue continue
break break
await self.device.enable_direct_connection() await self.device.enable_direct_connection()

View File

@ -57,7 +57,7 @@ async def convert_video(listener, video_file, ext, retry=False):
else: else:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error( LOGGER.error(
f"{stderr}. Something went wrong while converting video, mostly file need specific codec. Path: {video_file}" 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: else:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error( LOGGER.error(
f"{stderr}. Something went wrong while converting audio, mostly file need specific codec. Path: {audio_file}" 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) await rmtree(dirpath, ignore_errors=True)
return False return False
except: except Exception:
LOGGER.error( LOGGER.error(
f"Error while creating sreenshots from video. Path: {video_file}. Error: Timeout some issues with ffmpeg with specific arch!" 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}" f"Error while extracting thumbnail from video. Name: {video_file} stderr: {err}"
) )
return None return None
except: except Exception:
LOGGER.error( LOGGER.error(
f"Error while extracting thumbnail from video. Name: {video_file}. Error: Timeout some issues with ffmpeg with specific arch!" 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: elif code != 0:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
try: try:
await remove(out_path) await remove(out_path)
except: except Exception:
pass pass
if multi_streams: if multi_streams:
LOGGER.warning( LOGGER.warning(
@ -488,7 +488,7 @@ async def split_file(
elif code != 0: elif code != 0:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error(f"{stderr}. Split Document: {path}") LOGGER.error(f"{stderr}. Split Document: {path}")
return True return True
@ -556,7 +556,7 @@ async def createSampleVideo(listener, video_file, sample_duration, part_duration
else: else:
try: try:
stderr = stderr.decode().strip() stderr = stderr.decode().strip()
except: except Exception:
stderr = "Unable to decode the error!" stderr = "Unable to decode the error!"
LOGGER.error( LOGGER.error(
f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}" f"{stderr}. Something went wrong while creating sample video, mostly file is corrupted. Path: {video_file}"

View File

@ -193,7 +193,7 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=
if hasattr(task, "seeders_num"): if hasattr(task, "seeders_num"):
try: try:
msg += f"\n<b>Seeders:</b> {task.seeders_num()} | <b>Leechers:</b> {task.leechers_num()}" msg += f"\n<b>Seeders:</b> {task.seeders_num()} | <b>Leechers:</b> {task.leechers_num()}"
except: except Exception:
pass pass
elif tstatus == MirrorStatus.STATUS_SEEDING: elif tstatus == MirrorStatus.STATUS_SEEDING:
msg += f"\n<b>Size: </b>{task.size()}" msg += f"\n<b>Size: </b>{task.size()}"

View File

@ -38,7 +38,7 @@ async def stop_duplicate_check(listener):
elif listener.extract: elif listener.extract:
try: try:
name = get_base_name(name) name = get_base_name(name)
except: except Exception:
name = None name = None
if name is not None: if name is not None:

View File

@ -59,7 +59,7 @@ async def _onDownloadStarted(api, gid):
async def _onDownloadComplete(api, gid): async def _onDownloadComplete(api, gid):
try: try:
download = await sync_to_async(api.get_download, gid) download = await sync_to_async(api.get_download, gid)
except: except Exception:
return return
if download.options.follow_torrent == "false": if download.options.follow_torrent == "false":
return return
@ -107,7 +107,7 @@ async def _onBtDownloadComplete(api, gid):
if not file_o.selected and await aiopath.exists(f_path): if not file_o.selected and await aiopath.exists(f_path):
try: try:
await remove(f_path) await remove(f_path)
except: except Exception:
pass pass
await clean_unwanted(download.dir) await clean_unwanted(download.dir)
if task.listener.seed: if task.listener.seed:
@ -170,7 +170,7 @@ async def _onDownloadError(api, gid):
return return
error = download.error_message error = download.error_message
LOGGER.info(f"Download Error: {error}") LOGGER.info(f"Download Error: {error}")
except: except Exception:
pass pass
if task := await getTaskByGid(gid): if task := await getTaskByGid(gid):
await task.listener.onDownloadError(error) await task.listener.onDownloadError(error)

View File

@ -17,7 +17,7 @@ async def update_download(gid, value):
task._gid = new_gid task._gid = new_gid
async with jd_lock: async with jd_lock:
del jd_downloads[gid] del jd_downloads[gid]
except: except Exception:
pass pass
@ -71,7 +71,7 @@ async def _jd_listener():
await wait_for( await wait_for(
retry_function(jdownloader.device.jd.version), timeout=10 retry_function(jdownloader.device.jd.version), timeout=10
) )
except: except Exception:
is_connected = await jdownloader.jdconnect() is_connected = await jdownloader.jdconnect()
if not is_connected: if not is_connected:
LOGGER.error(jdownloader.error) LOGGER.error(jdownloader.error)
@ -84,7 +84,7 @@ async def _jd_listener():
packages = await jdownloader.device.downloads.query_packages( packages = await jdownloader.device.downloads.query_packages(
[{"finished": True}] [{"finished": True}]
) )
except: except Exception:
continue continue
finished = [ finished = [
pack["uuid"] for pack in packages if pack.get("finished", False) pack["uuid"] for pack in packages if pack.get("finished", False)

View File

@ -83,7 +83,7 @@ async def _onDownloadComplete(tor):
if f.priority == 0 and await aiopath.exists(f"{path}/{f.name}"): if f.priority == 0 and await aiopath.exists(f"{path}/{f.name}"):
try: try:
await remove(f"{path}/{f.name}") await remove(f"{path}/{f.name}")
except: except Exception:
pass pass
await task.listener.onDownloadComplete() await task.listener.onDownloadComplete()
if Intervals["stopAll"]: if Intervals["stopAll"]:

View File

@ -57,7 +57,7 @@ class TaskListener(TaskConfig):
intvl.cancel() intvl.cancel()
Intervals["status"].clear() Intervals["status"].clear()
await gather(sync_to_async(aria2.purge), delete_status()) await gather(sync_to_async(aria2.purge), delete_status())
except: except Exception:
pass pass
def removeFromSameDir(self): def removeFromSameDir(self):

View File

@ -816,7 +816,7 @@ def linkBox(url: str):
parsed_url = urlparse(url) parsed_url = urlparse(url)
try: try:
shareToken = parsed_url.path.split("/")[-1] shareToken = parsed_url.path.split("/")[-1]
except: except Exception:
raise DirectDownloadLinkException("ERROR: invalid URL") raise DirectDownloadLinkException("ERROR: invalid URL")
details = {"contents": [], "title": "", "total_size": 0} details = {"contents": [], "title": "", "total_size": 0}
@ -876,7 +876,7 @@ def linkBox(url: str):
try: try:
if data["shareType"] == "singleItem": if data["shareType"] == "singleItem":
return __singleItem(session, data["itemId"]) return __singleItem(session, data["itemId"])
except: except Exception:
pass pass
if not details["title"]: if not details["title"]:
details["title"] = data["dirName"] details["title"] = data["dirName"]
@ -1028,7 +1028,7 @@ def mediafireFolder(url):
raw = url.split("/", 4)[-1] raw = url.split("/", 4)[-1]
folderkey = raw.split("/", 1)[0] folderkey = raw.split("/", 1)[0]
folderkey = folderkey.split(",") folderkey = folderkey.split(",")
except: except Exception:
raise DirectDownloadLinkException("ERROR: Could not parse ") raise DirectDownloadLinkException("ERROR: Could not parse ")
if len(folderkey) == 1: if len(folderkey) == 1:
folderkey = folderkey[0] folderkey = folderkey[0]
@ -1083,7 +1083,7 @@ def mediafireFolder(url):
def __scraper(url): def __scraper(url):
try: try:
html = HTML(session.get(url).text) html = HTML(session.get(url).text)
except: except Exception:
return return
if final_link := html.xpath("//a[@id='downloadButton']/@href"): if final_link := html.xpath("//a[@id='downloadButton']/@href"):
return final_link[0] return final_link[0]
@ -1241,7 +1241,7 @@ def send_cm(url):
) )
if "Location" in _res.headers: if "Location" in _res.headers:
return _res.headers["Location"] return _res.headers["Location"]
except: except Exception:
pass pass
def __getFiles(html): def __getFiles(html):
@ -1613,7 +1613,7 @@ def mp4upload(url):
data["referer"] = url data["referer"] = url
direct_link = session.post(url, data=data).url direct_link = session.post(url, data=data).url
return direct_link, header return direct_link, header
except: except Exception:
raise DirectDownloadLinkException("ERROR: File Not Found!") raise DirectDownloadLinkException("ERROR: File Not Found!")

View File

@ -67,7 +67,7 @@ class JDownloaderHelper:
) )
try: try:
await wait_for(self.event.wait(), timeout=self._timeout) await wait_for(self.event.wait(), timeout=self._timeout)
except: except Exception:
await editMessage(self._reply_to, "Timed Out. Task has been cancelled!") await editMessage(self._reply_to, "Timed Out. Task has been cancelled!")
self.listener.isCancelled = True self.listener.isCancelled = True
self.event.set() self.event.set()
@ -97,7 +97,7 @@ async def add_jd_download(listener, path):
try: try:
await wait_for(retry_function(jdownloader.device.jd.version), timeout=10) await wait_for(retry_function(jdownloader.device.jd.version), timeout=10)
except: except Exception:
is_connected = await jdownloader.jdconnect() is_connected = await jdownloader.jdconnect()
if not is_connected: if not is_connected:
await listener.onDownloadError(jdownloader.error) await listener.onDownloadError(jdownloader.error)

View File

@ -110,7 +110,7 @@ async def add_qb_torrent(listener, path, ratio, seed_time):
]: ]:
await deleteMessage(meta) await deleteMessage(meta)
break break
except: except Exception:
await deleteMessage(meta) await deleteMessage(meta)
return return

View File

@ -64,7 +64,7 @@ class TelegramDownloadHelper:
async with global_lock: async with global_lock:
try: try:
GLOBAL_GID.remove(self._id) GLOBAL_GID.remove(self._id)
except: except Exception:
pass pass
await self._listener.onDownloadError(error) await self._listener.onDownloadError(error)

View File

@ -115,7 +115,7 @@ class YoutubeDLHelper:
self._eta = d.get("eta", "-") or "-" self._eta = d.get("eta", "-") or "-"
try: try:
self._progress = (self._downloaded_bytes / self._listener.size) * 100 self._progress = (self._downloaded_bytes / self._listener.size) * 100
except: except Exception:
pass pass
async def _onDownloadStart(self, from_queue=False): async def _onDownloadStart(self, from_queue=False):

View File

@ -52,7 +52,7 @@ class GoogleDriveHelper:
def speed(self): def speed(self):
try: try:
return self.proc_bytes / self.total_time return self.proc_bytes / self.total_time
except: except Exception:
return 0 return 0
@property @property

View File

@ -145,7 +145,7 @@ class gdriveList(GoogleDriveHelper):
) )
try: try:
await wait_for(self.event.wait(), timeout=self._timeout) await wait_for(self.event.wait(), timeout=self._timeout)
except: except Exception:
self.id = "Timed Out. Task has been cancelled!" self.id = "Timed Out. Task has been cancelled!"
self.listener.isCancelled = True self.listener.isCancelled = True
self.event.set() self.event.set()
@ -263,6 +263,7 @@ class gdriveList(GoogleDriveHelper):
await self.get_items() await self.get_items()
elif len(drives) == 0: elif len(drives) == 0:
msg = "Service accounts Doesn't have access to any drive!" msg = "Service accounts Doesn't have access to any drive!"
buttons = ButtonMaker()
if self._token_user and self._token_owner: if self._token_user and self._token_owner:
buttons.ibutton("Back", "gdq back dr", position="footer") buttons.ibutton("Back", "gdq back dr", position="footer")
buttons.ibutton("Cancel", "gdq cancel", position="footer") buttons.ibutton("Cancel", "gdq cancel", position="footer")

View File

@ -223,7 +223,7 @@ class gdUpload(GoogleDriveHelper):
if not self.listener.seed or self.listener.newDir or file_path in ft_delete: if not self.listener.seed or self.listener.newDir or file_path in ft_delete:
try: try:
remove(file_path) remove(file_path)
except: except Exception:
pass pass
self.file_processed_bytes = 0 self.file_processed_bytes = 0
# Insert new permissions # Insert new permissions

View File

@ -140,7 +140,7 @@ class RcloneList:
) )
try: try:
await wait_for(self.event.wait(), timeout=self._timeout) await wait_for(self.event.wait(), timeout=self._timeout)
except: except Exception:
self.path = "" self.path = ""
self.remote = "Timed Out. Task has been cancelled!" self.remote = "Timed Out. Task has been cancelled!"
self.listener.isCancelled = True self.listener.isCancelled = True

View File

@ -14,7 +14,7 @@ async def rclone_serve_booter():
try: try:
RcloneServe[0].kill() RcloneServe[0].kill()
RcloneServe.clear() RcloneServe.clear()
except: except Exception:
pass pass
return return
config = ConfigParser() config = ConfigParser()
@ -32,7 +32,7 @@ async def rclone_serve_booter():
try: try:
RcloneServe[0].kill() RcloneServe[0].kill()
RcloneServe.clear() RcloneServe.clear()
except: except Exception:
pass pass
cmd = [ cmd = [
"rclone", "rclone",

View File

@ -59,7 +59,7 @@ class RcloneTransferHelper:
while not (self._proc is None or self._listener.isCancelled): while not (self._proc is None or self._listener.isCancelled):
try: try:
data = (await self._proc.stdout.readline()).decode() data = (await self._proc.stdout.readline()).decode()
except: except Exception:
continue continue
if not data: if not data:
break break
@ -492,7 +492,7 @@ class RcloneTransferHelper:
if self._proc is not None: if self._proc is not None:
try: try:
self._proc.kill() self._proc.kill()
except: except Exception:
pass pass
if self._is_download: if self._is_download:
LOGGER.info(f"Cancelling Download: {self._listener.name}") LOGGER.info(f"Cancelling Download: {self._listener.name}")

View File

@ -17,7 +17,7 @@ class DirectStatus:
def progress_raw(self): def progress_raw(self):
try: try:
return self._obj.processed_bytes / self.listener.size * 100 return self._obj.processed_bytes / self.listener.size * 100
except: except Exception:
return 0 return 0
def progress(self): def progress(self):
@ -36,7 +36,7 @@ class DirectStatus:
try: try:
seconds = (self.listener.size - self._obj.processed_bytes) / self._obj.speed seconds = (self.listener.size - self._obj.processed_bytes) / self._obj.speed
return get_readable_time(seconds) return get_readable_time(seconds)
except: except Exception:
return "-" return "-"
def status(self): def status(self):

View File

@ -27,7 +27,7 @@ class ExtractStatus:
await self.processed_raw() await self.processed_raw()
try: try:
return self._proccessed_bytes / self._size * 100 return self._proccessed_bytes / self._size * 100
except: except Exception:
return 0 return 0
async def progress(self): async def progress(self):
@ -46,7 +46,7 @@ class ExtractStatus:
try: try:
seconds = (self._size - self._proccessed_bytes) / self.speed_raw() seconds = (self._size - self._proccessed_bytes) / self.speed_raw()
return get_readable_time(seconds) return get_readable_time(seconds)
except: except Exception:
return "-" return "-"
def status(self): def status(self):

View File

@ -36,7 +36,7 @@ class GdriveStatus:
def progress_raw(self): def progress_raw(self):
try: try:
return self._obj.processed_bytes / self._size * 100 return self._obj.processed_bytes / self._size * 100
except: except Exception:
return 0 return 0
def progress(self): def progress(self):
@ -49,7 +49,7 @@ class GdriveStatus:
try: try:
seconds = (self._size - self._obj.processed_bytes) / self._obj.speed seconds = (self._size - self._obj.processed_bytes) / self._obj.speed
return get_readable_time(seconds) return get_readable_time(seconds)
except: except Exception:
return "-" return "-"
def task(self): def task(self):

View File

@ -26,7 +26,7 @@ def _get_combined_info(result):
status = "UnknownError" status = "UnknownError"
try: try:
eta = (bytesTotal - bytesLoaded) / speed eta = (bytesTotal - bytesLoaded) / speed
except: except Exception:
eta = 0 eta = 0
return { return {
"name": name, "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] return _get_combined_info(result) if len(result) > 1 else result[0]
except: except Exception:
return old_info return old_info
@ -72,7 +72,7 @@ class JDownloaderStatus:
def progress(self): def progress(self):
try: try:
return f"{round((self._info.get('bytesLoaded', 0) / self._info.get('bytesTotal', 0)) * 100, 2)}%" return f"{round((self._info.get('bytesLoaded', 0) / self._info.get('bytesTotal', 0)) * 100, 2)}%"
except: except Exception:
return "0%" return "0%"
def processed_bytes(self): def processed_bytes(self):

View File

@ -47,7 +47,7 @@ class SabnzbdStatus:
def speed_raw(self): def speed_raw(self):
try: try:
return int(float(self._info["mb"]) * 1048576) / self.eta_raw() return int(float(self._info["mb"]) * 1048576) / self.eta_raw()
except: except Exception:
return 0 return 0
def speed(self): def speed(self):

View File

@ -30,7 +30,7 @@ class TelegramStatus:
def progress(self): def progress(self):
try: try:
progress_raw = self._obj.processed_bytes / self._size * 100 progress_raw = self._obj.processed_bytes / self._size * 100
except: except Exception:
progress_raw = 0 progress_raw = 0
return f"{round(progress_raw, 2)}%" return f"{round(progress_raw, 2)}%"
@ -41,7 +41,7 @@ class TelegramStatus:
try: try:
seconds = (self._size - self._obj.processed_bytes) / self._obj.speed seconds = (self._size - self._obj.processed_bytes) / self._obj.speed
return get_readable_time(seconds) return get_readable_time(seconds)
except: except Exception:
return "-" return "-"
def gid(self): def gid(self):

View File

@ -49,7 +49,7 @@ class YtDlpDownloadStatus:
self._obj.size - self._proccessed_bytes self._obj.size - self._proccessed_bytes
) / self._obj.download_speed ) / self._obj.download_speed
return get_readable_time(seconds) return get_readable_time(seconds)
except: except Exception:
return "-" return "-"
def task(self): def task(self):

View File

@ -27,7 +27,7 @@ class ZipStatus:
await self.processed_raw() await self.processed_raw()
try: try:
return self._proccessed_bytes / self._size * 100 return self._proccessed_bytes / self._size * 100
except: except Exception:
return 0 return 0
async def progress(self): async def progress(self):
@ -46,7 +46,7 @@ class ZipStatus:
try: try:
seconds = (self._size - self._proccessed_bytes) / self.speed_raw() seconds = (self._size - self._proccessed_bytes) / self.speed_raw()
return get_readable_time(seconds) return get_readable_time(seconds)
except: except Exception:
return "-" return "-"
def status(self): def status(self):

View File

@ -497,7 +497,7 @@ class TgUploader:
def speed(self): def speed(self):
try: try:
return self._processed_bytes / (time() - self._start_time) return self._processed_bytes / (time() - self._start_time)
except: except Exception:
return 0 return 0
@property @property

View File

@ -412,7 +412,7 @@ async def edit_nzb_server(_, message, pre_message, key, index=0):
if key == "newser": if key == "newser":
try: try:
value = eval(value) value = eval(value)
except: except Exception:
await sendMessage(message, "Invalid dict format!") await sendMessage(message, "Invalid dict format!")
await update_buttons(pre_message, "nzbserver") await update_buttons(pre_message, "nzbserver")
return return
@ -446,7 +446,7 @@ async def sync_jdownloader():
return return
try: try:
await wait_for(retry_function(jdownloader.update_devices), timeout=10) await wait_for(retry_function(jdownloader.update_devices), timeout=10)
except: except Exception:
is_connected = await jdownloader.jdconnect() is_connected = await jdownloader.jdconnect()
if not is_connected: if not is_connected:
LOGGER.error(jdownloader.error) LOGGER.error(jdownloader.error)
@ -999,7 +999,7 @@ async def load_config():
USENET_SERVERS = [] USENET_SERVERS = []
else: else:
USENET_SERVERS = eval(USENET_SERVERS) USENET_SERVERS = eval(USENET_SERVERS)
except: except Exception:
LOGGER.error(f"Wrong USENET_SERVERS format: {USENET_SERVERS}") LOGGER.error(f"Wrong USENET_SERVERS format: {USENET_SERVERS}")
USENET_SERVERS = [] USENET_SERVERS = []
@ -1029,7 +1029,7 @@ async def load_config():
else: else:
try: try:
SEARCH_PLUGINS = eval(SEARCH_PLUGINS) SEARCH_PLUGINS = eval(SEARCH_PLUGINS)
except: except Exception:
LOGGER.error(f"Wrong SEARCH_PLUGINS fornat {SEARCH_PLUGINS}") LOGGER.error(f"Wrong SEARCH_PLUGINS fornat {SEARCH_PLUGINS}")
SEARCH_PLUGINS = "" SEARCH_PLUGINS = ""

View File

@ -8,7 +8,6 @@ from bot import LOGGER, task_dict, task_dict_lock, bot
from bot.helper.ext_utils.bot_utils import ( from bot.helper.ext_utils.bot_utils import (
new_task, new_task,
sync_to_async, sync_to_async,
new_task,
cmd_exec, cmd_exec,
arg_parser, arg_parser,
COMMAND_USAGE, COMMAND_USAGE,
@ -82,7 +81,7 @@ class Clone(TaskListener):
try: try:
self.multi = int(args["-i"]) self.multi = int(args["-i"])
except: except Exception:
self.multi = 0 self.multi = 0
self.upDest = args["-up"] self.upDest = args["-up"]

View File

@ -88,7 +88,7 @@ async def do(func, message):
func_return = ( func_return = (
await sync_to_async(rfunc) if func == "exec" else await rfunc() await sync_to_async(rfunc) if func == "exec" else await rfunc()
) )
except: except Exception:
value = stdout.getvalue() value = stdout.getvalue()
return f"{value}{format_exc()}" return f"{value}{format_exc()}"
else: else:
@ -100,7 +100,7 @@ async def do(func, message):
else: else:
try: try:
result = f"{repr(await sync_to_async(eval, body, env))}" result = f"{repr(await sync_to_async(eval, body, env))}"
except: except Exception:
pass pass
else: else:
result = f"{value}{func_return}" result = f"{value}{func_return}"

View File

@ -93,7 +93,7 @@ async def select(_, message):
f"{e} Error in pause, this mostly happens after abuse aria2" f"{e} Error in pause, this mostly happens after abuse aria2"
) )
task.listener.select = True task.listener.select = True
except: except Exception:
await sendMessage(message, "This is not a bittorrent or sabnzbd task!") await sendMessage(message, "This is not a bittorrent or sabnzbd task!")
return return
@ -136,7 +136,7 @@ async def get_confirm(_, query):
if await aiopath.exists(f_path): if await aiopath.exists(f_path):
try: try:
await remove(f_path) await remove(f_path)
except: except Exception:
pass pass
if not task.queued: if not task.queued:
await sync_to_async( await sync_to_async(
@ -148,7 +148,7 @@ async def get_confirm(_, query):
if f["selected"] == "false" and await aiopath.exists(f["path"]): if f["selected"] == "false" and await aiopath.exists(f["path"]):
try: try:
await remove(f["path"]) await remove(f["path"])
except: except Exception:
pass pass
if not task.queued: if not task.queued:
try: try:

View File

@ -148,7 +148,7 @@ class Mirror(TaskListener):
try: try:
self.multi = int(args["-i"]) self.multi = int(args["-i"])
except: except Exception:
self.multi = 0 self.multi = 0
if not isinstance(self.seed, bool): if not isinstance(self.seed, bool):

View File

@ -658,7 +658,7 @@ async def rssMonitor():
res = await client.get(data["link"]) res = await client.get(data["link"])
html = res.text html = res.text
break break
except: except Exception:
tries += 1 tries += 1
if tries > 3: if tries > 3:
raise raise
@ -677,7 +677,7 @@ async def rssMonitor():
while True: while True:
try: try:
await sleep(10) await sleep(10)
except: except Exception:
raise RssShutdownException("Rss Monitor Stopped!") raise RssShutdownException("Rss Monitor Stopped!")
try: try:
item_title = rss_d.entries[feed_count]["title"] item_title = rss_d.entries[feed_count]["title"]

View File

@ -162,7 +162,7 @@ async def _getResult(search_results, key, message, method):
msg += f"<b>Size: </b>{result['size']}<br>" msg += f"<b>Size: </b>{result['size']}<br>"
try: try:
msg += f"<b>Seeders: </b>{result['seeders']} | <b>Leechers: </b>{result['leechers']}<br>" msg += f"<b>Seeders: </b>{result['seeders']} | <b>Leechers: </b>{result['leechers']}<br>"
except: except Exception:
pass pass
if "torrent" in result.keys(): if "torrent" in result.keys():
msg += f"<a href='{result['torrent']}'>Direct Link</a><br><br>" msg += f"<a href='{result['torrent']}'>Direct Link</a><br><br>"
@ -171,7 +171,7 @@ async def _getResult(search_results, key, message, method):
msg += f"<a href='http://t.me/share/url?url={quote(result['magnet'])}'>Telegram</a><br><br>" msg += f"<a href='http://t.me/share/url?url={quote(result['magnet'])}'>Telegram</a><br><br>"
else: else:
msg += "<br>" msg += "<br>"
except: except Exception:
continue continue
else: else:
msg += f"<a href='{result.descrLink}'>{escape(result.fileName)}</a><br>" msg += f"<a href='{result.descrLink}'>{escape(result.fileName)}</a><br>"

View File

@ -87,7 +87,7 @@ class YtSelection:
) )
try: try:
await wait_for(self.event.wait(), timeout=self._timeout) await wait_for(self.event.wait(), timeout=self._timeout)
except: except Exception:
await editMessage(self._reply_to, "Timed Out. Task has been cancelled!") await editMessage(self._reply_to, "Timed Out. Task has been cancelled!")
self.qual = None self.qual = None
self.listener.isCancelled = True self.listener.isCancelled = True
@ -318,7 +318,7 @@ class YtDlp(TaskListener):
try: try:
self.multi = int(args["-i"]) self.multi = int(args["-i"])
except: except Exception:
self.multi = 0 self.multi = 0
self.select = args["-s"] self.select = args["-s"]

View File

@ -35,3 +35,39 @@ from .exception import (
from .myjdapi import Myjdapi from .myjdapi import Myjdapi
__version__ = "1.1.7" __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",
]

View File

@ -1 +1,5 @@
from sabnzbdapi.requests import sabnzbdClient from sabnzbdapi.requests import sabnzbdClient
__all__ = [
"sabnzbdClient"
]

0
start.sh Executable file → Normal file
View File

View File

@ -35,7 +35,7 @@ try:
if bool(environ.get("_____REMOVE_THIS_LINE_____")): if bool(environ.get("_____REMOVE_THIS_LINE_____")):
log_error("The README.md file there to be read! Exiting now!") log_error("The README.md file there to be read! Exiting now!")
exit(1) exit(1)
except: except Exception:
pass pass
BOT_TOKEN = environ.get("BOT_TOKEN", "") BOT_TOKEN = environ.get("BOT_TOKEN", "")