From 9392ae9a3b5fe6aebb478d8fed35694c1b538289 Mon Sep 17 00:00:00 2001 From: Hafitz Setya Date: Wed, 22 Sep 2021 10:03:29 +0700 Subject: [PATCH 1/5] Update bot commands in README.md --- README.md | 15 ++++++++++++++- bot/__main__.py | 26 +++++++++++++------------- bot/modules/mirror.py | 8 ++++---- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6d4eaaf1e6b..b66e4dae09e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ![Docker Pulls](https://img.shields.io/docker/pulls/breakdowns/mega-sdk-python?label=Docker%20Pull) [![Channel](https://img.shields.io/badge/Join%20Channel-!-red)](https://t.me/SlamMirrorUpdates) -**Slam Mirror Bot** is a _multipurpose_ Telegram Bot written in Python for mirroring/leeching files on the Internet to our beloved Google Drive. Based on [python-aria-mirror-bot](https://github.com/lzzy12/python-aria-mirror-bot) +**Slam Mirror Bot** is a _multipurpose_ Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive. Based on [python-aria-mirror-bot](https://github.com/lzzy12/python-aria-mirror-bot) # Features:
@@ -204,11 +204,24 @@ qbmirror - Start Mirroring using qBittorrent qbtarmirror - Start mirroring and upload as .tar using qb qbzipmirror - Start mirroring and upload as .zip using qb qbunzipmirror - Extract files using qBittorrent +leech - Leech Torrent/Direct link +tarleech - Leech Torrent/Direct link and upload as .tar +zipleech - Leech Torrent/Direct link and upload as .zip +unzipleech - Leech Torrent/Direct link and extract +qbleech - Leech Torrent/Direct link using qBittorrent +qbtarleech - Leech Torrent/Direct link and upload as .tar using qb +qbzipleech - Leech Torrent/Direct link and upload as .zip using qb +qbunzipleech - Leech Torrent/Direct link and extract using qb clone - Copy file/folder to Drive count - Count file/folder of Drive link watch - Mirror Youtube-dl supported link tarwatch - Mirror Youtube playlist link and upload as .tar zipwatch - Mirror Youtube playlist link and upload as .zip +leechwatch - Leech through Youtube-dl supported link +leechtarwatch - Leech Youtube playlist link and upload as .tar +leechzipwatch - Leech Youtube playlist link and upload as .zip +leechset - Leech settings +leechset - Set Thumbnail status - Get Mirror Status message list - [query] Searches files in Drive cancel - Cancel a task diff --git a/bot/__main__.py b/bot/__main__.py index 205ee0898f0..b6b23b8d539 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -105,21 +105,21 @@ def log(update, context):

/{BotCommands.QbUnzipMirrorCommand} [magnet_link]: Starts mirroring using qBittorrent and if downloaded file is any archive, extracts it to Google Drive

-/{BotCommands.LeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.LeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.TarLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.tar). [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.TarLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.tar). [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.ZipLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.zip). [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.ZipLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.zip). [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.UnzipLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link and if file is any archive, extracts it. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.UnzipLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link and if file is any archive, extracts it. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.QbLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.QbLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.QbTarLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.tar) using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.QbTarLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.tar) using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.QbZipLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.zip) using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.QbZipLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link and upload it as (.zip) using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

-/{BotCommands.QbUnzipLeechCommand} This command should be used as reply to Magnet link, Torrent link, or Direct link and if file is any archive, extracts it using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent] +/{BotCommands.QbUnzipLeechCommand}: This command should be used as reply to Magnet link, Torrent link, or Direct link and if file is any archive, extracts it using qBittorrent. [this command will SPAM the chat and send the downloads a seperate files, if there is more than one file, in the specified Torrent]

/{BotCommands.CloneCommand} [drive_url]: Copy file/folder to Google Drive

@@ -133,15 +133,15 @@ def log(update, context):

/{BotCommands.ZipWatchCommand} [youtube-dl supported link]: Mirror through youtube-dl and zip before uploading

-/{BotCommands.LeechWatchCommand} Leech through youtube-dl +/{BotCommands.LeechWatchCommand}: Leech through youtube-dl

-/{BotCommands.LeechTarWatchCommand} Leech through youtube-dl and tar before uploading +/{BotCommands.LeechTarWatchCommand}: Leech through youtube-dl and tar before uploading

-/{BotCommands.LeechZipWatchCommand} Leech through youtube-dl and zip before uploading +/{BotCommands.LeechZipWatchCommand}: Leech through youtube-dl and zip before uploading

-/{BotCommands.LeechSetCommand} Leech Settings +/{BotCommands.LeechSetCommand}: Leech Settings

-/{BotCommands.SetThumbCommand} Reply to photo to set it as thumbnail for next uploads +/{BotCommands.SetThumbCommand}: Reply to photo to set it as Thumbnail

/{BotCommands.CancelMirror}: Reply to the message by which the download was initiated and that download will be cancelled

diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index 109418ba80d..28a3a95cdf9 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -205,13 +205,13 @@ def onUploadComplete(self, link: str, size, files, folders, typ): chat_id = str(self.message.chat.id) count = len(files) if OWNER_ID == int(chat_id): - msg = f'Name: {link}\n' - msg += f'Total Files: {count}' + msg = f'Name: {link}\n' + msg += f'Total Files: {count}' sendMessage(msg, self.bot, self.update) else: chat_id = chat_id[4:] - msg = f"Name: {link}\n" - msg += f'Total Files: {count}\n' + msg = f"Name: {link}\n" + msg += f'Total Files: {count}\n' msg += f'cc: {uname}\n\n' fmsg = '' for index, item in enumerate(list(files), start=1): From 5239dfa96ad4bb9bb29d7206aeaee1122344abd0 Mon Sep 17 00:00:00 2001 From: Hafitz Setya Date: Wed, 22 Sep 2021 10:09:37 +0700 Subject: [PATCH 2/5] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b66e4dae09e..22240e46394 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ leechwatch - Leech through Youtube-dl supported link leechtarwatch - Leech Youtube playlist link and upload as .tar leechzipwatch - Leech Youtube playlist link and upload as .zip leechset - Leech settings -leechset - Set Thumbnail +setthumb - Set Thumbnail status - Get Mirror Status message list - [query] Searches files in Drive cancel - Cancel a task From e5ab2cec858d98dfb4c5c684fa8f46e13efc5986 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Wed, 22 Sep 2021 03:28:35 +0000 Subject: [PATCH 3/5] 'Refactored by Sourcery' --- bot/helper/ext_utils/bot_utils.py | 15 ++++----- bot/helper/ext_utils/fs_utils.py | 18 +++++----- .../download_utils/qbit_downloader.py | 22 ++++++------- .../upload_utils/pyrogramEngine.py | 8 ++--- bot/modules/leech_settings.py | 33 +++++++++---------- 5 files changed, 44 insertions(+), 52 deletions(-) diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index 283dafac6b4..c2e7a04c2a3 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -157,14 +157,13 @@ def get_readable_message(): msg += "\n\n" if STATUS_LIMIT is not None and index == STATUS_LIMIT: break - if STATUS_LIMIT is not None: - if dick_no > STATUS_LIMIT: - msg += f"Page: {PAGE_NO}/{pages} | Tasks: {dick_no}\n" - buttons = button_build.ButtonMaker() - buttons.sbutton("Previous", "pre") - buttons.sbutton("Next", "nex") - button = InlineKeyboardMarkup(buttons.build_menu(2)) - return msg, button + if STATUS_LIMIT is not None and dick_no > STATUS_LIMIT: + msg += f"Page: {PAGE_NO}/{pages} | Tasks: {dick_no}\n" + buttons = button_build.ButtonMaker() + buttons.sbutton("Previous", "pre") + buttons.sbutton("Next", "nex") + button = InlineKeyboardMarkup(buttons.build_menu(2)) + return msg, button return msg, "" def flip(update, context): diff --git a/bot/helper/ext_utils/fs_utils.py b/bot/helper/ext_utils/fs_utils.py index 41bd5d58bdd..62b0b801e61 100644 --- a/bot/helper/ext_utils/fs_utils.py +++ b/bot/helper/ext_utils/fs_utils.py @@ -160,23 +160,23 @@ def get_mime_type(file_path): return mime_type def take_ss(video_file, duration): - des_dir = f"Thumbnails" + des_dir = 'Thumbnails' if not os.path.exists(des_dir): os.mkdir(des_dir) des_dir = os.path.join(des_dir, f"{round(time.time())}.jpg") duration = int(duration) / 2 subprocess.run(["ffmpeg", "-hide_banner", "-loglevel", "error", "-ss", str(duration), "-i", video_file, "-vframes", "1", des_dir]) - if os.path.lexists(des_dir): - Image.open(des_dir).convert("RGB").save(des_dir) - img = Image.open(des_dir) - w, h = img.size - img.resize((320, h)) - img.save(des_dir, "JPEG") - return des_dir, 320, h - else: + if not os.path.lexists(des_dir): return None, 0, 0 + Image.open(des_dir).convert("RGB").save(des_dir) + img = Image.open(des_dir) + w, h = img.size + img.resize((320, h)) + img.save(des_dir, "JPEG") + return des_dir, 320, h + def split(path, size, split_size, start_time=0, i=1): out_dir = os.path.dirname(path) base_name = os.path.basename(path) diff --git a/bot/helper/mirror_utils/download_utils/qbit_downloader.py b/bot/helper/mirror_utils/download_utils/qbit_downloader.py index 82c824f2e0d..3d967bebb34 100644 --- a/bot/helper/mirror_utils/download_utils/qbit_downloader.py +++ b/bot/helper/mirror_utils/download_utils/qbit_downloader.py @@ -215,20 +215,20 @@ def get_confirm(update, context): data = query.data data = data.split(" ") qdl = getDownloadByGid(data[1]) - if qdl is not None: - if user_id != qdl.listener.message.from_user.id: - query.answer(text="Don't waste your time!", show_alert=True) - elif data[0] == "pin": - query.answer(text=data[2], show_alert=True) - elif data[0] == "done": - query.answer() - qdl.client.torrents_resume(torrent_hashes=data[2]) - sendStatusMessage(qdl.listener.update, qdl.listener.bot) - query.message.delete() - else: + if qdl is None: query.answer(text="This task has been cancelled!", show_alert=True) query.message.delete() + elif user_id != qdl.listener.message.from_user.id: + query.answer(text="Don't waste your time!", show_alert=True) + elif data[0] == "pin": + query.answer(text=data[2], show_alert=True) + elif data[0] == "done": + query.answer() + qdl.client.torrents_resume(torrent_hashes=data[2]) + sendStatusMessage(qdl.listener.update, qdl.listener.bot) + query.message.delete() + def get_hash_magnet(mgt): if mgt.startswith('magnet:'): diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py index c082f300e8c..185ec86c36e 100644 --- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py +++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py @@ -81,15 +81,11 @@ def upload_file(self, up_path, file): if self.thumb is None and thumb is not None and os.path.lexists(thumb): os.remove(thumb) elif file.upper().endswith(AUDIO_SUFFIXES): - title = None - artist = None metadata = extractMetadata(createParser(up_path)) if metadata.has("duration"): duration = metadata.get('duration').seconds - if metadata.has("title"): - title = metadata.get("title") - if metadata.has("artist"): - artist = metadata.get("artist") + title = metadata.get("title") if metadata.has("title") else None + artist = metadata.get("artist") if metadata.has("artist") else None self.sent_msg = self.sent_msg.reply_audio(audio=up_path, quote=True, caption=file, diff --git a/bot/modules/leech_settings.py b/bot/modules/leech_settings.py index b1c493c9698..d93c67f983c 100644 --- a/bot/modules/leech_settings.py +++ b/bot/modules/leech_settings.py @@ -20,19 +20,16 @@ def leechSet(update, context): user_id = update.message.from_user.id path = f"Thumbnails/{user_id}.jpg" msg = f"Leech Type for {user_id} user is " - if user_id in AS_DOC_USERS: + if ( + user_id in AS_DOC_USERS + or user_id not in AS_MEDIA_USERS + and AS_DOCUMENT + ): msg += "DOCUMENT" - elif user_id in AS_MEDIA_USERS: - msg += "MEDIA" - elif AS_DOCUMENT: - msg += "DOCUMENT" - elif not AS_DOCUMENT: + else: msg += "MEDIA" msg += "\nCustom Thmubnail " - if os.path.exists(path): - msg += "exists" - else: - msg += "not exists" + msg += "exists" if os.path.exists(path) else "not exists" buttons = button_build.ButtonMaker() buttons.sbutton("As Document", f"doc {user_id}") buttons.sbutton("As Media", f"med {user_id}") @@ -51,15 +48,17 @@ def setLeechType(update, context): if user_id != int(data[1]): query.answer(text="Not Yours!", show_alert=True) elif data[0] == "doc": - if user_id in AS_DOC_USERS: + if ( + user_id in AS_DOC_USERS + or user_id not in AS_MEDIA_USERS + and AS_DOCUMENT + ): query.answer(text="Already As Document!", show_alert=True) elif user_id in AS_MEDIA_USERS: AS_MEDIA_USERS.remove(user_id) AS_DOC_USERS.add(user_id) query.answer(text="Done!", show_alert=True) - elif AS_DOCUMENT: - query.answer(text="Already As Document!", show_alert=True) - elif not AS_DOCUMENT: + else: AS_DOC_USERS.add(user_id) query.answer(text="Done!", show_alert=True) elif data[0] == "med": @@ -67,13 +66,11 @@ def setLeechType(update, context): AS_DOC_USERS.remove(user_id) AS_MEDIA_USERS.add(user_id) query.answer(text="Done!", show_alert=True) - elif user_id in AS_MEDIA_USERS: + elif user_id in AS_MEDIA_USERS or not AS_DOCUMENT: query.answer(text="Already As Media!", show_alert=True) - elif AS_DOCUMENT: + else: AS_MEDIA_USERS.add(user_id) query.answer(text="Done!", show_alert=True) - elif not AS_DOCUMENT: - query.answer(text="Already As Media!", show_alert=True) elif data[0] == "thumb": path = f"Thumbnails/{user_id}.jpg" if os.path.lexists(path): From e200fc2df1147c9eec20e958c9b5a9ea5fbf6c57 Mon Sep 17 00:00:00 2001 From: Hafitz Setya Date: Wed, 22 Sep 2021 10:31:24 +0700 Subject: [PATCH 4/5] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22240e46394..b153fbe6635 100644 --- a/README.md +++ b/README.md @@ -208,10 +208,10 @@ leech - Leech Torrent/Direct link tarleech - Leech Torrent/Direct link and upload as .tar zipleech - Leech Torrent/Direct link and upload as .zip unzipleech - Leech Torrent/Direct link and extract -qbleech - Leech Torrent/Direct link using qBittorrent -qbtarleech - Leech Torrent/Direct link and upload as .tar using qb -qbzipleech - Leech Torrent/Direct link and upload as .zip using qb -qbunzipleech - Leech Torrent/Direct link and extract using qb +qbleech - Leech Torrent using qBittorrent +qbtarleech - Leech Torrent and upload as .tar using qb +qbzipleech - Leech Torrent and upload as .zip using qb +qbunzipleech - Leech Torrent and extract using qb clone - Copy file/folder to Drive count - Count file/folder of Drive link watch - Mirror Youtube-dl supported link From 9ba42f0eea9f9d54281176bb48cfc81c58ce1024 Mon Sep 17 00:00:00 2001 From: Hafitz Setya Date: Wed, 22 Sep 2021 10:33:15 +0700 Subject: [PATCH 5/5] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b153fbe6635..39ed9cd606f 100644 --- a/README.md +++ b/README.md @@ -208,9 +208,9 @@ leech - Leech Torrent/Direct link tarleech - Leech Torrent/Direct link and upload as .tar zipleech - Leech Torrent/Direct link and upload as .zip unzipleech - Leech Torrent/Direct link and extract -qbleech - Leech Torrent using qBittorrent -qbtarleech - Leech Torrent and upload as .tar using qb -qbzipleech - Leech Torrent and upload as .zip using qb +qbleech - Leech Torrent/Magnet using qBittorrent +qbtarleech - Leech Torrent/Magnet and upload as .tar using qb +qbzipleech - Leech Torrent/Magnet and upload as .zip using qb qbunzipleech - Leech Torrent and extract using qb clone - Copy file/folder to Drive count - Count file/folder of Drive link