diff --git a/alive.py b/alive.py
index 0723cd0..3011bee 100644
--- a/alive.py
+++ b/alive.py
@@ -9,7 +9,23 @@ from dotenv import load_dotenv
load_dotenv('config.env')
-url = os.environ.get("BASE_URL_OF_BOT")
-while True:
- time.sleep(1000)
- status = requests.get(url).status_code
+try:
+ BASE_URL = getConfig('BASE_URL_OF_BOT')
+ if len(BASE_URL) == 0:
+ BASE_URL = None
+except KeyError:
+ BASE_URL = None
+
+try:
+ IS_VPS = getConfig('IS_VPS')
+ if IS_VPS.lower() == 'true':
+ IS_VPS = True
+ else:
+ IS_VPS = False
+except KeyError:
+ IS_VPS = False
+
+if not IS_VPS and BASE_URL is not None:
+ while True:
+ time.sleep(1000)
+ status = requests.get(BASE_URL).status_code
diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py
index 6a080c4..c10d51f 100644
--- a/bot/helper/ext_utils/bot_utils.py
+++ b/bot/helper/ext_utils/bot_utils.py
@@ -123,12 +123,12 @@ def get_readable_message():
msg += f"\nStatus: {download.status()}"
if download.status() != MirrorStatus.STATUS_ARCHIVING and download.status() != MirrorStatus.STATUS_EXTRACTING:
msg += f"\n{get_progress_bar_string(download)} {download.progress()}"
- if download.status() == MirrorStatus.STATUS_DOWNLOADING:
- msg += f"\nDownloaded: {get_readable_file_size(download.processed_bytes())} of {download.size()}"
- elif download.status() == MirrorStatus.STATUS_CLONING:
+ if download.status() == MirrorStatus.STATUS_CLONING:
msg += f"\nCloned: {get_readable_file_size(download.processed_bytes())} of {download.size()}"
- else:
+ elif download.status() == MirrorStatus.STATUS_UPLOADING:
msg += f"\nUploaded: {get_readable_file_size(download.processed_bytes())} of {download.size()}"
+ else:
+ msg += f"\nDownloaded: {get_readable_file_size(download.processed_bytes())} of {download.size()}"
msg += f"\nSpeed: {download.speed()}" \
f", ETA: {download.eta()} "
# if hasattr(download, 'is_torrent'):
diff --git a/bot/helper/mirror_utils/download_utils/qbit_downloader.py b/bot/helper/mirror_utils/download_utils/qbit_downloader.py
index 10a0369..9316a39 100644
--- a/bot/helper/mirror_utils/download_utils/qbit_downloader.py
+++ b/bot/helper/mirror_utils/download_utils/qbit_downloader.py
@@ -68,6 +68,8 @@ class qbittorrent:
sendMessage("This is an unsupported/invalid link.", listener.bot, listener.update)
return
gid = ''.join(random.SystemRandom().choices(string.ascii_letters + string.digits, k=14))
+ with download_dict_lock:
+ download_dict[listener.uid] = QbDownloadStatus(gid, listener, self.ext_hash, self.client)
self.updater = setInterval(self.update_interval, self.update)
tor_info = tor_info[0]
if BASE_URL is not None and qbitsel:
@@ -102,10 +104,9 @@ class qbittorrent:
markup = sendMarkup(msg, listener.bot, listener.update, QBBUTTONS)
self.client.torrents_pause(torrent_hashes=self.ext_hash)
with download_dict_lock:
- download_dict[listener.uid] = QbDownloadStatus(gid, listener, self.ext_hash, self.client, markup)
+ download = download_dict[listener.uid]
+ download.markup = markup
else:
- with download_dict_lock:
- download_dict[listener.uid] = QbDownloadStatus(gid, listener, self.ext_hash, self.client ,markup)
sendStatusMessage(listener.update, listener.bot)
except qba.UnsupportedMediaType415Error as e:
LOGGER.error(str(e))
diff --git a/bot/helper/mirror_utils/status_utils/aria_download_status.py b/bot/helper/mirror_utils/status_utils/aria_download_status.py
index 1b3f1f9..d7f8866 100644
--- a/bot/helper/mirror_utils/status_utils/aria_download_status.py
+++ b/bot/helper/mirror_utils/status_utils/aria_download_status.py
@@ -11,15 +11,10 @@ class AriaDownloadStatus(Status):
def __init__(self, gid, listener):
super().__init__()
self.upload_name = None
- self.is_archiving = False
self.__gid = gid
self.__download = get_download(self.__gid)
self.__uid = listener.uid
self.__listener = listener
- self.message = listener.message
- self.last = None
- self.is_waiting = False
- self.is_extracting = False
def __update(self):
self.__download = get_download(self.__gid)
diff --git a/bot/helper/mirror_utils/status_utils/qbit_download_status.py b/bot/helper/mirror_utils/status_utils/qbit_download_status.py
index e443f0d..f4d3cbb 100644
--- a/bot/helper/mirror_utils/status_utils/qbit_download_status.py
+++ b/bot/helper/mirror_utils/status_utils/qbit_download_status.py
@@ -9,17 +9,15 @@ from .status import Status
class QbDownloadStatus(Status):
- def __init__(self, gid, listener, qbhash, client, markup):
+ def __init__(self, gid, listener, qbhash, client):
super().__init__()
self.__gid = gid
self.__hash = qbhash
self.__client = client
- self.__markup = markup
+ self.markup = None
self.__uid = listener.uid
self.__listener = listener
self.message = listener.message
- self.is_extracting = False
- self.is_archiving = False
def progress(self):
@@ -58,7 +56,7 @@ class QbDownloadStatus(Status):
download = self.torrent_info().state
if download == "queuedDL":
status = MirrorStatus.STATUS_WAITING
- elif download == "metaDL":
+ elif download == "metaDL" or download == "checkingResumeData":
status = MirrorStatus.STATUS_DOWNLOADING + " (Metadata)"
elif download == "pausedDL":
status = MirrorStatus.STATUS_PAUSE
@@ -89,7 +87,7 @@ class QbDownloadStatus(Status):
return self.__client
def mark(self):
- return self.__markup
+ return self.markup
def cancel_download(self):
LOGGER.info(f"Cancelling Download: {self.name()}")
diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
index ec61e02..5b0220c 100644
--- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py
+++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py
@@ -510,9 +510,10 @@ class GoogleDriveHelper:
mime_type = get_mime_type(current_file_name)
file_name = current_file_name.split("/")[-1]
# current_file_name will have the full path
- self.upload_file(current_file_name, file_name, mime_type, parent_id)
- self.total_files += 1
- new_id = parent_id
+ if not file_name.endswith(".!qB"):
+ self.upload_file(current_file_name, file_name, mime_type, parent_id)
+ self.total_files += 1
+ new_id = parent_id
if self.is_cancelled:
break
return new_id
diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py
index d5b8f5f..0265a3d 100644
--- a/bot/modules/mirror.py
+++ b/bot/modules/mirror.py
@@ -35,11 +35,11 @@ ariaDlManager = AriaDownloadHelper()
ariaDlManager.start_listener()
class MirrorListener(listeners.MirrorListeners):
- def __init__(self, bot, update, pswd, isTar=False, tag=None, extract=False):
+ def __init__(self, bot, update, pswd, isTar=False, extract=False, qbit=False):
super().__init__(bot, update)
self.isTar = isTar
- self.tag = tag
self.extract = extract
+ self.qbit = qbit
self.pswd = pswd
def onDownloadStarted(self):
@@ -65,11 +65,10 @@ class MirrorListener(listeners.MirrorListeners):
name = download.name()
gid = download.gid()
size = download.size_raw()
- if name is None: # when pyrogram's media.file_name is of NoneType
+ if name is None or self.qbit: # when pyrogram's media.file_name is of NoneType
name = os.listdir(f'{DOWNLOAD_DIR}{self.uid}')[0]
m_path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
if self.isTar:
- download.is_archiving = True
try:
with download_dict_lock:
download_dict[self.uid] = TarStatus(name, m_path, size)
@@ -79,12 +78,9 @@ class MirrorListener(listeners.MirrorListeners):
self.onUploadError('Internal error occurred!!')
return
elif self.extract:
- download.is_extracting = True
try:
path = fs_utils.get_base_name(m_path)
- LOGGER.info(
- f"Extracting: {name} "
- )
+ LOGGER.info(f"Extracting: {name}")
with download_dict_lock:
download_dict[self.uid] = ExtractStatus(name, m_path, size)
pswd = self.pswd
@@ -98,9 +94,7 @@ class MirrorListener(listeners.MirrorListeners):
else:
LOGGER.warning('Unable to extract archive! Uploading anyway')
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
- LOGGER.info(
- f'got path: {path}'
- )
+ LOGGER.info(f'got path: {path}')
except NotSupportedExtractionArchive:
LOGGER.info("Not any valid archive, uploading file as it is.")
@@ -109,9 +103,7 @@ class MirrorListener(listeners.MirrorListeners):
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
up_name = pathlib.PurePath(path).name
up_path = f'{DOWNLOAD_DIR}{self.uid}/{up_name}'
- if up_name == "None":
- up_name = "".join(os.listdir(f'{DOWNLOAD_DIR}{self.uid}/'))
- LOGGER.info(f"Upload Name: {up_name}")
+ LOGGER.info(f"Upload Name: {name}")
drive = gdriveTools.GoogleDriveHelper(up_name, self)
size = fs_utils.get_path_size(up_path)
upload_status = UploadStatus(drive, size, gid, self)
@@ -275,7 +267,6 @@ def _mirror(bot, update, isTar=False, extract=False):
reply_to = update.message.reply_to_message
if reply_to is not None:
file = None
- tag = reply_to.from_user.username
media_array = [reply_to.document, reply_to.video, reply_to.audio]
for i in media_array:
if i is not None:
@@ -285,7 +276,7 @@ def _mirror(bot, update, isTar=False, extract=False):
if not bot_utils.is_url(link) and not bot_utils.is_magnet(link) or len(link) == 0:
if file is not None:
if file.mime_type != "application/x-bittorrent":
- listener = MirrorListener(bot, update, pswd, isTar, tag, extract)
+ listener = MirrorListener(bot, update, pswd, isTar, extract)
tg_downloader = TelegramDownloadHelper(listener)
ms = update.message
tg_downloader.add_download(ms, f'{DOWNLOAD_DIR}{listener.uid}/', name)
@@ -296,8 +287,7 @@ def _mirror(bot, update, isTar=False, extract=False):
link = f"/usr/src/app/{file.file_name}"
else:
link = file.get_file().file_path
- else:
- tag = None
+
if not bot_utils.is_url(link) and not bot_utils.is_magnet(link):
sendMessage('No download source provided', bot, update)
return
@@ -313,7 +303,7 @@ def _mirror(bot, update, isTar=False, extract=False):
sendMessage(f"{e}", bot, update)
return
- listener = MirrorListener(bot, update, pswd, isTar, tag, extract)
+ listener = MirrorListener(bot, update, pswd, isTar, extract, qbit)
if bot_utils.is_gdrive_link(link):
if not isTar and not extract:
diff --git a/config_sample.env b/config_sample.env
index 209405c..e831db8 100644
--- a/config_sample.env
+++ b/config_sample.env
@@ -33,7 +33,7 @@ SHORTENER_API = ""
# qBittorrent
IS_VPS = ""
SERVER_PORT = "80" # For VPS
-BASE_URL_OF_BOT = ""
+BASE_URL_OF_BOT = "" #required for heroku
# If you want to use Credentials externally from Index Links, fill these vars with the direct links
# These are optional, if you don't know, simply leave them, don't fill anything in them.
ACCOUNTS_ZIP_URL = ""
diff --git a/wserver.py b/wserver.py
index a74a7a3..4848df7 100644
--- a/wserver.py
+++ b/wserver.py
@@ -36,7 +36,7 @@ p { font-size: 12px; margin: 24px;}