From bcf9c68f88ae3cc8fe7a87db0fab3df3a0b6171c Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 13:15:16 +0530 Subject: [PATCH 01/13] Update bot_utils.py --- bot/helper/ext_utils/bot_utils.py | 47 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index f7d4690c3..8839261d0 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -21,15 +21,15 @@ class MirrorStatus: - STATUS_UPLOADING = "Uploading...๐Ÿ“ค" - STATUS_DOWNLOADING = "Downloading...๐Ÿ“ฅ" - STATUS_CLONING = "Cloning...โ™ป๏ธ" - STATUS_WAITING = "Queued...๐Ÿ“" - STATUS_FAILED = "Failed ๐Ÿšซ. Cleaning Download..." - STATUS_PAUSE = "Paused...โญ•๏ธ" - STATUS_ARCHIVING = "Archiving...๐Ÿ”" - STATUS_EXTRACTING = "Extracting...๐Ÿ“‚" - STATUS_SPLITTING = "Splitting...โœ‚๏ธ" + STATUS_UPLOADING = "๐—จ๐—ฝ๐—น๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—š...๐Ÿ“ค" + STATUS_DOWNLOADING = "๐——๐—ผ๐˜„๐—ป๐—น๐—ผ๐—ฎ๐—ฑ๐—ถ๐—ป๐—š...๐Ÿ“ฅ" + STATUS_CLONING = "๐˜พ๐™ก๐™ค๐™ฃ๐™ž๐™ฃ๐™œ...โ™ป๏ธ" + STATUS_WAITING = "๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ๐—ฑ...๐Ÿ“" + STATUS_FAILED = "๐—™๐—ฎ๐—ถ๐—น๐—ฒ๐—ฑ ๐Ÿšซ! ๐—–๐—น๐—ฒ๐—ฎ๐—ป๐—ถ๐—ป๐—ด ๐—ฑ๐—ผ๐˜„๐—ป๐—น๐—ผ๐—ฎ๐—ฑ..." + STATUS_PAUSE = "๐™‹๐™–๐™ช๐™จ๐™š๐™™...โญ•๏ธ" + STATUS_ARCHIVING = "๐˜ผ๐™ง๐™˜๐™๐™ž๐™ซ๐™ž๐™ฃ๐™œ...๐Ÿ”" + STATUS_EXTRACTING = "๐™€๐™ญ๐™ฉ๐™ง๐™–๐™˜๐™ฉ๐™ž๐™ฃ๐™œ...๐Ÿ“‚" + STATUS_SPLITTING = "๐™Ž๐™ฅ๐™ก๐™ž๐™ฉ๐™ฉ๐™ž๐™ฃ๐™œ...โœ‚๏ธ" SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'] @@ -103,14 +103,14 @@ def get_progress_bar_string(status): p = 0 if total == 0 else round(completed * 100 / total) p = min(max(p, 0), 100) cFull = p // 8 - p_str = 'โ– ' * cFull - p_str += 'โ–ก' * (12 - cFull) + p_str = 'โœฆ' * cFull + p_str += 'โœง' * (12 - cFull) p_str = f"[{p_str}]" return p_str def get_readable_message(): with download_dict_lock: - msg = "" + msg = "โœฅโ•โ•โ• @๐˜๐š๐ฆ๐ซ๐š๐š๐ฃ๐ŸŽ๐ŸŽ๐Ÿ• โ•โ•โ•โœฅ" start = 0 if STATUS_LIMIT is not None: dick_no = len(download_dict) @@ -121,8 +121,8 @@ def get_readable_message(): globals()['PAGE_NO'] -= 1 start = COUNT for index, download in enumerate(list(download_dict.values())[start:], start=1): - msg += f"Name: {download.name()}" - msg += f"\nStatus: {download.status()}" + msg += f"๐Ÿ—‚๐—™๐—ถ๐—น๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ: {download.name()}" + msg += f"\n๐’๐ญ๐š๐ญ๐ฎ๐ฌ: {download.status()}" if download.status() not in [ MirrorStatus.STATUS_ARCHIVING, MirrorStatus.STATUS_EXTRACTING, @@ -130,24 +130,25 @@ def get_readable_message(): ]: msg += f"\n{get_progress_bar_string(download)} {download.progress()}" if download.status() == MirrorStatus.STATUS_CLONING: - msg += f"\nCloned: {get_readable_file_size(download.processed_bytes())} of {download.size()}" + msg += f"\nโ™ป๏ธ ๐‚๐ฅ๐จ๐ง๐ž๐ : {get_readable_file_size(download.processed_bytes())} of {download.size()}" elif download.status() == MirrorStatus.STATUS_UPLOADING: - msg += f"\nUploaded: {get_readable_file_size(download.processed_bytes())} of {download.size()}" + msg += f"\n๐Ÿ“ค ๐”๐ฉ๐ฅ๐จ๐š๐๐ž๐ : {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()}" + msg += f"\n๐Ÿ“ฅ ๐ƒ๐จ๐ฐ๐ง๐ฅ๐จ๐š๐๐ž๐ : {get_readable_file_size(download.processed_bytes())} of {download.size()}" + msg += f"\nโšก๐’๐ฉ๐ž๐ž๐ : {download.speed()}" msg += f"\nETA: {download.eta()}" try: - msg += f"\nSeeders: {download.aria_download().num_seeders}" \ - f" | Peers: {download.aria_download().connections}" + msg += f"\nโš“๏ธ๐’๐ž๐ž๐๐ž๐ซ๐ฌ : {download.aria_download().num_seeders}" \ + f" | ๐Ÿ”„ ๐๐ž๐ž๐ซ๐ฌ : {download.aria_download().connections}" except: pass try: - msg += f"\nSeeders: {download.torrent_info().num_seeds}" \ - f" | Leechers: {download.torrent_info().num_leechs}" + msg += f"\nโš“๏ธ ๐’๐ž๐ž๐๐ž๐ซ๐ฌ : {download.torrent_info().num_seeds}" \ + f" | ๐Ÿ”„ ๐‹๐ž๐ž๐œ๐ก๐ž๐ซ๐ฌ : {download.torrent_info().num_leechs}" except: pass - msg += f"\n/{BotCommands.CancelMirror} {download.gid()}" + msg += f'\n๐Ÿ‘จโ€๐Ÿฆฑ ๐”๐ฌ๐ž๐ซ : {download.message.from_user.first_name} ({download.message.from_user.id})' + msg += f"\n๐Ÿšซ ๐“๐จ ๐’๐ญ๐จ๐ฉ : /{BotCommands.CancelMirror} {download.gid()}" msg += "\n___________________________\n" if STATUS_LIMIT is not None and index == STATUS_LIMIT: break From e3c0569cc97cfaba686fdb193a6c4958c0fc907c Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 13:28:16 +0530 Subject: [PATCH 02/13] Update __main__.py --- bot/__main__.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/bot/__main__.py b/bot/__main__.py index 73b6b407c..85ea53848 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -31,22 +31,26 @@ def stats(update, context): cpuUsage = psutil.cpu_percent(interval=0.5) memory = psutil.virtual_memory().percent disk = psutil.disk_usage('/').percent - stats = f'Bot Uptime: {currentTime}\n' \ - f'Total Disk Space: {total}\n' \ - f'Used: {used} ' \ - f'Free: {free}\n\n' \ - f'Upload: {sent}\n' \ - f'Download: {recv}\n\n' \ - f'CPU: {cpuUsage}% ' \ - f'RAM: {memory}% ' \ - f'DISK: {disk}%' + stats = f'โ•ญโ”€โ”€โ”€ใ€Œ โญ•๏ธ BOT STATS โญ•๏ธ ใ€ \n' \ + f'โ”‚\n' \ + f'โ”œ โฐ Bot Uptime: {currentTime}\n' \ + f'โ”œ ๐Ÿ—„ Total Disk Space: {total}\n' \ + f'โ”œ ๐Ÿ—‚ Used: {used} ' \ + f'โ”œ ๐Ÿ“‚ Free: {free}\n\n' \ + f'โ”œ ๐Ÿ“ค Upload: {sent}\n' \ + f'โ”œ ๐Ÿ“ฅ Download: {recv}\n\n' \ + f'โ”œ ๐Ÿ–ฅ๏ธ CPU: {cpuUsage}% ' \ + f'โ”œ ๐Ÿš€ RAM: {memory}% ' \ + f'โ”œ ๐Ÿ—„ DISK: {disk}%' \ + f'โ”‚\n' \ + f'โ•ฐโ”€โ”€ใ€Œ ๐Ÿšธ @๐˜๐š๐ฆ๐ซ๐š๐š๐ฃ๐ŸŽ๐ŸŽ๐Ÿ• ๐Ÿšธ ใ€' sendMessage(stats, context.bot, update) def start(update, context): buttons = button_build.ButtonMaker() - buttons.buildbutton("Repo", "https://www.github.com/anasty17/mirror-leech-telegram-bot") - buttons.buildbutton("Channel", "https://t.me/mirrorLeechTelegramBot") + buttons.buildbutton("Repo", "https://www.github.com/crazy-racer/mirror-leech-telegram-bot") + buttons.buildbutton("Channel", "https://t.me/Mirrorclouds") reply_markup = InlineKeyboardMarkup(buttons.build_menu(2)) if CustomFilters.authorized_user(update) or CustomFilters.authorized_chat(update): start_string = f''' @@ -159,7 +163,7 @@ def log(update, context): help = Telegraph(access_token=telegraph_token).create_page( title='Mirrorbot Help', author_name='Mirrorbot', - author_url='https://github.com/anasty17/mirror-leech-telegram-bot', + author_url='https://github.com/crazy-racer/mirror-leech-telegram-bot', html_content=help_string_telegraph, )["path"] From ccacf9e3cf75834335922d31b44c2a8ef2e807eb Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 14:03:43 +0530 Subject: [PATCH 03/13] Create mirror.py --- bot/modules/mirror.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index cea2d488a..67632c0e2 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -250,7 +250,11 @@ def onUploadComplete(self, link: str, size, files, folders, typ): update_all_messages() return with download_dict_lock: - msg = f'Name: {download_dict[self.uid].name()}\n\nSize: {size}' + msg = f'๐Ÿ—‚ ๐—™๐—ถ๐—น๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ : {download_dict[self.uid].name()}\n\nSize: {size}\n' \ + f' \n' \ + f'๐Ÿ”ฅ ๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐™ˆ๐™ž๐™ง๐™ง๐™ค๐™ง ๐™•๐™ค๐™ฃ๐™€\n' \ + f' \n' \ + f'๐Ÿ”ฅ ๐™‚๐™ง๐™ค๐™ช๐™ฅ : @mirrorclouds\n' if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'): msg += '\n\nType: Folder' msg += f'\nSubFolders: {folders}' @@ -297,7 +301,7 @@ def onUploadComplete(self, link: str, size, files, folders, typ): else: uname = f'{self.message.from_user.first_name}' if uname is not None: - msg += f'\n\ncc: {uname}' + msg += f'\n\n๐Ÿ‘ค ๐—จ๐—ฝ๐—น๐—ผ๐—ฎ๐—ฑ๐—ฒ๐—ฟ : ๐Ÿ‘‰ {uname}\n\nโ–ซ๏ธ#Uploaded To Team Drive โœ“ \n\n๐Ÿšซ ๐˜ฟ๐™ค ๐™‰๐™ค๐™ฉ ๐™Ž๐™๐™–๐™ง๐™š ๐™„๐™ฃ๐™™๐™š๐™ญ ๐™‡๐™ž๐™ฃ๐™  \n\nโœ… ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ฑ ๐—•๐˜† : yamraaj007' try: fs_utils.clean_download(download_dict[self.uid].path()) except FileNotFoundError: From 5a1892f0fa39f3a19d33d6aa1834512f524bb553 Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 14:58:41 +0530 Subject: [PATCH 04/13] Create gdriveTools.py --- .../mirror_utils/upload_utils/gdriveTools.py | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index a0ae9659e..daff16cdc 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -165,7 +165,7 @@ def upload_file(self, file_path, file_name, mime_type, parent_id): # File body description file_metadata = { 'name': file_name, - 'description': 'Uploaded by Mirror-leech-telegram-bot', + 'description': '๐Ÿ‘ฒ ๐™๐™ฅ๐™ก๐™ค๐™–๐™™๐™š๐™™ ๐™—๐™ฎ ๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐™ˆ๐™ž๐™ง๐™ง๐™ค๐™ง๐™—๐™ค๐™ฉ', 'mimeType': mime_type, } try: @@ -376,10 +376,10 @@ def clone(self, link): msg = self.deletefile(durl) LOGGER.info(f"{msg}") return "your clone has been stopped and cloned data has been deleted!", "cancelled" - msg += f'Name: {meta.get("name")}\nSize: {get_readable_file_size(self.transferred_size)}' - msg += '\nType: Folder' - msg += f'\nSubFolders: {self.total_folders}' - msg += f'\nFiles: {self.total_files}' + msg += f'๐Ÿ—‚๏ธ ๐™๐™ž๐™ก๐™š๐™ฃ๐™–๐™ข๐™š: {meta.get("name")}\n๐Ÿ“ฆ ๐™Ž๐™ž๐™ฏ๐™š: {get_readable_file_size(self.transferred_size)}' + msg += '\nโš™๏ธ ๐™๐™ฎ๐™ฅ๐™š: Folder' + msg += f'\n๐Ÿ“š ๐™Ž๐™ช๐™—๐™๐™ค๐™ก๐™™๐™š๐™ง๐™จ: {self.total_folders}' + msg += f'\n๐Ÿ“ ๐™๐™ž๐™ก๐™š๐™จ: {self.total_files}' buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: surl = short_url(durl) @@ -396,7 +396,7 @@ def clone(self, link): buttons.buildbutton("โšก Index Link", url) else: file = self.copyFile(meta.get('id'), parent_id) - msg += f'Name: {file.get("name")}' + msg += f'๐Ÿ—‚ ๐—™๐—ถ๐—น๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ: {file.get("name")}' durl = self.__G_DRIVE_BASE_DOWNLOAD_URL.format(file.get("id")) buttons = button_build.ButtonMaker() if SHORTENER is not None and SHORTENER_API is not None: @@ -409,8 +409,8 @@ def clone(self, link): except: typ = 'File' try: - msg += f'\nSize: {get_readable_file_size(int(meta.get("size")))}' - msg += f'\nType: {typ}' + msg += f'\n๐Ÿ“ฆ ๐™Ž๐™ž๐™ฏ๐™š: {get_readable_file_size(int(meta.get("size")))}' + msg += f'\n>โš™๏ธ ๐™๐™ฎ๐™ฅ๐™š: {typ}' except TypeError: pass if INDEX_URL is not None: @@ -488,7 +488,7 @@ def create_directory(self, directory_name, parent_id): file_id = file.get("id") if not IS_TEAM_DRIVE: self.__set_permission(file_id) - LOGGER.info("Created G-Drive Folder:\nName: {}\nID: {} ".format(file.get("name"), file_id)) + LOGGER.info("โ™ป๏ธ Created G-Drive Folder:\nName: {}\nID: {} ".format(file.get("name"), file_id)) return file_id def upload_dir(self, input_directory, parent_id): @@ -576,9 +576,9 @@ def edit_telegraph(self): content += f' | Next' nxt_page += 1 Telegraph(access_token=telegraph_token).edit_page(path = self.path[prev_page], - title = 'Mirror-leech-bot Search', - author_name='Mirror-leech-bot', - author_url='https://github.com/anasty17/mirror-leech-telegram-bot', + title = '๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐— ๐—œ๐—ฅ๐—ฅ๐—ข๐—ฅ ๐—ญ๐—ข๐—ก๐—˜', + author_name='๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐— ๐—œ๐—ฅ๐—ฅ๐—ข๐—ฅ ๐˜ฝ๐™ค๐™ฉ', + author_url='https://github.com/crazy-racer/mirror-leech-telegram-bot', html_content=content) return @@ -773,9 +773,9 @@ def drive_list(self, fileName, stopDup=False, noMulti=False): for content in self.telegraph_content : self.path.append(Telegraph(access_token=telegraph_token).create_page( - title = 'Mirror-leech-bot Search', - author_name='Mirror-leech-bot', - author_url='https://github.com/anasty17/mirror-leech-telegram-bot', + title = '๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐— ๐—œ๐—ฅ๐—ฅ๐—ข๐—ฅ ๐—ญ๐—ข๐—ก๐—˜', + author_name='๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐— ๐—œ๐—ฅ๐—ฅ๐—ข๐—ฅ ๐—ญ๐—ข๐—ก๐—˜', + author_url='https://github.com/crazy-racer/mirror-leech-telegram-bot', html_content=content )['path']) @@ -793,7 +793,7 @@ def count(self, link): try: file_id = self.getIdFromUrl(link) except (KeyError,IndexError): - msg = "Google Drive ID could not be found in the provided link" + msg = "๐Ÿ“› Google Drive ID could not be found in the provided link" return msg msg = "" LOGGER.info(f"File ID: {file_id}") @@ -804,13 +804,13 @@ def count(self, link): LOGGER.info(f"Counting: {name}") if drive_file['mimeType'] == self.__G_DRIVE_DIR_MIME_TYPE: self.gDrive_directory(**drive_file) - msg += f'Name: {name}' - msg += f'\n\nSize: {get_readable_file_size(self.total_bytes)}' - msg += '\n\nType: Folder' - msg += f'\nSubFolders: {self.total_folders}' - msg += f'\nFiles: {self.total_files}' + msg += f'๐Ÿ—‚๏ธ ๐™๐™ž๐™ก๐™š๐™ฃ๐™–๐™ข๐™š: {name}' + msg += f'\n\n๐Ÿ“ฆ ๐™Ž๐™ž๐™ฏ๐™š: {get_readable_file_size(self.total_bytes)}' + msg += '\n\nโš™๏ธ ๐™๐™ฎ๐™ฅ๐™š: Folder' + msg += f'\n๐Ÿ“š ๐™Ž๐™ช๐™—๐™๐™ค๐™ก๐™™๐™š๐™ง๐™จ: {self.total_folders}' + msg += f'\n๐Ÿ“ ๐™๐™ž๐™ก๐™š๐™จ: {self.total_files}' else: - msg += f'Name: {name}' + msg += f'๐Ÿ—‚ ๐™๐™ž๐™ก๐™š๐™ฃ๐™–๐™ข๐™š: {name}' try: typee = drive_file['mimeType'] except: @@ -818,9 +818,9 @@ def count(self, link): try: self.total_files += 1 self.gDrive_file(**drive_file) - msg += f'\n\nSize: {get_readable_file_size(self.total_bytes)}' - msg += f'\n\nType: {typee}' - msg += f'\nFiles: {self.total_files}' + msg += f'\n\n๐Ÿ“ฆ ๐™Ž๐™ž๐™ฏ๐™š: {get_readable_file_size(self.total_bytes)}' + msg += f'\n\nโš™๏ธ ๐™๐™ฎ๐™ฅ๐™š: {typee}' + msg += f'\n๐Ÿ“ ๐™๐™ž๐™ก๐™š๐™จ: {self.total_files}' except TypeError: pass except Exception as err: @@ -859,7 +859,7 @@ def helper(self, link): try: file_id = self.getIdFromUrl(link) except (KeyError,IndexError): - msg = "Google Drive ID could not be found in the provided link" + msg = "๐Ÿ“› Google Drive ID could not be found in the provided link" return msg, "", "", "" LOGGER.info(f"File ID: {file_id}") try: @@ -1008,10 +1008,10 @@ def _on_download_progress(self): def cancel_download(self): self.is_cancelled = True if self.is_downloading: - LOGGER.info(f"Cancelling Download: {self.name}") + LOGGER.info(f"โŒ Cancelling Download: {self.name}") self.__listener.onDownloadError('Download stopped by user!') elif self.is_cloning: - LOGGER.info(f"Cancelling Clone: {self.name}") + LOGGER.info(f"โŒ Cancelling Clone: {self.name}") elif self.is_uploading: - LOGGER.info(f"Cancelling Upload: {self.name}") + LOGGER.info(f"โŒ Cancelling Upload: {self.name}") self.__listener.onUploadError('your upload has been stopped and uploaded data has been deleted!') From 01cf30e60ca9ce90fbc299c3c576c88d745dcdc9 Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 15:08:37 +0530 Subject: [PATCH 05/13] Update message_utils.py --- bot/helper/telegram_helper/message_utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bot/helper/telegram_helper/message_utils.py b/bot/helper/telegram_helper/message_utils.py index 4f9c9c65c..c9a0b7d5a 100644 --- a/bot/helper/telegram_helper/message_utils.py +++ b/bot/helper/telegram_helper/message_utils.py @@ -75,9 +75,9 @@ def update_all_messages(): free = get_readable_file_size(free) currentTime = get_readable_time(time.time() - botStartTime) msg, buttons = get_readable_message() - msg += f"CPU: {psutil.cpu_percent()}%" \ - f" RAM: {psutil.virtual_memory().percent}%" \ - f" DISK: {psutil.disk_usage('/').percent}%" + msg += f"๐Ÿ–ฅ๏ธ ๐˜พ๐™‹๐™: {psutil.cpu_percent()}%" \ + f" ๐Ÿš€ ๐™๐˜ผ๐™ˆ: {psutil.virtual_memory().percent}%" \ + f" ๐Ÿ“ฆ ๐˜ฟ๐™„๐™Ž๐™†: {psutil.disk_usage('/').percent}%" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 @@ -95,7 +95,7 @@ def update_all_messages(): uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) - msg += f"\nFREE: {free} | UPTIME: {currentTime}\nDL: {dlspeed}/s ๐Ÿ”ป | UL: {ulspeed}/s ๐Ÿ”บ\n" + msg += f"\n๐™๐™๐™€๐™€: {free} | ๐™๐™‹๐™๐™„๐™ˆ๐™€: {currentTime}\n๐˜ฟ๐™‡: {dlspeed}/s ๐Ÿ”ป | ๐™๐™‡: {ulspeed}/s ๐Ÿ”บ\n" with status_reply_dict_lock: for chat_id in list(status_reply_dict.keys()): if status_reply_dict[chat_id] and msg != status_reply_dict[chat_id].text: @@ -116,9 +116,9 @@ def sendStatusMessage(msg, bot): free = get_readable_file_size(free) currentTime = get_readable_time(time.time() - botStartTime) progress, buttons = get_readable_message() - progress += f"CPU: {psutil.cpu_percent()}%" \ - f" RAM: {psutil.virtual_memory().percent}%" \ - f" DISK: {psutil.disk_usage('/').percent}%" + progress += f"๐Ÿ–ฅ๏ธ ๐˜พ๐™‹๐™: {psutil.cpu_percent()}%" \ + f" ๐Ÿš€ ๐™๐˜ผ๐™ˆ: {psutil.virtual_memory().percent}%" \ + f" ๐Ÿ“ฆ ๐˜ฟ๐™„๐™Ž๐™†: {psutil.disk_usage('/').percent}%" with download_dict_lock: dlspeed_bytes = 0 uldl_bytes = 0 @@ -136,7 +136,7 @@ def sendStatusMessage(msg, bot): uldl_bytes += float(speedy.split('M')[0]) * 1048576 dlspeed = get_readable_file_size(dlspeed_bytes) ulspeed = get_readable_file_size(uldl_bytes) - progress += f"\nFREE: {free} | UPTIME: {currentTime}\nDL: {dlspeed}/s ๐Ÿ”ป | UL: {ulspeed}/s ๐Ÿ”บ\n" + progress += f"\n๐™๐™๐™€๐™€: {free} | ๐™๐™‹๐™๐™„๐™ˆ๐™€: {currentTime}\n๐˜ฟ๐™‡: {dlspeed}/s ๐Ÿ”ป | ๐™๐™‡: {ulspeed}/s ๐Ÿ”บ\n" with status_reply_dict_lock: if msg.message.chat.id in list(status_reply_dict.keys()): try: From 099c576ac953f210767fc358260057c7f655be49 Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 15:16:03 +0530 Subject: [PATCH 06/13] Update clone.py --- bot/modules/clone.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot/modules/clone.py b/bot/modules/clone.py index b001d5283..e97db6d57 100644 --- a/bot/modules/clone.py +++ b/bot/modules/clone.py @@ -21,7 +21,7 @@ def cloneNode(update, context): sendMessage(res, context.bot, update) return if STOP_DUPLICATE: - LOGGER.info('Checking File/Folder if already in Drive...') + LOGGER.info('๐Ÿ”Ž Checking File/Folder if already in Drive...') smsg, button = gd.drive_list(name, True, True) if smsg: msg3 = "File/Folder is already available in Drive.\nHere are the search results:" @@ -34,7 +34,7 @@ def cloneNode(update, context): sendMessage(msg2, context.bot, update) return if files <= 10: - msg = sendMessage(f"Cloning: {link}", context.bot, update) + msg = sendMessage(f"๐Ÿ“š Cloning: {link}", context.bot, update) result, button = gd.clone(link) deleteMessage(context.bot, msg) else: @@ -62,7 +62,7 @@ def cloneNode(update, context): else: uname = f'{update.message.from_user.first_name}' if uname is not None: - cc = f'\n\ncc: {uname}' + cc = f'\n\n๐Ÿ‘ค ๐—–๐—น๐—ผ๐—ป๐—ฒ๐—ฟ : {uname}\n\n๐Ÿ”ฅ ๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐— ๐—ถ๐—ฟ๐—ฟ๐—ผ๐—ฟ ๐—ญ๐—ผ๐—ป๐—˜\n\n๐Ÿ”ฅ ๐—š๐—ฟ๐—ผ๐˜‚๐—ฝ : @Mirrorclouds\n\nโ–ซ๏ธ#Uploaded To Team Drive โœ“ \n\n๐Ÿšซ ๐——๐—ผ ๐—ก๐—ผ๐˜ ๐—ฆ๐—ต๐—ฎ๐—ฟ๐—ฒ ๐—œ๐—ป๐—ฑ๐—ฒ๐˜… ๐—Ÿ๐—ถ๐—ป๐—ธ \n\nโœ… ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ฑ ๐—•๐˜† : @Yamraaj007' men = f'{uname} ' if button in ["cancelled", ""]: sendMessage(men + result, context.bot, update) From 8ed0f8396df8d448fe8bf6d798d79bf462e8dd78 Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 15:18:54 +0530 Subject: [PATCH 07/13] Update count.py --- bot/modules/count.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/modules/count.py b/bot/modules/count.py index b8559acae..1314c439d 100644 --- a/bot/modules/count.py +++ b/bot/modules/count.py @@ -14,7 +14,7 @@ def countNode(update, context): args = update.message.text.split(" ", maxsplit=1) if len(args) > 1: link = args[1] - msg = sendMessage(f"Counting: {link}", context.bot, update) + msg = sendMessage(f"๐Ÿ“šCounting: {link}", context.bot, update) gd = GoogleDriveHelper() result = gd.count(link) deleteMessage(context.bot, msg) @@ -23,7 +23,7 @@ def countNode(update, context): else: uname = f'{update.message.from_user.first_name}' if uname is not None: - cc = f'\n\ncc: {uname}' + cc = f'\n\n๐Ÿ‘ค ๐—–๐—ผ๐˜‚๐—ป๐˜๐—ฒ๐—ฟ : {uname}\n\n๐Ÿ”ฅ ๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐— ๐—ถ๐—ฟ๐—ฟ๐—ผ๐—ฟ ๐—ญ๐—ผ๐—ป๐—˜\n\n๐Ÿ”ฅ ๐—š๐—ฟ๐—ผ๐˜‚๐—ฝ : @Mirrorclouds\n\nโ–ซ๏ธ#Uploaded To Team Drive โœ“ \n\n๐Ÿšซ ๐——๐—ผ ๐—ก๐—ผ๐˜ ๐—ฆ๐—ต๐—ฎ๐—ฟ๐—ฒ ๐—œ๐—ป๐—ฑ๐—ฒ๐˜… ๐—Ÿ๐—ถ๐—ป๐—ธ \n\nโœ… ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ฒ๐—ฑ ๐—•๐˜† : @Yamraaj007' sendMessage(result + cc, context.bot, update) else: sendMessage("Provide G-Drive Shareable Link to Count.", context.bot, update) From 97b04de4cf3fde0bc21ab0beadc0d7d138f6160c Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Sun, 10 Oct 2021 15:31:33 +0530 Subject: [PATCH 08/13] Update speedtest.py --- bot/modules/speedtest.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bot/modules/speedtest.py b/bot/modules/speedtest.py index 9dfd65c87..9720a0173 100644 --- a/bot/modules/speedtest.py +++ b/bot/modules/speedtest.py @@ -15,17 +15,17 @@ def speedtest(update, context): test.results.share() result = test.results.dict() string_speed = f''' -Server -Name: {result['server']['name']} -Country: {result['server']['country']}, {result['server']['cc']} -Sponsor: {result['server']['sponsor']} -ISP: {result['client']['isp']} - -SpeedTest Results -Upload: {speed_convert(result['upload'] / 8)} -Download: {speed_convert(result['download'] / 8)} -Ping: {result['ping']} ms -ISP Rating: {result['client']['isprating']} +๐Ÿ–ฅ๏ธ Server +๐Ÿ’ณ Name: {result['server']['name']} +โ›ณ๏ธ Country: {result['server']['country']}, {result['server']['cc']} +๐Ÿ’ฐ Sponsor: {result['server']['sponsor']} +๐Ÿฌ ISP: {result['client']['isp']} + +โœˆ๏ธ SpeedTest Results +๐Ÿ”บ Upload: {speed_convert(result['upload'] / 8)} +๐Ÿ”ป Download: {speed_convert(result['download'] / 8)} +๐Ÿ“ถ Ping: {result['ping']} ms +๐Ÿฌ ISP Rating: {result['client']['isprating']} ''' editMessage(string_speed, speed) From 98f0bb60751b9dffc437ffa84b81807803d8e718 Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Tue, 9 Nov 2021 00:15:20 +0530 Subject: [PATCH 09/13] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5dd4b0264..f8ec0c57b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,4 +30,4 @@ tenacity TgCrypto torrentool==1.1.0 urllib3 -youtube_dl +yt_dlp From b625cc5e1ede14b04276cabc59ad143a108a2ef6 Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Tue, 9 Nov 2021 00:18:00 +0530 Subject: [PATCH 10/13] Update youtube_dl_download_helper.py --- .../mirror_utils/download_utils/youtube_dl_download_helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py index 2119505a2..35b0f472e 100644 --- a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py +++ b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py @@ -1,6 +1,6 @@ from .download_helper import DownloadHelper import time -from youtube_dl import YoutubeDL, DownloadError +from yt_dlp import YoutubeDL, DownloadError from bot import download_dict_lock, download_dict from ..status_utils.youtube_dl_download_status import YoutubeDLDownloadStatus import logging @@ -17,7 +17,7 @@ def __init__(self, obj): def debug(self, msg): LOGGER.debug(msg) # Hack to fix changing changing extension - match = re.search(r'.ffmpeg..Merging formats into..(.*?).$', msg) + match = re.search(r'.Merger..Merging formats into..(.*?).$', msg) if match and not self.obj.is_playlist: newname = match.group(1) newname = newname.split("/") From fabee8d30243cb40c15a93863b688d7525ec327a Mon Sep 17 00:00:00 2001 From: yamraaj007 <69627019+crazy-racer@users.noreply.github.com> Date: Tue, 9 Nov 2021 00:23:19 +0530 Subject: [PATCH 11/13] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 11ae1dc92..276c57ab5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM anasty17/mirror-leech:latest +FROM priiiiyo/mega-sdk-python:latest WORKDIR /usr/src/app RUN chmod 777 /usr/src/app From 24ca413e2ca813bcda39331e24ee75402b671c9d Mon Sep 17 00:00:00 2001 From: "sourcery-ai[bot]" <58596630+sourcery-ai[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:39:47 +0530 Subject: [PATCH 12/13] 'Refactored by Sourcery' (#12) Co-authored-by: Sourcery AI <> --- .../youtube_dl_download_helper.py | 12 +++--- .../mirror_utils/upload_utils/gdriveTools.py | 39 ++++++++++--------- bot/modules/mirror.py | 22 +++++------ 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py index 35b0f472e..ca249890a 100644 --- a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py +++ b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py @@ -19,7 +19,7 @@ def debug(self, msg): # Hack to fix changing changing extension match = re.search(r'.Merger..Merging formats into..(.*?).$', msg) if match and not self.obj.is_playlist: - newname = match.group(1) + newname = match[1] newname = newname.split("/") newname = newname[-1] self.obj.name = newname @@ -159,10 +159,12 @@ def add_download(self, link, path, qual, name): self.opts['postprocessors'] = [{'key': 'FFmpegExtractAudio','preferredcodec': 'mp3','preferredquality': '320',}] else: self.opts['format'] = qual - if not self.is_playlist: - self.opts['outtmpl'] = f"{path}/{self.name}" - else: - self.opts['outtmpl'] = f"{path}/{self.name}/%(title)s.%(ext)s" + self.opts['outtmpl'] = ( + f"{path}/{self.name}/%(title)s.%(ext)s" + if self.is_playlist + else f"{path}/{self.name}" + ) + self.__download(link) def cancel_download(self): diff --git a/bot/helper/mirror_utils/upload_utils/gdriveTools.py b/bot/helper/mirror_utils/upload_utils/gdriveTools.py index daff16cdc..4b7e7f361 100644 --- a/bot/helper/mirror_utils/upload_utils/gdriveTools.py +++ b/bot/helper/mirror_utils/upload_utils/gdriveTools.py @@ -104,7 +104,7 @@ def getIdFromUrl(link: str): res = re.search(regex,link) if res is None: raise IndexError("G-Drive ID not found.") - return res.group(5) + return res[5] parsed = urlparse.urlparse(link) return parse_qs(parsed.query)['id'][0] @@ -197,9 +197,7 @@ def upload_file(self, file_path, file_name, mime_type, parent_id): drive_file = self.__service.files().create(supportsTeamDrives=True, body=file_metadata, media_body=media_body) response = None - while response is None: - if self.is_cancelled: - break + while response is None and not self.is_cancelled: try: self.status, response = drive_file.next_chunk() except HttpError as err: @@ -236,7 +234,7 @@ def upload(self, file_name: str): file_dir = f"{DOWNLOAD_DIR}{self.__listener.message.message_id}" file_path = f"{file_dir}/{file_name}" size = get_readable_file_size(get_path_size(file_path)) - LOGGER.info("Uploading File: " + file_path) + LOGGER.info(f"Uploading File: {file_path}") self.updater = setInterval(self.update_interval, self._on_upload_progress) if os.path.isfile(file_path): try: @@ -246,7 +244,7 @@ def upload(self, file_name: str): return if link is None: raise Exception('Upload has been manually cancelled') - LOGGER.info("Uploaded To G-Drive: " + file_path) + LOGGER.info(f"Uploaded To G-Drive: {file_path}") except Exception as e: if isinstance(e, RetryError): LOGGER.info(f"Total Attempts: {e.last_attempt.attempt_number}") @@ -272,7 +270,7 @@ def upload(self, file_name: str): msg = self.deletefile(link) LOGGER.info(f"{msg}") return - LOGGER.info("Uploaded To G-Drive: " + file_name) + LOGGER.info(f"Uploaded To G-Drive: {file_name}") except Exception as e: if isinstance(e, RetryError): LOGGER.info(f"Total Attempts: {e.last_attempt.attempt_number}") @@ -439,9 +437,9 @@ def clone(self, link): err = err.last_attempt.exception() err = str(err).replace('>', '').replace('<', '') LOGGER.error(err) - if "User rate limit exceeded" in str(err): + if "User rate limit exceeded" in err: msg = "User rate limit exceeded." - elif "File not found" in str(err): + elif "File not found" in err: token_service = self.alt_authorize() if token_service is not None: self.__service = token_service @@ -488,7 +486,10 @@ def create_directory(self, directory_name, parent_id): file_id = file.get("id") if not IS_TEAM_DRIVE: self.__set_permission(file_id) - LOGGER.info("โ™ป๏ธ Created G-Drive Folder:\nName: {}\nID: {} ".format(file.get("name"), file_id)) + LOGGER.info( + f'โ™ป๏ธ Created G-Drive Folder:\nName: {file.get("name")}\nID: {file_id} ' + ) + return file_id def upload_dir(self, input_directory, parent_id): @@ -724,7 +725,7 @@ def drive_list(self, fileName, stopDup=False, noMulti=False): msg += f' | Index Link' elif file.get('mimeType') == 'application/vnd.google-apps.shortcut': msg += f"โ{file.get('name')}" \ - f" (shortcut)" + f" (shortcut)" # Excluded index link as indexes cant download or open these shortcuts else: furl = f"https://drive.google.com/uc?id={file.get('id')}&export=download" @@ -826,12 +827,12 @@ def count(self, link): except Exception as err: err = str(err).replace('>', '').replace('<', '') LOGGER.error(err) - if "File not found" in str(err): + if "File not found" in err: token_service = self.alt_authorize() if token_service is not None: self.__service = token_service return self.count(link) - msg = "File not found." + msg = "File not found." else: msg = f"Error.\n{err}" return msg @@ -880,12 +881,12 @@ def helper(self, link): except Exception as err: err = str(err).replace('>', '').replace('<', '') LOGGER.error(err) - if "File not found" in str(err): + if "File not found" in err: token_service = self.alt_authorize() if token_service is not None: self.__service = token_service return self.helper(link) - msg = "File not found." + msg = "File not found." else: msg = f"Error.\n{err}" return msg, "", "", "" @@ -909,9 +910,9 @@ def download(self, link): err = err.last_attempt.exception() err = str(err).replace('>', '').replace('<', '') LOGGER.error(err) - if "downloadQuotaExceeded" in str(err): + if "downloadQuotaExceeded" in err: err = "Download Quota Exceeded." - elif "File not found" in str(err): + elif "File not found" in err: token_service = self.alt_authorize() if token_service is not None: self.__service = token_service @@ -928,7 +929,7 @@ def download(self, link): def download_folder(self, folder_id, path, folder_name): if not os.path.exists(path + folder_name): os.makedirs(path + folder_name) - path += folder_name + '/' + path += f'{folder_name}/' result = [] page_token = None while True: @@ -965,7 +966,7 @@ def download_folder(self, folder_id, path, folder_name): 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') + fh = io.FileIO(f'{path}{filename}', 'wb') downloader = MediaIoBaseDownload(fh, request, chunksize = 65 * 1024 * 1024) done = False while not done: diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 67632c0e2..a3dbb897d 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -84,7 +84,7 @@ def onDownloadComplete(self): download_dict[self.uid] = TarStatus(name, m_path, size) if self.isZip: pswd = self.pswd - path = m_path + ".zip" + path = f"{m_path}.zip" LOGGER.info(f'Zip: orig_path: {m_path}, zip_path: {path}') if pswd is not None: subprocess.run(["7z", "a", "-mx=0", f"-p{pswd}", path, m_path]) @@ -112,8 +112,8 @@ def onDownloadComplete(self): for dirpath, subdir, files in os.walk(m_path, topdown=False): for filee in files: if re.search(r'\.part0*1.rar$', filee) or re.search(r'\.7z.0*1$', filee) \ - or (filee.endswith(".rar") and not re.search(r'\.part\d+.rar$', filee)) \ - or re.search(r'\.zip.0*1$', filee): + or (filee.endswith(".rar") and not re.search(r'\.part\d+.rar$', filee)) \ + or re.search(r'\.zip.0*1$', filee): m_path = os.path.join(dirpath, filee) if pswd is not None: result = subprocess.run(["7z", "x", f"-p{pswd}", m_path, f"-o{dirpath}"]) @@ -124,7 +124,7 @@ def onDownloadComplete(self): break for filee in files: if filee.endswith(".rar") or re.search(r'\.r\d+$', filee) \ - or re.search(r'\.7z.\d+$', filee) or re.search(r'\.zip.\d+$', filee): + or re.search(r'\.7z.\d+$', filee) or re.search(r'\.zip.\d+$', filee): del_path = os.path.join(dirpath, filee) os.remove(del_path) path = f'{DOWNLOAD_DIR}{self.uid}/{name}' @@ -251,10 +251,10 @@ def onUploadComplete(self, link: str, size, files, folders, typ): return with download_dict_lock: msg = f'๐Ÿ—‚ ๐—™๐—ถ๐—น๐—ฒ๐—ก๐—ฎ๐—บ๐—ฒ : {download_dict[self.uid].name()}\n\nSize: {size}\n' \ - f' \n' \ - f'๐Ÿ”ฅ ๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐™ˆ๐™ž๐™ง๐™ง๐™ค๐™ง ๐™•๐™ค๐™ฃ๐™€\n' \ - f' \n' \ - f'๐Ÿ”ฅ ๐™‚๐™ง๐™ค๐™ช๐™ฅ : @mirrorclouds\n' + f' \n' \ + f'๐Ÿ”ฅ ๐™”๐™–๐™ข๐™ง๐™–๐™–๐™Ÿ ๐™ˆ๐™ž๐™ง๐™ง๐™ค๐™ง ๐™•๐™ค๐™ฃ๐™€\n' \ + f' \n' \ + f'๐Ÿ”ฅ ๐™‚๐™ง๐™ค๐™ช๐™ฅ : @mirrorclouds\n' if os.path.isdir(f'{DOWNLOAD_DIR}/{self.uid}/{download_dict[self.uid].name()}'): msg += '\n\nType: Folder' msg += f'\nSubFolders: {folders}' @@ -374,12 +374,8 @@ def _mirror(bot, update, isTar=False, extract=False, isZip=False, isQbit=False, link = link.strip() reply_to = update.message.reply_to_message if reply_to is not None: - file = None media_array = [reply_to.document, reply_to.video, reply_to.audio] - for i in media_array: - if i is not None: - file = i - break + file = next((i for i in media_array if i is not None), None) if ( not bot_utils.is_url(link) and not bot_utils.is_magnet(link) From a5b251545854a350c8565799fe41b6c5cb2d5258 Mon Sep 17 00:00:00 2001 From: Yamraaj Yaduvanshi <69627019+YaMraaJ-debug@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:43:10 +0530 Subject: [PATCH 13/13] Update Dockerfile Signed-off-by: Yamraaj Yaduvanshi <69627019+YaMraaJ-debug@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 276c57ab5..11ae1dc92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM priiiiyo/mega-sdk-python:latest +FROM anasty17/mirror-leech:latest WORKDIR /usr/src/app RUN chmod 777 /usr/src/app