Generate our own gid for mega mirrors
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
c791b39785
commit
c4c7575000
|
|
@ -4,7 +4,8 @@ from mega import (MegaApi, MegaListener, MegaRequest, MegaTransfer, MegaError)
|
|||
from bot.helper.telegram_helper.message_utils import update_all_messages
|
||||
import os
|
||||
from bot.helper.mirror_utils.status_utils.mega_download_status import MegaDownloadStatus
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
class MegaDownloaderException(Exception):
|
||||
pass
|
||||
|
|
@ -137,7 +138,8 @@ class MegaDownloadHelper:
|
|||
node = mega_listener.node
|
||||
if mega_listener.error is not None:
|
||||
return listener.onDownloadError(str(mega_listener.error))
|
||||
mega_listener.setValues(node.getName(), api.getSize(node), mega_link.split("!", 1)[-1].split("!", 1)[0])
|
||||
gid = ''.join(random.SystemRandom().choices(string.ascii_letters + string.digits, k=8))
|
||||
mega_listener.setValues(node.getName(), api.getSize(node), gid)
|
||||
with download_dict_lock:
|
||||
download_dict[listener.uid] = MegaDownloadStatus(mega_listener, listener)
|
||||
threading.Thread(target=executor.do, args=(api.startDownload, (node, path))).start()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from .status import Status
|
|||
|
||||
class MegaDownloadStatus(Status):
|
||||
|
||||
def __init__(self, obj,listener):
|
||||
def __init__(self, obj, listener):
|
||||
self.uid = obj.uid
|
||||
self.listener = listener
|
||||
self.obj = obj
|
||||
|
|
@ -22,7 +22,6 @@ class MegaDownloadStatus(Status):
|
|||
def progress(self):
|
||||
"""Progress of download in percentage"""
|
||||
return f"{self.progress_raw()}%"
|
||||
|
||||
|
||||
def status(self) -> str:
|
||||
return MirrorStatus.STATUS_DOWNLOADING
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ ariaDlManager.start_listener()
|
|||
|
||||
|
||||
class MirrorListener(listeners.MirrorListeners):
|
||||
def __init__(self, bot, update, isTar=False,tag=None, extract=False):
|
||||
def __init__(self, bot, update, isTar=False, tag=None, extract=False):
|
||||
super().__init__(bot, update)
|
||||
self.isTar = isTar
|
||||
self.tag = tag
|
||||
|
|
@ -66,7 +66,7 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
return
|
||||
elif self.extract:
|
||||
download.is_extracting = True
|
||||
|
||||
|
||||
path = fs_utils.get_base_name(m_path)
|
||||
if path != "unsupported":
|
||||
LOGGER.info(
|
||||
|
|
@ -171,6 +171,7 @@ class MirrorListener(listeners.MirrorListeners):
|
|||
else:
|
||||
update_all_messages()
|
||||
|
||||
|
||||
def _mirror(bot, update, isTar=False, extract=False):
|
||||
message_args = update.message.text.split(' ')
|
||||
try:
|
||||
|
|
@ -214,9 +215,9 @@ def _mirror(bot, update, isTar=False, extract=False):
|
|||
listener = MirrorListener(bot, update, isTar, tag, extract)
|
||||
if bot_utils.is_mega_link(link):
|
||||
mega_dl = MegaDownloadHelper()
|
||||
mega_dl.add_download(link,f'{DOWNLOAD_DIR}/{listener.uid}/',listener)
|
||||
mega_dl.add_download(link, f'{DOWNLOAD_DIR}/{listener.uid}/', listener)
|
||||
else:
|
||||
ariaDlManager.add_download(link, f'{DOWNLOAD_DIR}/{listener.uid}/',listener)
|
||||
ariaDlManager.add_download(link, f'{DOWNLOAD_DIR}/{listener.uid}/', listener)
|
||||
sendStatusMessage(update, bot)
|
||||
if len(Interval) == 0:
|
||||
Interval.append(setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
|
||||
|
|
@ -234,7 +235,7 @@ def tar_mirror(update, context):
|
|||
|
||||
@run_async
|
||||
def unzip_mirror(update, context):
|
||||
_mirror(context.bot,update, extract=True)
|
||||
_mirror(context.bot, update, extract=True)
|
||||
|
||||
|
||||
mirror_handler = CommandHandler(BotCommands.MirrorCommand, mirror,
|
||||
|
|
|
|||
Loading…
Reference in New Issue