Skip to content

Commit

Permalink
Fix cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
breakdowns authored Jun 11, 2021
1 parent c40cc9f commit c92d954
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bot/helper/mirror_utils/download_utils/mega_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def onRequestFinish(self, api, request, error):
.format(request, error))
if str(error).lower() != "no error":
self.error = error.copy()
self.is_cancelled = True
self.listener.onDownloadError("\nMEGA Link you are trying to download is no longer available.")
return
request_type = request.getType()
if request_type == MegaRequest.TYPE_LOGIN:
Expand Down Expand Up @@ -147,7 +145,7 @@ def __init__(self):
@new_thread
def add_download(mega_link: str, path: str, listener):
if MEGA_API_KEY is None:
raise MegaDownloaderException('Mega API KEY not provided! Cannot mirror mega links')
raise MegaDownloaderException('Mega API KEY not provided! Cannot mirror Mega links')
executor = AsyncExecutor()
api = MegaApi(MEGA_API_KEY, None, None, 'telegram-mirror-bot')
global listeners
Expand All @@ -161,14 +159,16 @@ def add_download(mega_link: str, path: str, listener):
executor.do(api.getPublicNode, (mega_link,))
node = mega_listener.public_node
else:
LOGGER.info("Logging into mega folder")
LOGGER.info("Logging into Mega folder")
folder_api = MegaApi(MEGA_API_KEY,None,None,'TgBot')
folder_api.addListener(mega_listener)
executor.do(folder_api.loginToFolder, (mega_link,))
node = folder_api.authorizeNode(mega_listener.node)
if mega_listener.error is not None:
return listener.onDownloadError(str(mega_listener.error))
if STOP_DUPLICATE_MEGA:
msg = sendMessage('Check the File/Folder if already in drive...', listener.bot, listener.update)
LOGGER.info(f'Check the File/Folder if already in drive')
msg = sendMessage('Check the File/Folder if already in Drive...', listener.bot, listener.update)
LOGGER.info(f'Check the File/Folder if already in Drive')
mname = node.getName()
if listener.isTar == True:
mname = mname + ".tar"
Expand All @@ -179,7 +179,7 @@ def add_download(mega_link: str, path: str, listener):
smsg, button = gd.drive_list(mname)
if smsg:
deleteMessage(listener.bot, msg)
msg1 = "File/Folder is already available in Drive.\nHere are the search results:"
msg1 = "<b>File/Folder is already available in Drive.</b>\n<b>Here are the search results:</b>"
sendMarkup(msg1, listener.bot, listener.update, button)
return
else:
Expand All @@ -190,7 +190,7 @@ def add_download(mega_link: str, path: str, listener):
limit = MEGA_LIMIT
limit = limit.split(' ', maxsplit=1)
limitint = int(limit[0])
msg3 = f'Failed, Mega limit is {MEGA_LIMIT}.\nYour File/Folder size is {get_readable_file_size(api.getSize(node))}.'
msg3 = f'<b>Failed, Mega limit is {MEGA_LIMIT}.</b>\n<b>Your File/Folder size is {get_readable_file_size(api.getSize(node))}.</b>'
if 'GB' in limit or 'gb' in limit:
if api.getSize(node) > limitint * 1024**3:
deleteMessage(listener.bot, msg2)
Expand Down

0 comments on commit c92d954

Please sign in to comment.