diff --git a/README.md b/README.md index d6771af..31616d5 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ python3 generate_drive_token.py ## Deploying On VPS -**IMPORTANT NOTE**: In start.sh you must replace `$PORT` with 80 or any other port you want to use +**IMPORTANT NOTE**: You must set `SERVER_PORT` variable to `80` or any other port you want to use. - Start Docker daemon (skip if already running): ``` diff --git a/bot/__init__.py b/bot/__init__.py index 70a202e..5d65ee5 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -46,13 +46,14 @@ if CONFIG_FILE_URL is not None: load_dotenv('config.env') -PORT = os.environ.get('PORT', 'SERVER_PORT') +SERVER_PORT = os.environ.get('SERVER_PORT', None) +PORT = os.environ.get('PORT', SERVER_PORT) web = subprocess.Popen([f"gunicorn wserver:start_server --bind 0.0.0.0:{PORT} --worker-class aiohttp.GunicornWebWorker"], shell=True) +time.sleep(1) alive = subprocess.Popen(["python3", "alive.py"]) subprocess.run(["mkdir", "-p", "qBittorrent/config"]) subprocess.run(["cp", "qBittorrent.conf", "qBittorrent/config/qBittorrent.conf"]) subprocess.run(["qbittorrent-nox", "-d", "--profile=."]) -time.sleep(0.5) Interval = [] DRIVES_NAMES = [] DRIVES_IDS = [] diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index 78b79fa..b344c2c 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -879,6 +879,7 @@ class GoogleDriveHelper: def download_file(self, file_id, path, filename, mime_type): request = self.__service.files().get_media(fileId=file_id) + filename = filename.replace('/', '') fh = io.FileIO('{}{}'.format(path, filename), 'wb') downloader = MediaIoBaseDownload(fh, request, chunksize = 65 * 1024 * 1024) done = False diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 2875355..6ddf7f4 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -65,7 +65,7 @@ class MirrorListener(listeners.MirrorListeners): with download_dict_lock: LOGGER.info(f"Download completed: {download_dict[self.uid].name()}") download = download_dict[self.uid] - name = download.name() + name = download.name().replace('/', '') gid = download.gid() size = download.size_raw() if name is None or self.isQbit: # when pyrogram's media.file_name is of NoneType @@ -242,15 +242,6 @@ def _mirror(bot, update, isTar=False, extract=False, isZip=False, isQbit=False): if link == "qbs": qbitsel = True link = message_args[2] - if bot_utils.is_url(link) and not bot_utils.is_magnet(link): - resp = requests.get(link) - if resp.status_code == 200: - file_name = str(time.time()).replace(".", "") + ".torrent" - open(file_name, "wb").write(resp.content) - link = f"{file_name}" - else: - sendMessage("ERROR: link got HTTP response:" + resp.status_code, bot, update) - return if link.startswith("|") or link.startswith("pswd: "): link = '' except IndexError: @@ -286,7 +277,6 @@ def _mirror(bot, update, isTar=False, extract=False, isZip=False, isQbit=False): if i is not None: file = i break - if ( not bot_utils.is_url(link) and not bot_utils.is_magnet(link) @@ -304,11 +294,30 @@ def _mirror(bot, update, isTar=False, extract=False, isZip=False, isQbit=False): return else: link = file.get_file().file_path + elif ( + not bot_utils.is_url(link) + and not bot_utils.is_magnet(link) + or len(link) == 0 + ) and file is None: + reply_text = reply_to.text + reply_text = re.split('\n ', reply_text)[0] + if bot_utils.is_url(reply_text) or bot_utils.is_magnet(reply_text): + link = reply_text - if not bot_utils.is_url(link) and not bot_utils.is_magnet(link): + if bot_utils.is_url(link) and not bot_utils.is_magnet(link) and not os.path.exists(link) and isQbit: + resp = requests.get(link) + if resp.status_code == 200: + file_name = str(time.time()).replace(".", "") + ".torrent" + open(file_name, "wb").write(resp.content) + link = f"{file_name}" + else: + sendMessage("ERROR: link got HTTP response:" + resp.status_code, bot, update) + return + + elif not bot_utils.is_url(link) and not bot_utils.is_magnet(link): sendMessage('No download source provided', bot, update) return - if not os.path.exists(link) and not bot_utils.is_mega_link(link) and not bot_utils.is_gdrive_link(link) and not bot_utils.is_magnet(link): + elif not os.path.exists(link) and not bot_utils.is_mega_link(link) and not bot_utils.is_gdrive_link(link) and not bot_utils.is_magnet(link): try: link = direct_link_generator(link) except DirectDownloadLinkException as e: