diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index 340c5a425e31..71f0af8dec26 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -62,12 +62,12 @@ def create_help_buttons(): f"help mirror {name}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "help close" ) COMMAND_USAGE["mirror"] = [ MIRROR_HELP_DICT["main"], - buttons.build_menu(3) + buttons.build_menu(2) ] buttons.reset() for name in list(YT_HELP_DICT.keys())[1:]: @@ -76,12 +76,12 @@ def create_help_buttons(): f"help yt {name}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "help close" ) COMMAND_USAGE["yt"] = [ YT_HELP_DICT["main"], - buttons.build_menu(3) + buttons.build_menu(2) ] buttons.reset() for name in list(CLONE_HELP_DICT.keys())[1:]: @@ -90,12 +90,12 @@ def create_help_buttons(): f"help clone {name}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "help close" ) COMMAND_USAGE["clone"] = [ CLONE_HELP_DICT["main"], - buttons.build_menu(3) + buttons.build_menu(2) ] @@ -116,24 +116,24 @@ def bt_selection_buttons(id_): BASE_URL = config_dict["BASE_URL"] if config_dict["WEB_PINCODE"]: buttons.ubutton( - "Select Files", + "ꜱᴇʟᴇᴄᴛ ꜰɪʟᴇꜱ", f"{BASE_URL}/app/files/{id_}" ) buttons.ibutton( - "Pincode", + "ᴘɪɴᴄᴏᴅᴇ", f"sel pin {gid} {pincode}" ) else: buttons.ubutton( - "Select Files", + "ꜱᴇʟᴇᴄᴛ ꜰɪʟᴇꜱ", f"{BASE_URL}/app/files/{id_}?pin_code={pincode}" ) buttons.ibutton( - "Done Selecting", + "ᴅᴏɴᴇ ꜱᴇʟᴇᴄᴛɪɴɢ", f"sel done {gid} {id_}" ) buttons.ibutton( - "Cancel", + "ᴄʟᴏꜱᴇ", f"sel cancel {gid}" ) return buttons.build_menu(2) @@ -141,7 +141,10 @@ def bt_selection_buttons(id_): def extra_btns(buttons): if extra_buttons: - for btn_name, btn_url in extra_buttons.items(): + for ( + btn_name, + btn_url + ) in extra_buttons.items(): buttons.ubutton( btn_name, btn_url @@ -154,87 +157,87 @@ async def set_commands(client): await client.set_bot_commands([ BotCommand( f"{BotCommands.MirrorCommand[0]}", - "Mirror direct links using Aria2" + "ᴍɪʀʀᴏʀ ᴅɪʀᴇᴄᴛ ʟɪɴᴋꜱ ᴜꜱɪɴɢ ᴀʀɪᴀ2ᴄ" ), BotCommand( f"{BotCommands.JdMirrorCommand[0]}", - "Mirror supported links using JDownloader" + "ᴍɪʀʀᴏʀ ᴊᴅᴏᴡɴʟᴏᴀᴅᴇʀ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ" ), BotCommand( f"{BotCommands.NzbMirrorCommand[0]}", - "Mirror NZB files using SABnzbd" + "ᴍɪʀʀᴏʀ ꜱᴀʙɴᴢʙᴅ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ ᴏʀ ꜰɪʟᴇꜱ" ), BotCommand( f"{BotCommands.QbMirrorCommand[0]}", - "Mirror torrents using qBittorrent" + "ᴍɪʀʀᴏʀ Qʙɪᴛ-ᴛᴏʀʀᴇɴᴛ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ ᴏʀ ꜰɪʟᴇꜱ" ), BotCommand( f"{BotCommands.YtdlCommand[0]}", - "Mirror yt-dlp supported links" + "ᴍɪʀʀᴏʀ ʏᴛ-ᴅʟᴘ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ" ), BotCommand( f"{BotCommands.LeechCommand[0]}", - "Leech direct links using Aria2" + "ʟᴇᴇᴄʜ ᴅɪʀᴇᴄᴛ ʟɪɴᴋꜱ ᴜꜱɪɴɢ ᴀʀɪᴀ2ᴄ" ), BotCommand( f"{BotCommands.JdLeechCommand[0]}", - "Leech supported links using JDownloader" + "ʟᴇᴇᴄʜ ᴊᴅᴏᴡɴʟᴏᴀᴅᴇʀ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ" ), BotCommand( f"{BotCommands.NzbLeechCommand[0]}", - "Leech NZB files using SABnzbd" + "ʟᴇᴇᴄʜ ꜱᴀʙɴᴢʙᴅ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ ᴏʀ ꜰɪʟᴇꜱ" ), BotCommand( f"{BotCommands.QbLeechCommand[0]}", - "Leech torrents using qBittorrent" + "ʟᴇᴇᴄʜ Qʙɪᴛ-ᴛᴏʀʀᴇɴᴛ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ ᴏʀ ꜰɪʟᴇꜱ" ), BotCommand( f"{BotCommands.YtdlLeechCommand[0]}", - "Leech yt-dlp supported links" + "ʟᴇᴇᴄʜ ʏᴛ-ᴅʟᴘ ꜱᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋꜱ" ), BotCommand( f"{BotCommands.CloneCommand}", - "Copy file/folder to Drive" + "ᴄᴏᴘʏ ꜰɪʟᴇ ᴏʀ ꜰᴏʟᴅᴇʀ ᴛᴏ ᴛʜᴇ ᴅʀɪᴠᴇ" ), BotCommand( f"{BotCommands.CountCommand}", - "[drive_url]: Count file/folder of Google Drive." + "[ᴅʀɪᴠᴇ ᴜʀʟ]: ᴄᴏᴜɴᴛ ꜰɪʟᴇ ᴏʀ ꜰᴏʟᴅᴇʀ ᴏꜰ ᴛʜᴇ ɢᴏᴏɢʟᴇ ᴅʀɪᴠᴇ" ), BotCommand( f"{BotCommands.StatusCommand[0]}", - "Get mirror status message" + "ɢᴇᴛ ᴀʟʟ ᴛᴀꜱᴋꜱ ꜱᴛᴀᴛᴜꜱ ᴍᴇꜱꜱᴀɢᴇ" ), BotCommand( f"{BotCommands.StatsCommand[0]}", - "Check bot stats" + "ᴄʜᴇᴄᴋ ʙᴏᴛ ꜱᴛᴀᴛꜱ" ), BotCommand( f"{BotCommands.SelectCommand}", - "Select files to download only torrents" + "ꜱᴇʟᴇᴄᴛ ꜰɪʟᴇꜱ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ" ), BotCommand( f"{BotCommands.CancelTaskCommand[0]}", - "Cancel a Task" + "ᴄᴀɴᴄᴇʟ ᴀ ᴛᴀꜱᴋ" ), BotCommand( f"{BotCommands.CancelAllCommand}", - "Cancel all tasks which added by you." + "ᴄᴀɴᴄᴇʟ ᴀʟʟ ᴛᴀꜱᴋꜱ ᴡʜɪᴄʜ ᴀᴅᴅᴇᴅ ʙʏ ʏᴏᴜ" ), BotCommand( f"{BotCommands.ListCommand}", - "Search in Drive" + "ꜱᴇᴀʀᴄʜ ɪɴ ᴅʀɪᴠᴇ" ), BotCommand( f"{BotCommands.SearchCommand}", - "Search in Torrent" + "ꜱᴇᴀʀᴄʜ ɪɴ ᴛᴏʀʀᴇɴᴛ" ), BotCommand( f"{BotCommands.UserSetCommand[0]}", - "Users settings" + "ᴜꜱᴇʀꜱ ꜱᴇᴛᴛɪɴɢꜱ" ), BotCommand( f"{BotCommands.HelpCommand}", - "Get detailed help" + "ɢᴇᴛ ᴅᴇᴛᴀɪʟᴇᴅ ʜᴇʟᴘ" ), ]) @@ -243,7 +246,7 @@ async def get_telegraph_list(telegraph_content): path = [ ( await telegraph.create_page( - title="Z-Mirror Drive Search", + title="ᴢ-ᴍɪʀʀᴏʀ ᴅʀɪᴠᴇ ꜱᴇᴀʀᴄʜ", content=content ) )["path"] @@ -256,7 +259,7 @@ async def get_telegraph_list(telegraph_content): ) buttons = ButtonMaker() buttons.ubutton( - "🔎 VIEW", + "🔎 ᴠɪᴇᴡ\nʀᴇꜱᴜʟᴛꜱ", f"https://telegra.ph/{path[0]}" ) return buttons.build_menu(1) @@ -308,7 +311,10 @@ def arg_parser(items, arg_base): for j in range(i + 1, t): item = items[j] if item in arg_base: - if part in bool_arg_set and not sub_list: + if ( + part in bool_arg_set + and not sub_list + ): arg_base[part] = True break sub_list.append(item) @@ -316,7 +322,10 @@ def arg_parser(items, arg_base): if sub_list: arg_base[part] = " ".join(sub_list) i += 1 - if "link" in arg_base and items[0] not in arg_base: + if ( + "link" in arg_base + and items[0] not in arg_base + ): link = [] if arg_start == -1: link.extend(iter(items)) @@ -396,7 +405,11 @@ async def cmd_exec(cmd, shell=False): stderr = stderr.decode().strip() except: stderr = "Unable to decode the error!" - return stdout, stderr, proc.returncode + return ( + stdout, + stderr, + proc.returncode + ) def new_task(func): diff --git a/bot/helper/ext_utils/help_messages.py b/bot/helper/ext_utils/help_messages.py index 4bf8d2b51537..775e7e1736d1 100644 --- a/bot/helper/ext_utils/help_messages.py +++ b/bot/helper/ext_utils/help_messages.py @@ -263,58 +263,58 @@ YT_HELP_DICT = { "main": yt, - "New-Name": f"{new_name}\nNote: Don't add file extension", - "Zip": zip_arg, - "Quality": qual, - "Options": yt_opt, - "Multi-Link": multi_link, - "Same-Directory": same_dir, - "Thumb": thumb, - "Split-Size": split_size, - "Upload-Destination": upload, - "Rclone-Flags": rcf, - "Bulk": bulk, - "Sample-Video": sample_video, - "Screenshot": screenshot, - "Convert-Media": convert_media, - "Force-Start": force_start, - "Name-Substitute": name_sub, - "Mixed-Leech": mixed_leech, + "ʀᴇɴᴀᴍᴇ\nꜰɪʟᴇ": f"{new_name}\nNote: Don't add file extension", + "ᴢɪᴘ\nꜰɪʟᴇꜱ": zip_arg, + "Qᴜᴀʟɪᴛʏ\nᴏᴘᴛ": qual, + "ʏᴛ\nᴏᴘᴛɪᴏɴꜱ": yt_opt, + "ᴍᴜʟᴛɪ\nʟɪɴᴋ": multi_link, + "ꜱᴀᴍᴇ\nᴅɪʀᴇᴄᴛᴏʀʏ": same_dir, + "ᴀᴅᴅ\nᴛʜᴜᴍʙ": thumb, + "ꜱᴘʟɪᴛ\nꜱɪᴢᴇ": split_size, + "ᴜᴘʟᴏᴀᴅ\nᴅᴇꜱᴛɪɴᴀᴛɪᴏɴ": upload, + "ʀᴄʟᴏɴᴇ\nꜰʟᴀɢꜱ": rcf, + "ʙᴜʟᴋ\nʟɪɴᴋꜱ": bulk, + "ꜱᴀᴍᴘʟᴇ\nᴠɪᴅᴇᴏ": sample_video, + "ꜱᴄʀᴇᴇɴ\nꜱʜᴏᴛ": screenshot, + "ᴄᴏɴᴠᴇʀᴛ\nᴍᴇᴅɪᴀ": convert_media, + "ꜰᴏʀᴄᴇ\nꜱᴛᴀʀᴛ": force_start, + "ɴᴀᴍᴇ\nꜱᴜʙꜱᴛɪᴛᴜᴛᴇ": name_sub, + "ʜʏʙʀɪᴅ\nʟᴇᴇᴄʜ": mixed_leech, } MIRROR_HELP_DICT = { "main": mirror, - "New-Name": new_name, - "DL-Auth": "Direct link authorization: -au -ap\n\n/cmd link -au username -ap password", - "Headers": "Direct link custom headers: -h\n\n/cmd link -h key: value key1: value1", - "Extract/Zip": extract_zip, - "Select-Files": "Bittorrent/JDownloader/Sabnzbd File Selection: -s\n\n/cmd link -s or by replying to file/link", - "Torrent-Seed": seed, - "Multi-Link": multi_link, - "Same-Directory": same_dir, - "Thumb": thumb, - "Split-Size": split_size, - "Upload-Destination": upload, - "Rclone-Flags": rcf, - "Bulk": bulk, - "Join": join, - "Rclone-DL": rlone_dl, - "Tg-Links": tg_links, - "Sample-Video": sample_video, - "Screenshot": screenshot, - "Convert-Media": convert_media, - "Force-Start": force_start, - "User-Download": user_download, - "Name-Substitute": name_sub, - "Mixed-Leech": mixed_leech, + "ʀᴇɴᴀᴍᴇ\nꜰɪʟᴇ": new_name, + "ᴅᴏᴡɴʟᴏᴀᴅ\nᴀᴜᴛʜ": "Direct link authorization: -au -ap\n\n/cmd link -au username -ap password", + "ᴅᴅʟ\nʜᴇᴀᴅᴇʀꜱ": "Direct link custom headers: -h\n\n/cmd link -h key: value key1: value1", + "ᴇxᴛʀᴀᴄᴛ\nᴢɪᴘ": extract_zip, + "ꜱᴇʟᴇᴄᴛ\nꜰɪʟᴇꜱ": "Bittorrent/JDownloader/Sabnzbd File Selection: -s\n\n/cmd link -s or by replying to file/link", + "ᴛᴏʀʀᴇɴᴛ\nꜱᴇᴇᴅ": seed, + "ᴍᴜʟᴛɪ\nʟɪɴᴋ": multi_link, + "ꜱᴀᴍᴇ\nᴅɪʀᴇᴄᴛᴏʀʏ": same_dir, + "ᴀᴅᴅ\nᴛʜᴜᴍʙ": thumb, + "ꜱᴘʟɪᴛ\nꜱɪᴢᴇ": split_size, + "ᴜᴘʟᴏᴀᴅ\nᴅᴇꜱᴛɪɴᴀᴛɪᴏɴ": upload, + "ʀᴄʟᴏɴᴇ\nꜰʟᴀɢꜱ": rcf, + "ʙᴜʟᴋ\nʟɪɴᴋꜱ": bulk, + "ᴊᴏɪɴ\nꜰɪʟᴇꜱ": join, + "ʀᴄʟᴏɴᴇ\nᴅʟ": rlone_dl, + "ᴛᴇʟᴇɢʀᴀᴍ\nʟɪɴᴋꜱ": tg_links, + "ꜱᴀᴍᴘʟᴇ\nᴠɪᴅᴇᴏ": sample_video, + "ꜱᴄʀᴇᴇɴ\nꜱʜᴏᴛ": screenshot, + "ᴄᴏɴᴠᴇʀᴛ\nᴍᴇᴅɪᴀ": convert_media, + "ꜰᴏʀᴄᴇ\nꜱᴛᴀʀᴛ": force_start, + "ᴜꜱᴇʀ\nᴅᴏᴡɴʟᴏᴀᴅ": user_download, + "ɴᴀᴍᴇ\nꜱᴜʙꜱᴛɪᴛᴜᴛᴇ": name_sub, + "ʜʏʙʀɪᴅ\nʟᴇᴇᴄʜ": mixed_leech, } CLONE_HELP_DICT = { "main": clone, - "Multi-Link": multi_link, - "Bulk": bulk, - "Gdrive": gdrive, - "Rclone": rclone_cl, + "ᴍᴜʟᴛɪ\nʟɪɴᴋ": multi_link, + "ʙᴜʟᴋ\nʟɪɴᴋꜱ": bulk, + "ɢᴏᴏɢʟᴇ\nᴅʀɪᴠᴇ": gdrive, + "ʀᴄʟᴏɴᴇ\nᴅʟ": rclone_cl, } RSS_HELP_MESSAGE = """ @@ -342,7 +342,8 @@ """ PASSWORD_ERROR_MESSAGE = """ -This link requires a password! +Links require a password! + - Insert :: after the link and write the password after the sign. Example: link::my password diff --git a/bot/helper/ext_utils/status_utils.py b/bot/helper/ext_utils/status_utils.py index 5969a51377ed..8785388eac56 100644 --- a/bot/helper/ext_utils/status_utils.py +++ b/bot/helper/ext_utils/status_utils.py @@ -252,15 +252,15 @@ async def get_readable_message( and int(config_dict["AUTO_DELETE_MESSAGE_DURATION"]) > 0 ): msg += ( - f"```\n#Zee{index + start_position}: " - f"{escape(f"{task.name()}")}\n```" + f"
\r\n{index + start_position} ➜ "
+                f"{escape(f"{task.name()}")}\n
" if elapse <= config_dict["AUTO_DELETE_MESSAGE_DURATION"] - else f"\n
#Zee{index + start_position}...(Processing)
" + else f"\n
{index + start_position} ➜ (Processing)
" ) else: msg += ( - f"```\n#Zee{index + start_position}: " - f"{escape(f"{task.name()}")}\n```" + f"
\r\n{index + start_position} ➜ "
+                f"{escape(f"{task.name()}")}\n
" ) if tstatus not in [ MirrorStatus.STATUS_SEEDING, @@ -310,10 +310,12 @@ async def get_readable_message( ) else: msg += ( + f"\nStatus : {tstatus}" f"\nSize : {task.size()}" f"\nUpload : {task.listener.mode}" f"\nPast : {elapsed}" f"\nUser : {user_tag}" + f"\nUserID : ||{task.listener.userId}||" f"\nEngine : {task.engine}" ) msg += f"\n
⚠️ {cancel_task}
\n\n" @@ -336,11 +338,13 @@ async def get_readable_message( if not is_user: buttons.ibutton( "ᴛᴀsᴋs\nɪɴғᴏ", - f"status {sid} ov" + f"status {sid} ov", + position="footer" ) buttons.ibutton( "sʏsᴛᴇᴍ\nɪɴғᴏ", - f"status {sid} stats" + f"status {sid} stats", + position="footer" ) if len(tasks) > STATUS_LIMIT: msg += f"Tasks: {tasks_no} | Step: {page_step}\n" @@ -371,8 +375,7 @@ async def get_readable_message( ]: buttons.ibutton( i, - f"status {sid} ps {i}", - position="footer" + f"status {sid} ps {i}" ) if ( status != "All" or @@ -389,10 +392,11 @@ async def get_readable_message( ) button = buttons.build_menu(8) msg += ( - f"CPU: {cpu_percent()}% | " - f"FREE: {get_readable_file_size(disk_usage(DOWNLOAD_DIR).free)}\n" - f"RAM: {virtual_memory().percent}% | " - f"UPTM: {get_readable_time(time() - botStartTime)}" + "▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n" + f"ᴄᴘᴜ: {cpu_percent()}% | " + f"ꜰʀᴇᴇ: {get_readable_file_size(disk_usage(DOWNLOAD_DIR).free)}\n" + f"ʀᴀᴍ: {virtual_memory().percent}% | " + f"ᴜᴘᴛᴍ: {get_readable_time(time() - botStartTime)}" ) return ( msg, diff --git a/bot/helper/ext_utils/token_manager.py b/bot/helper/ext_utils/token_manager.py index 389c089acf75..f0d99f0ae0b0 100644 --- a/bot/helper/ext_utils/token_manager.py +++ b/bot/helper/ext_utils/token_manager.py @@ -61,12 +61,12 @@ async def checking_access(user_id, button=None): if button is None: button = ButtonMaker() button.ubutton( - "Get New Token", + "ɢᴇɴᴇʀᴀᴛᴇ\nɴᴇᴡ ᴛᴏᴋᴇɴ", short_url(f"https://redirect.z-mirror.eu.org/{bot_name}/{token}") ) tmsg = ( - "Your Token is expired. Get a new one." - f"\nToken Validity: {get_readable_time(config_dict["TOKEN_TIMEOUT"])}\n" + "You need to generate a new Token." + f"\n➜ Validity: {get_readable_time(config_dict["TOKEN_TIMEOUT"])}" ) return ( tmsg, @@ -118,7 +118,14 @@ async def start(client, message): ) return await sendMessage( message, - "Shortener bypass detected.\n\nPlease generate a new token.\n\nDon't try to bypass it, next time ban." + ( + "Shortener bypass detected.\nPlease generate a new token.\n\n" + "Don't try to bypass it, else next time BAN.\n\n" + "Don't use any Adblocker or VPN or Proxy\n" + "or Incognito or DNS or Extensions\n" + "or Any other Bypass methods.\n\nFor your safety and my " + "profit, use telegram's inbuilt browser or chrome without any extensions." + ) ) if userid not in user_data: return await sendMessage( @@ -149,7 +156,14 @@ async def start(client, message): ) return await sendMessage( message, - "Shortener bypass detected.\n\nPlease generate a new token.\n\nDon't try to bypass it, next time ban." + ( + "Shortener bypass detected.\nPlease generate a new token.\n\n" + "Don't try to bypass it, else next time BAN.\n\n" + "Don't use any Adblocker or VPN or Proxy\n" + "or Incognito or DNS or Extensions\n" + "or Any other Bypass methods.\n\nFor your safety and my" + "profit, use telegram's inbuilt browser or chrome without any extensions." + ) ) token = str(uuid4()) ttime = time() @@ -163,10 +177,10 @@ async def start(client, message): ttime ) msg = ( - "Your token refreshed successfully!\n" - f"Validity: {get_readable_time(int(config_dict["TOKEN_TIMEOUT"]))}\n\n" + "Your token refreshed successfully!\n" + f"➜ Validity: {get_readable_time(int(config_dict["TOKEN_TIMEOUT"]))}\n\n" "Your Limites:\n" - f"{config_dict["USER_MAX_TASKS"]} parallal tasks.\n" + f"➜ {config_dict["USER_MAX_TASKS"]} parallal tasks.\n" ) return await sendMessage( message, diff --git a/bot/helper/listeners/task_listener.py b/bot/helper/listeners/task_listener.py index b7d8a6d70a7a..25d654d2a474 100644 --- a/bot/helper/listeners/task_listener.py +++ b/bot/helper/listeners/task_listener.py @@ -553,13 +553,13 @@ async def onUploadComplete( and not config_dict["DISABLE_DRIVE_LINK"] ): buttons.ubutton( - "♻️ Drive Link", + "ᴅʀɪᴠᴇ\nʟɪɴᴋ", link, "header" ) elif not link.startswith("https://drive.google.com/"): buttons.ubutton( - "☁️ Cloud Link", + "ᴄʟᴏᴜᴅ\nʟɪɴᴋ", link, "header" ) @@ -578,7 +578,7 @@ async def onUploadComplete( if mime_type == "Folder": share_url += "/" buttons.ubutton( - "🔗 Rclone Link", + "ʀᴄʟᴏɴᴇ\nʟɪɴᴋ", share_url ) elif not rclonePath: @@ -594,12 +594,12 @@ async def onUploadComplete( share_url = f"{INDEX_URL}findpath?id={dir_id}" if mime_type == "Folder": buttons.ubutton( - "📁 Direct Link", + "ᴅɪʀᴇᴄᴛ\nꜰɪʟᴇ ʟɪɴᴋ", share_url ) else: buttons.ubutton( - "🔗 Direct Link", + "ᴅɪʀᴇᴄᴛ\nꜰᴏʟᴅᴇʀ ʟɪɴᴋ", share_url ) if mime_type.startswith( @@ -611,7 +611,7 @@ async def onUploadComplete( ): share_urls = f"{INDEX_URL}findpath?id={dir_id}&view=true" buttons.ubutton( - "🌐 View Link", + "ᴠɪᴇᴡ\nʟɪɴᴋ", share_urls ) buttons = extra_btns(buttons) @@ -637,7 +637,7 @@ async def onUploadComplete( and config_dict["DISABLE_DRIVE_LINK"] ): buttons.ubutton( - "♻️ Drive Link", + "ᴅʀɪᴠᴇ\nʟɪɴᴋ", link, "header" ) diff --git a/bot/helper/listeners/ytdlp_listener.py b/bot/helper/listeners/ytdlp_listener.py new file mode 100644 index 000000000000..43efd255ec84 --- /dev/null +++ b/bot/helper/listeners/ytdlp_listener.py @@ -0,0 +1,450 @@ +from time import time +from functools import partial +from asyncio import ( + Event, + wait_for, + wrap_future +) + +from bot.helper.ext_utils.bot_utils import ( + new_task, + new_thread +) +from bot.helper.ext_utils.status_utils import ( + get_readable_file_size, + get_readable_time +) +from bot.helper.telegram_helper.button_build import ButtonMaker +from bot.helper.telegram_helper.message_utils import ( + auto_delete_message, + delete_links, + deleteMessage, + editMessage, + sendMessage +) + +from pyrogram.handlers import CallbackQueryHandler +from pyrogram.filters import ( + regex, + user +) + +from httpx import AsyncClient +from yt_dlp import YoutubeDL + + +@new_task +async def select_format(_, query, obj): + data = query.data.split() + message = query.message + await query.answer() + + if data[1] == "dict": + b_name = data[2] + await obj.qual_subbuttons(b_name) + elif data[1] == "mp3": + await obj.mp3_subbuttons() + elif data[1] == "audio": + await obj.audio_format() + elif data[1] == "aq": + if data[2] == "back": + await obj.audio_format() + else: + await obj.audio_quality(data[2]) + elif data[1] == "back": + await obj.back_to_main() + elif data[1] == "cancel": + cmsg = await editMessage( + message, + "Yt-Dlp task has been cancelled." + ) + obj.qual = None + obj.listener.isCancelled = True + obj.event.set() + else: + if data[1] == "sub": + obj.qual = obj.formats[data[2]][data[3]][1] + elif "|" in data[1]: + obj.qual = obj.formats[data[1]] + else: + obj.qual = data[1] + obj.event.set() + if obj.listener.isCancelled: + await auto_delete_message( + message, + cmsg + ) + +class YtSelection: + def __init__( + self, + listener + ): + self.listener = listener + self._is_m4a = False + self._reply_to = None + self._time = time() + self._timeout = 120 + self._is_playlist = False + self._main_buttons = None + self.event = Event() + self.formats = {} + self.qual = None + self.tag = listener.tag + + @new_thread + async def _event_handler(self): + pfunc = partial( + select_format, + obj=self + ) + handler = self.listener.client.add_handler( + CallbackQueryHandler( + pfunc, + filters=regex("^ytq") + & + user(self.listener.userId) + ), + group=-1, + ) + try: + await wait_for( + self.event.wait(), + timeout=self._timeout + ) + except: + await editMessage( + self._reply_to, + "Timed Out. Task has been cancelled!" + ) + self.qual = None + self.listener.isCancelled = True + await auto_delete_message( + self.listener.message, + self._reply_to + ) + self.event.set() + finally: + self.listener.client.remove_handler(*handler) + if self.listener.isCancelled: + await delete_links(self.listener.message) + + async def get_quality(self, result): + future = self._event_handler() + buttons = ButtonMaker() + if "entries" in result: + self._is_playlist = True + for i in [ + "144", + "240", + "360", + "480", + "720", + "1080", + "1440", + "2160" + ]: + video_format = f"bv*[height<=?{i}][ext=mp4]+ba[ext=m4a]/b[height<=?{i}]" + b_data = f"{i}|mp4" + self.formats[b_data] = video_format + buttons.ibutton( + f"{i}-ᴍᴘ4", + f"ytq {b_data}" + ) + video_format = f"bv*[height<=?{i}][ext=webm]+ba/b[height<=?{i}]" + b_data = f"{i}|webm" + self.formats[b_data] = video_format + buttons.ibutton( + f"{i}-ᴡᴇʙᴍ", + f"ytq {b_data}" + ) + buttons.ibutton( + "ᴍᴘ3", + "ytq mp3" + ) + buttons.ibutton( + "ᴀᴜᴅɪᴏ\nꜰᴏʀᴍᴀᴛꜱ", + "ytq audio" + ) + buttons.ibutton( + "ʙᴇꜱᴛ\nᴠɪᴅᴇᴏꜱ", + "ytq bv*+ba/b" + ) + buttons.ibutton( + "ʙᴇꜱᴛ\nᴀᴜᴅɪᴏꜱ", + "ytq ba/b" + ) + buttons.ibutton( + "ᴄᴀɴᴄᴇʟ", + "ytq cancel", + "footer" + ) + self._main_buttons = buttons.build_menu(3) + msg = f"Choose Playlist Videos Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + else: + format_dict = result.get("formats") + if format_dict is not None: + for item in format_dict: + if item.get("tbr"): + format_id = item["format_id"] + + if item.get("filesize"): + size = item["filesize"] + elif item.get("filesize_approx"): + size = item["filesize_approx"] + else: + size = 0 + + if ( + item.get("video_ext") == "none" + and ( + item.get("resolution") == "audio only" + or item.get("acodec") != "none" + ) + ): + if item.get("audio_ext") == "m4a": + self._is_m4a = True + b_name = ( + f"{item.get('acodec') or format_id}-{item['ext']}" + ) + v_format = format_id + elif item.get("height"): + height = item["height"] + ext = item["ext"] + fps = ( + item["fps"] + if item.get("fps") + else "" + ) + b_name = f"{height}p{fps}-{ext}" + ba_ext = ( + "[ext=m4a]" + if self._is_m4a + and ext == "mp4" + else "" + ) + v_format = f"{format_id}+ba{ba_ext}/b[height=?{height}]" + else: + continue + + self.formats.setdefault(b_name, {})[ + f"{item['tbr']}" + ] = [ + size, + v_format, + ] + + for ( + b_name, + tbr_dict + ) in self.formats.items(): + if len(tbr_dict) == 1: + tbr, v_list = next(iter(tbr_dict.items())) + buttonName = f"{b_name} ({get_readable_file_size(v_list[0])})" + buttons.ibutton( + buttonName, + f"ytq sub {b_name} {tbr}" + ) + else: + buttons.ibutton( + b_name, + f"ytq dict {b_name}" + ) + buttons.ibutton( + "ᴍᴘ3", + "ytq mp3" + ) + buttons.ibutton( + "ᴀᴜᴅɪᴏ\nꜰᴏʀᴍᴀᴛꜱ", + "ytq audio" + ) + buttons.ibutton( + "ʙᴇꜱᴛ\nᴠɪᴅᴇᴏ", + "ytq bv*+ba/b" + ) + buttons.ibutton( + "ʙᴇꜱᴛ\nᴀᴜᴅɪᴏ", + "ytq ba/b" + ) + buttons.ibutton( + "ᴄᴀɴᴄᴇʟ", + "ytq cancel", + "footer" + ) + self._main_buttons = buttons.build_menu(2) + msg = f"Choose Video Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + self._reply_to = await sendMessage( + self.listener.message, + msg, + self._main_buttons + ) + await wrap_future(future) # type: ignore + if not self.listener.isCancelled: + await deleteMessage(self._reply_to) + return self.qual + + async def back_to_main(self): + if self._is_playlist: + msg = f"Choose Playlist Videos Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + else: + msg = f"Choose Video Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + await editMessage( + self._reply_to, + msg, + self._main_buttons + ) + + async def qual_subbuttons(self, b_name): + buttons = ButtonMaker() + tbr_dict = self.formats[b_name] + for tbr, d_data in tbr_dict.items(): + button_name = f"{tbr}K ({get_readable_file_size(d_data[0])})" + buttons.ibutton( + button_name, + f"ytq sub {b_name} {tbr}" + ) + buttons.ibutton( + "ʙᴀᴄᴋ", + "ytq back", + "footer" + ) + buttons.ibutton( + "ᴄᴀɴᴄᴇʟ", + "ytq cancel", + "footer" + ) + subbuttons = buttons.build_menu(2) + msg = ( + f"Choose Bit rate for {b_name}:\n" + f"Timeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + ) + await editMessage( + self._reply_to, + msg, + subbuttons + ) + + async def mp3_subbuttons(self): + i = "s" if self._is_playlist else "" + buttons = ButtonMaker() + audio_qualities = [ + 64, + 128, + 320 + ] + for q in audio_qualities: + audio_format = f"ba/b-mp3-{q}" + buttons.ibutton( + f"{q}ᴋ-ᴍᴘ3", + f"ytq {audio_format}" + ) + buttons.ibutton( + "ʙᴀᴄᴋ", + "ytq back" + ) + buttons.ibutton( + "ᴄᴀɴᴄᴇʟ", + "ytq cancel" + ) + subbuttons = buttons.build_menu(3) + msg = f"Choose mp3 Audio{i} Bitrate:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + await editMessage( + self._reply_to, + msg, + subbuttons + ) + + async def audio_format(self): + i = "s" if self._is_playlist else "" + buttons = ButtonMaker() + for frmt in [ + "ᴀᴀᴄ", + "ᴀʟᴀᴄ", + "ꜰʟᴀᴄ", + "ᴍ4ᴀ", + "ᴏᴘᴜꜱ", + "ᴠᴏʀʙɪꜱ", + "ᴡᴀᴠ" + ]: + audio_format = f"ba/b-{frmt}-" + buttons.ibutton( + frmt, + f"ytq aq {audio_format}" + ) + buttons.ibutton( + "ʙᴀᴄᴋ", + "ytq back", + "footer" + ) + buttons.ibutton( + "ᴄᴀɴᴄᴇʟ", + "ytq cancel", + "footer" + ) + subbuttons = buttons.build_menu(3) + msg = f"Choose Audio{i} Format:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + await editMessage( + self._reply_to, + msg, + subbuttons + ) + + async def audio_quality(self, format): + i = ( + "s" + if self._is_playlist + else "" + ) + buttons = ButtonMaker() + for qual in range(11): + audio_format = f"{format}{qual}" + buttons.ibutton( + qual, + f"ytq {audio_format}" + ) + buttons.ibutton( + "ʙᴀᴄᴋ", + "ytq aq back" + ) + buttons.ibutton( + "ᴄᴀɴᴄᴇʟ", + "ytq aq cancel" + ) + subbuttons = buttons.build_menu(5) + msg = ( + f"Choose Audio{i} Qaulity:\n0 is best and 10 is worst\n" + f"Timeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" + ) + await editMessage( + self._reply_to, + msg, + subbuttons + ) + + +def extract_info(link, options): + with YoutubeDL(options) as ydl: + result = ydl.extract_info( + link, + download=False + ) + if result is None: + raise ValueError("Info result is None") + return result + + +async def mdisk(link, name): + key = link.split("/")[-1] + async with AsyncClient(verify=False) as client: + resp = await client.get( + f"https://diskuploader.entertainvideo.com/v1/file/cdnurl?param={key}" + ) + if resp.status_code == 200: + resp_json = resp.json() + link = resp_json["source"] + if not name: + name = resp_json["filename"] + return ( + name, + link + ) diff --git a/bot/modules/authorize.py b/bot/modules/authorize.py index d5e90f4e153e..00debc574b2b 100644 --- a/bot/modules/authorize.py +++ b/bot/modules/authorize.py @@ -137,7 +137,10 @@ async def removeSudo(client, message): msg = "Demoted" else: msg = "Give ID or Reply To message of whom you want to remove from Sudo" - await sendMessage(message, msg) + await sendMessage( + message, + msg + ) bot.add_handler( # type: ignore diff --git a/bot/modules/bot_settings.py b/bot/modules/bot_settings.py index 184e114a7b81..1e6da88f0e25 100644 --- a/bot/modules/bot_settings.py +++ b/bot/modules/bot_settings.py @@ -100,39 +100,40 @@ async def get_buttons(key=None, edit_type=None): buttons = ButtonMaker() if key is None: buttons.ibutton( - "Config Variables", + "ᴄᴏɴꜰɪɢ\nᴠᴀʀɪᴀʙʟᴇꜱ", "botset var" ) buttons.ibutton( - "Private Files", + "ᴘʀɪᴠᴀᴛᴇ\nꜰɪʟᴇꜱ", "botset private" ) buttons.ibutton( - "Qbit Settings", + "Qʙɪᴛᴛᴏʀʀᴇɴᴛ\nꜱᴇᴛᴛɪɴɢꜱ", "botset qbit" ) buttons.ibutton( - "Aria2c Settings", + "ᴀʀɪᴀ2ᴄ\nꜱᴇᴛᴛɪɴɢꜱ", "botset aria" ) buttons.ibutton( - "Sabnzbd Settings", + "ꜱᴀʙɴᴢʙᴅ\nꜱᴇᴛᴛɪɴɢꜱ", "botset nzb" ) buttons.ibutton( - "JDownloader Sync", + "ᴊᴅᴏᴡɴʟᴏᴀᴅᴇʀ\nꜱʏɴᴄ", "botset syncjd" ) buttons.ibutton( - "Close", - "botset close" + "ᴄʟᴏꜱᴇ", + "botset close", + position="footer" ) - msg = "Bot Settings:" + msg = "Bot Settings\n\nPress any button to view or edit settings." elif edit_type is not None: if edit_type == "botvar": msg = "" buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset var" ) if key not in [ @@ -142,11 +143,11 @@ async def get_buttons(key=None, edit_type=None): "BOT_TOKEN" ]: buttons.ibutton( - "Default", + "ᴅᴇꜰᴀᴜʟᴛ", f"botset resetvar {key}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) if key in [ @@ -165,20 +166,20 @@ async def get_buttons(key=None, edit_type=None): msg += f"Send a valid value for {key}. Current value is '{config_dict[key]}'. Timeout: 60 sec" elif edit_type == "ariavar": buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset aria" ) if key != "newkey": buttons.ibutton( - "Default", + "ᴅᴇꜰᴀᴜʟᴛ", f"botset resetaria {key}" ) buttons.ibutton( - "Empty String", + "ᴇᴍᴘᴛʏ\nꜱᴛʀɪɴɢ", f"botset emptyaria {key}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) msg = ( @@ -188,33 +189,33 @@ async def get_buttons(key=None, edit_type=None): ) elif edit_type == "qbitvar": buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset qbit" ) buttons.ibutton( - "Empty String", + "ᴇᴍᴘᴛʏ\nꜱᴛʀɪɴɢ", f"botset emptyqbit {key}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) msg = f"Send a valid value for {key}. Current value is '{qbit_options[key]}'. Timeout: 60 sec" elif edit_type == "nzbvar": buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset nzb" ) buttons.ibutton( - "Default", + "ᴅᴇꜰᴀᴜʟᴛ", f"botset resetnzb {key}" ) buttons.ibutton( - "Empty String", + "ᴇᴍᴘᴛʏ\nꜱᴛʀɪɴɢ", f"botset emptynzb {key}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) msg = f"Send a valid value for {key}. Current value is '{nzb_options[key]}'.\nIf the value is list then seperate them by space or ,\nExample: .exe,info or .exe .info\nTimeout: 60 sec" @@ -230,16 +231,16 @@ async def get_buttons(key=None, edit_type=None): ) ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", f"botset nzbser{index}" ) if key != "newser": buttons.ibutton( - "Empty", + "ᴇᴍᴘᴛʏ", f"botset emptyserkey {index} {key}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) if key == "newser": @@ -254,20 +255,20 @@ async def get_buttons(key=None, edit_type=None): ) if STATE == "view": buttons.ibutton( - "Edit", + "ᴇᴅɪᴛ", "botset edit var" ) else: buttons.ibutton( - "View", + "ᴠɪᴇᴡ", "botset view var" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset back" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) for x in range( @@ -283,15 +284,16 @@ async def get_buttons(key=None, edit_type=None): msg = f"Config Variables | Page: {int(START / 10)} | State: {STATE}" elif key == "private": buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset back" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) msg = """ -Send private file: config.env, token.pickle, rclone.conf, accounts.zip, list_drives.txt, cookies.txt, terabox.txt, .netrc or any other private file! +Send private file: config.env, token.pickle, rclone.conf, accounts.zip, +list_drives.txt, cookies.txt, terabox.txt, .netrc or any other private file! To delete private file send only the file name as text message. Note: Changing .netrc will not take effect for aria2c until restart. @@ -306,24 +308,24 @@ async def get_buttons(key=None, edit_type=None): ) if STATE == "view": buttons.ibutton( - "Edit", + "ᴇᴅɪᴛ", "botset edit aria" ) else: buttons.ibutton( - "View", + "ᴠɪᴇᴡ", "botset view aria" ) buttons.ibutton( - "Add new key", + "ᴀᴅᴅ ɴᴇᴡ ᴋᴇʏ", "botset ariavar newkey" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset back" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) for x in range( @@ -345,24 +347,24 @@ async def get_buttons(key=None, edit_type=None): ) if STATE == "view": buttons.ibutton( - "Edit", + "ᴇᴅɪᴛ", "botset edit qbit" ) else: buttons.ibutton( - "View", + "ᴠɪᴇᴡ", "botset view qbit" ) buttons.ibutton( - "Sync Qbittorrent", + "Qʙɪᴛᴛᴏʀʀᴇɴᴛ\nꜱʏɴᴄ", "botset syncqbit" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset back" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) for x in range( @@ -384,28 +386,28 @@ async def get_buttons(key=None, edit_type=None): ) if STATE == "view": buttons.ibutton( - "Edit", + "ᴇᴅɪᴛ", "botset edit nzb" ) else: buttons.ibutton( - "View", + "ᴠɪᴇᴡ", "botset view nzb" ) buttons.ibutton( - "Servers", + "ꜱᴇʀᴠᴇʀꜱ", "botset nzbserver" ) buttons.ibutton( - "Sync Sabnzbd", + "ꜱᴀʙɴᴢʙᴅ\nꜱʏɴᴄ", "botset syncnzb" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset back" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) for x in range( @@ -432,15 +434,15 @@ async def get_buttons(key=None, edit_type=None): f"botset nzbser{index}" ) buttons.ibutton( - "Add New", + "ᴀᴅᴅ\nɴᴇᴡ", "botset nzbsevar newser" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset nzb" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) if len(config_dict["USENET_SERVERS"]) > 10: @@ -467,24 +469,24 @@ async def get_buttons(key=None, edit_type=None): ) if STATE == "view": buttons.ibutton( - "Edit", + "ᴇᴅɪᴛ", f"botset edit {key}" ) else: buttons.ibutton( - "View", + "ᴠɪᴇᴡ", f"botset view {key}" ) buttons.ibutton( - "Remove Server", + "ʀᴇᴍᴏᴠᴇ\nꜱᴇʀᴠᴇʀ", f"botset remser {index}" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "botset nzbserver" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "botset close" ) if len(config_dict["USENET_SERVERS"][index].keys()) > 10: @@ -500,10 +502,7 @@ async def get_buttons(key=None, edit_type=None): ) msg = f"Server Keys | Page: {int(START / 10)} | State: {STATE}" - button = ( - buttons.build_menu(1) - if key is None - else buttons.build_menu(2)) + button = buttons.build_menu(2) return ( msg, button @@ -552,7 +551,10 @@ async def edit_variable(client, message, pre_message, key): len(task_dict) != 0 and (st := Intervals["status"]) ): - for cid, intvl in list(st.items()): + for ( + cid, + intvl + ) in list(st.items()): intvl.cancel() Intervals["status"][cid] = setInterval( value, @@ -1068,11 +1070,11 @@ async def update_private_file(_, message, pre_message): buttons = ButtonMaker() msg = "Push to UPSTREAM_REPO ?" buttons.ibutton( - "Yes!", + "ʏᴇꜱ!", f"botset push {file_name}" ) buttons.ibutton( - "No", + "ɴᴏ", "botset close" ) await sendMessage( @@ -1780,7 +1782,10 @@ async def edit_bot_settings(client, query): async def bot_settings(_, message): handler_dict[message.chat.id] = False - msg, button = await get_buttons() + ( + msg, + button + ) = await get_buttons() globals()["START"] = 0 await sendMessage( message, diff --git a/bot/modules/cancel_task.py b/bot/modules/cancel_task.py index d2487030561a..c7fded52fda5 100644 --- a/bot/modules/cancel_task.py +++ b/bot/modules/cancel_task.py @@ -159,27 +159,27 @@ async def cancel_all(status, userId): def create_cancel_buttons(isSudo, userId=""): buttons = button_build.ButtonMaker() buttons.ibutton( - "Downloading", + "ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ", f"canall ms {(MirrorStatus.STATUS_DOWNLOADING).split(' ')[0]} {userId}" ) buttons.ibutton( - "Uploading", + "ᴜᴘʟᴏᴀᴅɪɴɢ", f"canall ms {(MirrorStatus.STATUS_UPLOADING).split(' ')[0]} {userId}" ) buttons.ibutton( - "Seeding", + "ꜱᴇᴇᴅɪɴɢ", f"canall ms {(MirrorStatus.STATUS_SEEDING).split(' ')[0]} {userId}" ) buttons.ibutton( - "Spltting", + "ꜱᴘʟᴛᴛɪɴɢ", f"canall ms {(MirrorStatus.STATUS_SPLITTING).split(' ')[0]} {userId}" ) buttons.ibutton( - "Cloning", + "ᴄʟᴏɴɪɴɢ", f"canall ms {(MirrorStatus.STATUS_CLONING).split(' ')[0]} {userId}" ) buttons.ibutton( - "Extracting", + "ᴇxᴛʀᴀᴄᴛɪɴɢ", f"canall ms {(MirrorStatus.STATUS_EXTRACTING).split(' ')[0]} {userId}" ) buttons.ibutton( @@ -187,42 +187,42 @@ def create_cancel_buttons(isSudo, userId=""): f"canall ms {(MirrorStatus.STATUS_ARCHIVING).split(' ')[0]} {userId}" ) buttons.ibutton( - "QueuedDl", + "Qᴜᴇᴜᴇᴅᴅʟ", f"canall ms {(MirrorStatus.STATUS_QUEUEDL).split(' ')[0]} {userId}" ) buttons.ibutton( - "QueuedUp", + "Qᴜᴇᴜᴇᴅᴜᴘ", f"canall ms {(MirrorStatus.STATUS_QUEUEUP).split(' ')[0]} {userId}" ) buttons.ibutton( - "SampleVideo", + "ꜱᴀᴍᴘʟᴇᴠɪᴅᴇᴏ", f"canall ms {(MirrorStatus.STATUS_SAMVID).split(' ')[0]} {userId}" ) buttons.ibutton( - "ConvertMedia", + "ᴄᴏɴᴠᴇʀᴛᴍᴇᴅɪᴀ", f"canall ms {(MirrorStatus.STATUS_CONVERTING).split(' ')[0]} {userId}" ) buttons.ibutton( - "Paused", + "ᴘᴀᴜꜱᴇᴅ", f"canall ms {(MirrorStatus.STATUS_PAUSED).split(' ')[0]} {userId}" ) buttons.ibutton( - "All", + "ᴀʟʟ", f"canall ms All {userId}" ) if isSudo: if userId: buttons.ibutton( - "All Added Tasks", + "ᴀʟʟ ᴀᴅᴅᴇᴅ ᴛᴀꜱᴋꜱ", f"canall bot ms {userId}" ) else: buttons.ibutton( - "My Tasks", + "ᴍʏ ᴛᴀꜱᴋꜱ", f"canall user ms {userId}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", f"canall close ms {userId}" ) return buttons.build_menu(2) @@ -327,15 +327,15 @@ async def cancel_all_update(_, query): elif data[1] == "ms": buttons = button_build.ButtonMaker() buttons.ibutton( - "Yes!", + "ʏᴇꜱ!", f"canall {data[2]} confirm {userId}" ) buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", f"canall back confirm {userId}" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", f"canall close confirm {userId}" ) button = buttons.build_menu(2) diff --git a/bot/modules/gd_search.py b/bot/modules/gd_search.py index 887f7dcad885..0d19761e9af0 100644 --- a/bot/modules/gd_search.py +++ b/bot/modules/gd_search.py @@ -35,25 +35,25 @@ async def list_buttons(user_id, isRecursive=True, user_token=False): buttons = ButtonMaker() buttons.ibutton( - "Folders", + "ꜰᴏʟᴅᴇʀꜱ", f"list_types {user_id} folders {isRecursive} {user_token}" ) buttons.ibutton( - "Files", + "ꜰɪʟᴇꜱ", f"list_types {user_id} files {isRecursive} {user_token}") buttons.ibutton( - "Both", + "ʙᴏᴛʜ", f"list_types {user_id} both {isRecursive} {user_token}") buttons.ibutton( - f"Recursive: {isRecursive}", + f"ʀᴇᴄᴜʀꜱɪᴠᴇ: {isRecursive}", f"list_types {user_id} rec {isRecursive} {user_token}", ) buttons.ibutton( - f"User Token: {user_token}", + f"ᴜꜱᴇʀ\nᴛᴏᴋᴇɴ: {user_token}", f"list_types {user_id} ut {isRecursive} {user_token}", ) buttons.ibutton( - "Cancel", + "ᴄᴀɴᴄᴇʟ", f"list_types {user_id} cancel") return buttons.build_menu(2) diff --git a/bot/modules/help.py b/bot/modules/help.py index 218c665ca172..e86f48405b2b 100644 --- a/bot/modules/help.py +++ b/bot/modules/help.py @@ -1,7 +1,7 @@ from pyrogram.filters import regex from pyrogram.handlers import CallbackQueryHandler -from bot import bot +from bot import bot, LOGGER from bot.helper.ext_utils.bot_utils import COMMAND_USAGE from bot.helper.ext_utils.help_messages import ( YT_HELP_DICT, @@ -44,37 +44,37 @@ async def argUsage(_, query): elif data[1] == "mirror": buttons = ButtonMaker() buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "help back m" ) button = buttons.build_menu() await editMessage( message, - MIRROR_HELP_DICT[data[2]], + MIRROR_HELP_DICT[data[2] + "\n" + data[3]], button ) elif data[1] == "yt": buttons = ButtonMaker() buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "help back y" ) button = buttons.build_menu() await editMessage( message, - YT_HELP_DICT[data[2]], + YT_HELP_DICT[data[2] + "\n" + data[3]], button ) elif data[1] == "clone": buttons = ButtonMaker() buttons.ibutton( - "Back", + "ʙᴀᴄᴋ", "help back c" ) button = buttons.build_menu() await editMessage( message, - CLONE_HELP_DICT[data[2]], + CLONE_HELP_DICT[data[2] + "\n" + data[3]], button ) diff --git a/bot/modules/status.py b/bot/modules/status.py index b739098198fe..2a4aa98c049c 100644 --- a/bot/modules/status.py +++ b/bot/modules/status.py @@ -69,8 +69,8 @@ async def mirror_status(_, message): if count == 0: currentTime = get_readable_time(time() - botStartTime) # type: ignore free = get_readable_file_size(disk_usage(DOWNLOAD_DIR).free) - msg = "Stop it! Get some help!\n\nNo Active Tasks!\n\n" - msg += f"Each user can get status for his tasks by adding me or user_id after cmd: /{BotCommands.StatusCommand[0]} me\n\n" + msg = "Stop it!\nGet some help!\n\nNo Active Tasks!\n\n" + msg += f"Get your tasks status by adding me or user_id after cmd: /{BotCommands.StatusCommand[0]} me\n\n" msg += ( f"\nCPU: {cpu_percent()}% | FREE: {free}" f"\nRAM: {virtual_memory().percent}% | UPTIME: {currentTime}" @@ -314,19 +314,19 @@ async def stats(_, message, edit_mode=False): f"Total: {total} | Free: {free}" buttons.ibutton( - "Sys Stats", + "ꜱʏꜱᴛᴇᴍ\nꜱᴛᴀᴛꜱ", "show_sys_stats" ) buttons.ibutton( - "Repo Stats", + "ʀᴇᴘᴏ\nꜱᴛᴀᴛꜱ", "show_repo_stats" ) buttons.ibutton( - "Bot Limits", + "ʙᴏᴛ\nʟɪᴍɪᴛꜱ", "show_bot_limits" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "close_signal" ) sbtns = buttons.build_menu(2) @@ -349,19 +349,19 @@ async def send_bot_stats(_, query): edit_mode=True ) buttons.ibutton( - "Sys Stats", + "ꜱʏꜱᴛᴇᴍ\nꜱᴛᴀᴛꜱ", "show_sys_stats" ) buttons.ibutton( - "Repo Stats", + "ʀᴇᴘᴏ\nꜱᴛᴀᴛꜱ", "show_repo_stats" ) buttons.ibutton( - "Bot Limits", + "ʙᴏᴛ\nʟɪᴍɪᴛꜱ", "show_bot_limits" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "close_signal" ) sbtns = buttons.build_menu(2) @@ -383,19 +383,19 @@ async def send_sys_stats(_, query): edit_mode=True ) buttons.ibutton( - "Bot Stats", + "ʙᴏᴛ\nꜱᴛᴀᴛꜱ", "show_bot_stats" ) buttons.ibutton( - "Repo Stats", + "ʀᴇᴘᴏ\nꜱᴛᴀᴛꜱ", "show_repo_stats" ) buttons.ibutton( - "Bot Limits", + "ʙᴏᴛ\nʟɪᴍɪᴛꜱ", "show_bot_limits" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "close_signal" ) sbtns = buttons.build_menu(2) @@ -492,19 +492,19 @@ async def send_repo_stats(_, query): f"{update_info}" buttons.ibutton( - "Bot Stats", + "ʙᴏᴛ\nꜱᴛᴀᴛꜱ", "show_bot_stats" ) buttons.ibutton( - "Sys Stats", + "ꜱʏꜱᴛᴇᴍ\nꜱᴛᴀᴛꜱ", "show_sys_stats" ) buttons.ibutton( - "Bot Limits", + "ʙᴏᴛ\nʟɪᴍɪᴛꜱ", "show_bot_limits" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "close_signal" ) sbtns = buttons.build_menu(2) @@ -547,19 +547,19 @@ async def send_bot_limits(_, query): f"Bot Tasks : {BMT}" buttons.ibutton( - "Bot Stats", + "ʙᴏᴛ\nꜱᴛᴀᴛꜱ", "show_bot_stats" ) buttons.ibutton( - "Sys Stats", + "ꜱʏꜱᴛᴇᴍ\nꜱᴛᴀᴛꜱ", "show_sys_stats" ) buttons.ibutton( - "Repo Stats", + "ʀᴇᴘᴏ\nꜱᴛᴀᴛꜱ", "show_repo_stats" ) buttons.ibutton( - "Close", + "ᴄʟᴏꜱᴇ", "close_signal" ) sbtns = buttons.build_menu(2) diff --git a/bot/modules/torrent_search.py b/bot/modules/torrent_search.py index 286ee64985be..971bdeb1a144 100644 --- a/bot/modules/torrent_search.py +++ b/bot/modules/torrent_search.py @@ -199,7 +199,7 @@ async def _search(key, site, message, method): ) buttons = ButtonMaker() buttons.ubutton( - "🔎 VIEW", + "🔎 ᴠɪᴇᴡ\nʀᴇꜱᴜʟᴛꜱ", link ) button = buttons.build_menu(1) @@ -308,13 +308,16 @@ async def _getResult(search_results, key, message, method): def _api_buttons(user_id, method): buttons = ButtonMaker() - for data, name in SITES.items(): # type: ignore + for ( + data, + name + ) in SITES.items(): # type: ignore buttons.ibutton( name, f"torser {user_id} {data} {method}" ) buttons.ibutton( - "Cancel", + "ᴄᴀɴᴄᴇʟ", f"torser {user_id} cancel" ) return buttons.build_menu(2) @@ -332,11 +335,11 @@ async def _plugin_buttons(user_id): f"torser {user_id} {siteName} plugin" ) buttons.ibutton( - "All", + "ᴀʟʟ\nꜱɪᴛᴇꜱ", f"torser {user_id} all plugin" ) buttons.ibutton( - "Cancel", + "ᴄᴀɴᴄᴇʟ", f"torser {user_id} cancel" ) return buttons.build_menu(2) @@ -362,15 +365,15 @@ async def torrentSearch(_, message): ) elif len(key) == 1: buttons.ibutton( - "Trending", + "ᴛʀᴇɴᴅɪɴɢ", f"torser {user_id} apitrend" ) buttons.ibutton( - "Recent", + "ʀᴇᴄᴇɴᴛ", f"torser {user_id} apirecent" ) buttons.ibutton( - "Cancel", + "ᴄᴀɴᴄᴇʟ", f"torser {user_id} cancel" ) button = buttons.build_menu(2) @@ -384,15 +387,15 @@ async def torrentSearch(_, message): and SEARCH_PLUGINS ): buttons.ibutton( - "Api", + "ᴀᴘɪ", f"torser {user_id} apisearch" ) buttons.ibutton( - "Plugins", + "ᴘʟᴜɢɪɴꜱ", f"torser {user_id} plugin" ) buttons.ibutton( - "Cancel", + "ᴄᴀɴᴄᴇʟ", f"torser {user_id} cancel" ) button = buttons.build_menu(2) diff --git a/bot/modules/users_settings.py b/bot/modules/users_settings.py index 7c196a30b9ae..9fbc023780df 100644 --- a/bot/modules/users_settings.py +++ b/bot/modules/users_settings.py @@ -194,12 +194,12 @@ async def get_user_settings(from_user): mixed_leech = "Disabled" buttons.ibutton( - "Leech Settings", + "ʟᴇᴇᴄʜ\nꜱᴇᴛᴛɪɴɢꜱ", f"userset {user_id} leech" ) buttons.ibutton( - "Rclone Tools", + "ʀᴄʟᴏɴᴇ\nᴛᴏᴏʟꜱ", f"userset {user_id} rclone" ) rccmsg = ( @@ -218,7 +218,7 @@ async def get_user_settings(from_user): rccpath = "Not Added" buttons.ibutton( - "Gdrive Tools", + "ɢᴅʀɪᴠᴇ\nᴛᴏᴏʟꜱ", f"userset {user_id} gdrive" ) tokenmsg = ( @@ -263,7 +263,7 @@ async def get_user_settings(from_user): else "Not Added" ) buttons.ibutton( - "Upload Paths", + "ᴜᴘʟᴏᴀᴅ\nᴘᴀᴛʜꜱ", f"userset {user_id} upload_paths" ) @@ -285,12 +285,12 @@ async def get_user_settings(from_user): else "Rclone" ) buttons.ibutton( - f"Upload using {dub}", + f"ᴜᴘʟᴏᴀᴅ\nᴜꜱɪɴɢ {dub}", f"userset {user_id} {default_upload}" ) buttons.ibutton( - "Extension Filter", + "ᴇxᴛᴇɴꜱɪᴏɴ\nꜰɪʟᴛᴇʀ", f"userset {user_id} ex_ex" ) ex_ex = ( @@ -311,12 +311,12 @@ async def get_user_settings(from_user): else "Not Added" ) buttons.ibutton( - "Name Substitute", + "ɴᴀᴍᴇ\nꜱᴜʙꜱᴛɪᴛᴜᴛᴇ", f"userset {user_id} name_substitute" ) buttons.ibutton( - "YT-DLP Options", + "ʏᴛ-ᴅʟᴘ\nᴏᴘᴛɪᴏɴꜱ", f"userset {user_id} yto" ) if user_dict.get( @@ -334,13 +334,14 @@ async def get_user_settings(from_user): if user_dict: buttons.ibutton( - "Reset All", + "ʀᴇꜱᴇᴛ ᴀʟʟ\nᴄʜᴀɴɢᴇꜱ", f"userset {user_id} reset" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) text = f""" @@ -378,7 +379,7 @@ async def get_user_settings(from_user): return ( text, - buttons.build_menu(1) + buttons.build_menu(2) ) @@ -724,7 +725,7 @@ async def edit_user_settings(client, query): thumbpath = f"Thumbnails/{user_id}.jpg" buttons = ButtonMaker() buttons.ibutton( - "Thumbnail", + "ᴛʜᴜᴍʙ", f"userset {user_id} sthumb" ) thumbmsg = ( @@ -733,7 +734,7 @@ async def edit_user_settings(client, query): else "Not Exists" ) buttons.ibutton( - "Leech Split Size", + "ꜱᴘʟɪᴛ\nꜱɪᴢᴇ", f"userset {user_id} lss" ) if user_dict.get( @@ -745,7 +746,7 @@ async def edit_user_settings(client, query): split_size = config_dict["LEECH_SPLIT_SIZE"] split_size = get_readable_file_size(split_size) buttons.ibutton( - "Leech Destination", + "ʟᴇᴇᴄʜ\nᴅᴇꜱᴛ", f"userset {user_id} ldest" ) if user_dict.get( @@ -761,7 +762,7 @@ async def edit_user_settings(client, query): else: leech_dest = "None" buttons.ibutton( - "Leech Prefix", + "ᴘʀᴇꜰɪx", f"userset {user_id} leech_prefix" ) if user_dict.get( @@ -776,7 +777,7 @@ async def edit_user_settings(client, query): else: lprefix = "None" buttons.ibutton( - "Leech Suffix", + "ꜱᴜꜰꜰɪx", f"userset {user_id} leech_suffix" ) if user_dict.get( @@ -791,7 +792,7 @@ async def edit_user_settings(client, query): else: lsuffix = "None" buttons.ibutton( - "Leech Caption Font", + "ᴄᴀᴘ\nꜰᴏɴᴛ", f"userset {user_id} leech_cap_font" ) if user_dict.get( @@ -815,13 +816,13 @@ async def edit_user_settings(client, query): ): ltype = "DOCUMENT" buttons.ibutton( - "Send As Media", + "ᴜᴘʟᴏᴀᴅ\nᴀꜱ ᴍᴇᴅɪᴀ", f"userset {user_id} as_doc false" ) else: ltype = "MEDIA" buttons.ibutton( - "Send As Document", + "ᴜᴘʟᴏᴀᴅ\nᴀꜱ ᴅᴏᴄᴜᴍᴇɴᴛ", f"userset {user_id} as_doc true" ) if ( @@ -833,13 +834,13 @@ async def edit_user_settings(client, query): and config_dict["EQUAL_SPLITS"] ): buttons.ibutton( - "Disable Equal Splits", + "ᴅɪꜱᴀʙʟᴇ\nᴇQᴜᴀʟ ꜱᴘʟɪᴛꜱ", f"userset {user_id} equal_splits false" ) equal_splits = "Enabled" else: buttons.ibutton( - "Enable Equal Splits", + "ᴇɴᴀʙʟᴇ\nᴇQᴜᴀʟ ꜱᴘʟɪᴛꜱ", f"userset {user_id} equal_splits true" ) equal_splits = "Disabled" @@ -852,13 +853,13 @@ async def edit_user_settings(client, query): and config_dict["MEDIA_GROUP"] ): buttons.ibutton( - "Disable Media Group", + "ᴅɪꜱᴀʙʟᴇ\nᴍᴇᴅɪᴀ ɢʀᴏᴜᴘ", f"userset {user_id} media_group false" ) media_group = "Enabled" else: buttons.ibutton( - "Enable Media Group", + "ᴇɴᴀʙʟᴇ\nᴍᴇᴅɪᴀ ɢʀᴏᴜᴘ", f"userset {user_id} media_group true" ) media_group = "Disabled" @@ -872,14 +873,14 @@ async def edit_user_settings(client, query): and config_dict["USER_TRANSMISSION"] ): buttons.ibutton( - "Upload with Bot", + "ᴜᴘʟᴏᴀᴅ\nᴡɪᴛʜ ʙᴏᴛ", f"userset {user_id} user_transmission false" ) leech_method = "user" elif IS_PREMIUM_USER: leech_method = "bot" buttons.ibutton( - "Upload with User", + "ᴜᴘʟᴏᴀᴅ\nᴡɪᴛʜ ᴜꜱᴇʀ", f"userset {user_id} user_transmission true" ) else: @@ -896,25 +897,27 @@ async def edit_user_settings(client, query): ): mixed_leech = "Enabled" buttons.ibutton( - "Disable Hybrid Upload", + "ᴅɪꜱᴀʙʟᴇ\nʜʏʙʀɪᴅ ᴜᴘʟᴏᴀᴅ", f"userset {user_id} mixed_leech false" ) elif IS_PREMIUM_USER: mixed_leech = "Disabled" buttons.ibutton( - "Enable Hybrid Upload", + "ᴇɴᴀʙʟᴇ\nʜʏʙʀɪᴅ ᴜᴘʟᴏᴀᴅ", f"userset {user_id} mixed_leech true" ) else: mixed_leech = "Disabled" buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) text = f""" Leech Settings for {name} @@ -935,26 +938,28 @@ async def edit_user_settings(client, query): await editMessage( message, text, - buttons.build_menu(1) + buttons.build_menu(3) ) elif data[2] == "rclone": await query.answer() buttons = ButtonMaker() buttons.ibutton( - "Rclone Config", + "ʀᴄʟᴏɴᴇ\nᴄᴏɴꜰɪɢ", f"userset {user_id} rcc" ) buttons.ibutton( - "Default Rclone Path", + "ᴅᴇꜰᴀᴜʟᴛ\nʀᴄʟᴏɴᴇ ᴘᴀᴛʜ", f"userset {user_id} rcp" ) buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) rccmsg = ( "Exists" @@ -979,21 +984,21 @@ async def edit_user_settings(client, query): await editMessage( message, text, - buttons.build_menu(1) + buttons.build_menu(2) ) elif data[2] == "gdrive": await query.answer() buttons = ButtonMaker() buttons.ibutton( - "token.pickle", + "ᴜᴘʟᴏᴀᴅ\nᴛᴏᴋᴇɴ ᴘɪᴄᴋʟᴇ", f"userset {user_id} token" ) buttons.ibutton( - "Default Gdrive ID", + "ᴅᴇꜰᴀᴜʟᴛ\nɢᴅʀɪᴠᴇ ɪᴅ", f"userset {user_id} gdid" ) buttons.ibutton( - "Index URL", + "ɪɴᴅᴇx ᴜʀʟ", f"userset {user_id} index" ) if ( @@ -1005,23 +1010,25 @@ async def edit_user_settings(client, query): and config_dict["STOP_DUPLICATE"] ): buttons.ibutton( - "Disable Stop Duplicate", + "ᴅɪꜱᴀʙʟᴇ\nꜱᴛᴏᴘ ᴅᴜᴘʟɪᴄᴀᴛᴇ", f"userset {user_id} stop_duplicate false" ) sd_msg = "Enabled" else: buttons.ibutton( - "Enable Stop Duplicate", + "ᴇɴᴀʙʟᴇ\nꜱᴛᴏᴘ ᴅᴜᴘʟɪᴄᴀᴛᴇ", f"userset {user_id} stop_duplicate true" ) sd_msg = "Disabled" buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) tokenmsg = ( "Exists" @@ -1058,28 +1065,30 @@ async def edit_user_settings(client, query): await editMessage( message, text, - buttons.build_menu(1) + buttons.build_menu(2) ) elif data[2] == "sthumb": await query.answer() buttons = ButtonMaker() if await aiopath.exists(thumb_path): buttons.ibutton( - "Delete Thumbnail", + "ᴅᴇʟᴇᴛᴇ\nᴛʜᴜᴍʙɴᴀɪʟ", f"userset {user_id} thumb" ) buttons.ibutton( - "Back", - f"userset {user_id} leech" + "ʙᴀᴄᴋ", + f"userset {user_id} leech", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, "Send a photo to save it as custom thumbnail. Timeout: 60 sec", - buttons.build_menu(1), + buttons.build_menu(2), ) pfunc = partial( set_thumb, @@ -1099,17 +1108,19 @@ async def edit_user_settings(client, query): False ) or config_dict["YT_DLP_OPTIONS"]: buttons.ibutton( - "Remove YT-DLP Options", + "ʀᴇᴍᴏᴠᴇ\nʏᴛ-ᴅʟᴘ ᴏᴘᴛɪᴏɴꜱ", f"userset {user_id} yt_opt", "header" ) buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) rmsg = """ Send YT-DLP Options. Timeout: 60 sec @@ -1124,7 +1135,7 @@ async def edit_user_settings(client, query): await editMessage( message, rmsg, - buttons.build_menu(1) + buttons.build_menu(2) ) pfunc = partial( set_option, @@ -1144,23 +1155,25 @@ async def edit_user_settings(client, query): False ): buttons.ibutton( - "Reset Split Size", + "ʀᴇꜱᴇᴛ\nꜱᴘʟɪᴛ ꜱɪᴢᴇ", f"userset {user_id} split_size" ) buttons.ibutton( - "Back", - f"userset {user_id} leech" + "ʙᴀᴄᴋ", + f"userset {user_id} leech", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) sp_msg = "Send Leech split size.\nDon't add unit(MB, GB), default unit is GB\n" sp_msg += "\nExamples:\nSend 4 for 4GB\nor 0.5 for 512MB\n\nTimeout: 60 sec" await editMessage( message, sp_msg, - buttons.build_menu(1), + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1177,19 +1190,23 @@ async def edit_user_settings(client, query): buttons = ButtonMaker() if await aiopath.exists(rclone_conf): buttons.ibutton( - "Delete rclone.conf", + "ᴅᴇʟᴇᴛᴇ\nʀᴄʟᴏɴᴇ.ᴄᴏɴꜰ", f"userset {user_id} rclone_config" ) buttons.ibutton( - "Back", - f"userset {user_id} rclone" + "ʙᴀᴄᴋ", + f"userset {user_id} rclone", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( - message, "Send rclone.conf. Timeout: 60 sec", buttons.build_menu(1) + message, + "Send rclone.conf. Timeout: 60 sec", + buttons.build_menu(2) ) pfunc = partial( add_rclone, @@ -1209,22 +1226,24 @@ async def edit_user_settings(client, query): False ): buttons.ibutton( - "Reset Rclone Path", + "ʀᴇꜱᴇᴛ\nʀᴄʟᴏɴᴇ ᴘᴀᴛʜ", f"userset {user_id} rclone_path" ) buttons.ibutton( - "Back", - f"userset {user_id} rclone" + "ʙᴀᴄᴋ", + f"userset {user_id} rclone", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) rmsg = "Send Rclone Path. Timeout: 60 sec" await editMessage( message, rmsg, - buttons.build_menu(1) + buttons.build_menu(2) ) pfunc = partial( set_option, @@ -1241,20 +1260,23 @@ async def edit_user_settings(client, query): buttons = ButtonMaker() if await aiopath.exists(token_pickle): buttons.ibutton( - "Delete token.pickle", + "ᴅᴇʟᴇᴛᴇ\nᴛᴏᴋᴇɴ.ᴘɪᴄᴋʟᴇ", f"userset {user_id} token_pickle" ) buttons.ibutton( - "Back", - f"userset {user_id} gdrive" + "ʙᴀᴄᴋ", + f"userset {user_id} gdrive", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( - message, "Send token.pickle. Timeout: 60 sec", - buttons.build_menu(1) + message, + "Send token.pickle.\n\nTimeout: 60 sec", + buttons.build_menu(2) ) pfunc = partial( add_token_pickle, @@ -1274,22 +1296,24 @@ async def edit_user_settings(client, query): False ): buttons.ibutton( - "Reset Gdrive ID", + "ʀᴇꜱᴇᴛ\nɢᴅʀɪᴠᴇ ɪᴅ", f"userset {user_id} gdrive_id" ) buttons.ibutton( - "Back", - f"userset {user_id} gdrive" + "ʙᴀᴄᴋ", + f"userset {user_id} gdrive", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) - rmsg = "Send Gdrive ID. Timeout: 60 sec" + rmsg = "Send Gdrive ID.\n\nTimeout: 60 sec" await editMessage( message, rmsg, - buttons.build_menu(1) + buttons.build_menu(2) ) pfunc = partial( set_option, @@ -1309,22 +1333,24 @@ async def edit_user_settings(client, query): False ): buttons.ibutton( - "Remove Index URL", + "ʀᴇᴍᴏᴠᴇ\nɪɴᴅᴇx ᴜʀʟ", f"userset {user_id} index_url" ) buttons.ibutton( - "Back", - f"userset {user_id} gdrive" + "ʙᴀᴄᴋ", + f"userset {user_id} gdrive", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) - rmsg = "Send Index URL. Timeout: 60 sec" + rmsg = "Send Index URL.\n\nTimeout: 60 sec" await editMessage( message, rmsg, - buttons.build_menu(1) + buttons.build_menu(2) ) pfunc = partial( set_option, @@ -1348,21 +1374,23 @@ async def edit_user_settings(client, query): and config_dict["LEECH_FILENAME_PREFIX"] ): buttons.ibutton( - "Remove Leech Prefix", + "ʀᴇᴍᴏᴠᴇ\nᴘʀᴇꜰɪx", f"userset {user_id} lprefix" ) buttons.ibutton( - "Back", - f"userset {user_id} leech" + "ʙᴀᴄᴋ", + f"userset {user_id} leech", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, - "Send Leech Filename Prefix. You can add HTML tags. Timeout: 60 sec", - buttons.build_menu(1), + "Send Leech Filename Prefix.\nYou can add HTML tags.\n\nTimeout: 60 sec", + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1386,21 +1414,23 @@ async def edit_user_settings(client, query): and config_dict["LEECH_FILENAME_SUFFIX"] ): buttons.ibutton( - "Remove Leech Suffix", + "ʀᴇᴍᴏᴠᴇ\nꜱᴜꜰꜰɪx", f"userset {user_id} lsuffix" ) buttons.ibutton( - "Back", - f"userset {user_id} leech" + "ʙᴀᴄᴋ", + f"userset {user_id} leech", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, - "Send Leech Filename Suffix. You can add HTML tags. Timeout: 60 sec", - buttons.build_menu(1), + "Send Leech Filename Suffix.\nYou can add HTML tags.\n\nTimeout: 60 sec", + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1424,16 +1454,18 @@ async def edit_user_settings(client, query): and config_dict["LEECH_CAPTION_FONT"] ): buttons.ibutton( - "Remove Leech Caption Font", + "ʀᴇᴍᴏᴠᴇ\nᴄᴀᴘᴛɪᴏɴ ꜰᴏɴᴛ", f"userset {user_id} lcapfont" ) buttons.ibutton( - "Back", - f"userset {user_id} leech" + "ʙᴀᴄᴋ", + f"userset {user_id} leech", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) msg = """ Send Leech Caption Font. Default is regular. @@ -1453,7 +1485,7 @@ async def edit_user_settings(client, query): await editMessage( message, msg, - buttons.build_menu(1), + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1477,21 +1509,23 @@ async def edit_user_settings(client, query): and config_dict["USER_LEECH_DESTINATION"] ): buttons.ibutton( - "Reset Leech Destination", + "ʀᴇꜱᴇᴛ\nʟᴇᴇᴄʜ ᴅᴇꜱᴛɪɴᴀᴛɪᴏɴ", f"userset {user_id} leech_dest" ) buttons.ibutton( - "Back", - f"userset {user_id} leech" + "ʙᴀᴄᴋ", + f"userset {user_id} leech", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, - "Send leech destination ID/USERNAME/PM. Timeout: 60 sec", - buttons.build_menu(1), + "Send leech destination\nID or USERNAME or PM.\n\nTimeout: 60 sec", + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1515,16 +1549,18 @@ async def edit_user_settings(client, query): and GLOBAL_EXTENSION_FILTER ): buttons.ibutton( - "Remove Excluded Extensions", + "ʀᴇᴍᴏᴠᴇ\nᴇxᴄʟᴜᴅᴇᴅ ᴇxᴛᴇɴꜱɪᴏɴꜱ", f"userset {user_id} excluded_extensions" ) buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) ex_msg = "Send exluded extenions seperated by space without dot at beginning.\n" ex_msg += "Ex: zip mp4 jpg\nTimeout: 60 sec\n\n" @@ -1532,7 +1568,7 @@ async def edit_user_settings(client, query): await editMessage( message, ex_msg, - buttons.build_menu(1), + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1552,16 +1588,18 @@ async def edit_user_settings(client, query): False ): buttons.ibutton( - "Remove Name Substitute", + "ʀᴇᴍᴏᴠᴇ\nɴᴀᴍᴇ ꜱᴜʙꜱᴛɪᴛᴜᴛᴇ", f"userset {user_id} name_sub" ) buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) emsg = r""" Word Substitutions. You can add pattern instead of normal text. Timeout: 60 sec @@ -1584,7 +1622,7 @@ async def edit_user_settings(client, query): await editMessage( message, emsg, - buttons.build_menu(1), + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1618,7 +1656,7 @@ async def edit_user_settings(client, query): await query.answer() buttons = ButtonMaker() buttons.ibutton( - "New Path", + "ɴᴇᴡ\nᴘᴀᴛʜ", f"userset {user_id} new_path" ) if user_dict.get( @@ -1626,41 +1664,49 @@ async def edit_user_settings(client, query): False ): buttons.ibutton( - "Show All Paths", + "ꜱʜᴏᴡ\nᴀʟʟ ᴘᴀᴛʜꜱ", f"userset {user_id} show_path" ) buttons.ibutton( - "Remove Path", + "ʀᴇᴍᴏᴠᴇ\nᴘᴀᴛʜ", f"userset {user_id} rm_path" ) buttons.ibutton( - "Back", - f"userset {user_id} back" + "ʙᴀᴄᴋ", + f"userset {user_id} back", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, "Add or remove upload path.\n", - buttons.build_menu(1), + buttons.build_menu(2), ) elif data[2] == "new_path": await query.answer() buttons = ButtonMaker() buttons.ibutton( - "Back", - f"userset {user_id} upload_paths" + "ʙᴀᴄᴋ", + f"userset {user_id} upload_paths", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, - "Send path name(no space in name) which you will use it as a shortcut and the path/id seperated by space. You can add multiple names and paths separated by new line. Timeout: 60 sec", - buttons.build_menu(1), + ( + "Send path name(no space in name) which you will use it as" + " a shortcut and the path/id seperated by space. You can add" + " multiple names and paths separated by new line. Timeout: 60 sec" + ), + buttons.build_menu(2), ) pfunc = partial( set_option, @@ -1676,17 +1722,19 @@ async def edit_user_settings(client, query): await query.answer() buttons = ButtonMaker() buttons.ibutton( - "Back", - f"userset {user_id} upload_paths" + "ʙᴀᴄᴋ", + f"userset {user_id} upload_paths", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) await editMessage( message, - "Send paths names which you want to delete, separated by space. Timeout: 60 sec", - buttons.build_menu(1), + "Send paths names which you want to delete, separated by space.\n\nTimeout: 60 sec", + buttons.build_menu(2), ) pfunc = partial( delete_path, @@ -1701,12 +1749,14 @@ async def edit_user_settings(client, query): await query.answer() buttons = ButtonMaker() buttons.ibutton( - "Back", - f"userset {user_id} upload_paths" + "ʙᴀᴄᴋ", + f"userset {user_id} upload_paths", + position="footer" ) buttons.ibutton( - "Close", - f"userset {user_id} close" + "ᴄʟᴏꜱᴇ", + f"userset {user_id} close", + position="footer" ) user_dict = user_data.get( user_id, @@ -1719,7 +1769,7 @@ async def edit_user_settings(client, query): await editMessage( message, msg, - buttons.build_menu(1), + buttons.build_menu(2), ) elif data[2] == "reset": await query.answer() diff --git a/bot/modules/ytdlp.py b/bot/modules/ytdlp.py index 92b4e5cbfc45..1f3ec6a92a57 100644 --- a/bot/modules/ytdlp.py +++ b/bot/modules/ytdlp.py @@ -1,22 +1,3 @@ -from asyncio import ( - wait_for, - Event, - wrap_future -) -from functools import partial -from httpx import AsyncClient -from pyrogram.filters import ( - command, - regex, - user -) -from pyrogram.handlers import ( - MessageHandler, - CallbackQueryHandler -) -from time import time -from yt_dlp import YoutubeDL - from bot import ( DOWNLOAD_DIR, bot, @@ -26,428 +7,27 @@ from bot.helper.ext_utils.bot_utils import ( new_task, sync_to_async, - new_thread, arg_parser, COMMAND_USAGE, ) from bot.helper.ext_utils.links_utils import is_url -from bot.helper.ext_utils.status_utils import ( - get_readable_file_size, - get_readable_time +from bot.helper.listeners.ytdlp_listener import ( + YtSelection, + mdisk, + extract_info ) from bot.helper.listeners.task_listener import TaskListener from bot.helper.task_utils.download_utils.yt_dlp_download import YoutubeDLHelper from bot.helper.telegram_helper.bot_commands import BotCommands -from bot.helper.telegram_helper.button_build import ButtonMaker from bot.helper.telegram_helper.filters import CustomFilters from bot.helper.telegram_helper.message_utils import ( auto_delete_message, - delete_links, deleteMessage, - editMessage, sendMessage, ) - -@new_task -async def select_format(_, query, obj): - data = query.data.split() - message = query.message - await query.answer() - - if data[1] == "dict": - b_name = data[2] - await obj.qual_subbuttons(b_name) - elif data[1] == "mp3": - await obj.mp3_subbuttons() - elif data[1] == "audio": - await obj.audio_format() - elif data[1] == "aq": - if data[2] == "back": - await obj.audio_format() - else: - await obj.audio_quality(data[2]) - elif data[1] == "back": - await obj.back_to_main() - elif data[1] == "cancel": - cmsg = await editMessage( - message, - "Yt-Dlp task has been cancelled." - ) - obj.qual = None - obj.listener.isCancelled = True - obj.event.set() - else: - if data[1] == "sub": - obj.qual = obj.formats[data[2]][data[3]][1] - elif "|" in data[1]: - obj.qual = obj.formats[data[1]] - else: - obj.qual = data[1] - obj.event.set() - if obj.listener.isCancelled: - await auto_delete_message( - message, - cmsg - ) - -class YtSelection: - def __init__( - self, - listener - ): - self.listener = listener - self._is_m4a = False - self._reply_to = None - self._time = time() - self._timeout = 120 - self._is_playlist = False - self._main_buttons = None - self.event = Event() - self.formats = {} - self.qual = None - self.tag = listener.tag - - @new_thread - async def _event_handler(self): - pfunc = partial( - select_format, - obj=self - ) - handler = self.listener.client.add_handler( - CallbackQueryHandler( - pfunc, - filters=regex("^ytq") - & - user(self.listener.userId) - ), - group=-1, - ) - try: - await wait_for( - self.event.wait(), - timeout=self._timeout - ) - except: - await editMessage( - self._reply_to, - "Timed Out. Task has been cancelled!" - ) - self.qual = None - self.listener.isCancelled = True - await auto_delete_message( - self.listener.message, - self._reply_to - ) - self.event.set() - finally: - self.listener.client.remove_handler(*handler) - if self.listener.isCancelled: - await delete_links(self.listener.message) - - async def get_quality(self, result): - future = self._event_handler() - buttons = ButtonMaker() - if "entries" in result: - self._is_playlist = True - for i in [ - "144", - "240", - "360", - "480", - "720", - "1080", - "1440", - "2160" - ]: - video_format = f"bv*[height<=?{i}][ext=mp4]+ba[ext=m4a]/b[height<=?{i}]" - b_data = f"{i}|mp4" - self.formats[b_data] = video_format - buttons.ibutton( - f"{i}-mp4", - f"ytq {b_data}" - ) - video_format = f"bv*[height<=?{i}][ext=webm]+ba/b[height<=?{i}]" - b_data = f"{i}|webm" - self.formats[b_data] = video_format - buttons.ibutton( - f"{i}-webm", - f"ytq {b_data}" - ) - buttons.ibutton( - "MP3", - "ytq mp3" - ) - buttons.ibutton( - "Audio Formats", - "ytq audio" - ) - buttons.ibutton( - "Best Videos", - "ytq bv*+ba/b" - ) - buttons.ibutton( - "Best Audios", - "ytq ba/b" - ) - buttons.ibutton( - "Cancel", - "ytq cancel", - "footer" - ) - self._main_buttons = buttons.build_menu(3) - msg = f"Choose Playlist Videos Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - else: - format_dict = result.get("formats") - if format_dict is not None: - for item in format_dict: - if item.get("tbr"): - format_id = item["format_id"] - - if item.get("filesize"): - size = item["filesize"] - elif item.get("filesize_approx"): - size = item["filesize_approx"] - else: - size = 0 - - if ( - item.get("video_ext") == "none" - and ( - item.get("resolution") == "audio only" - or item.get("acodec") != "none" - ) - ): - if item.get("audio_ext") == "m4a": - self._is_m4a = True - b_name = ( - f"{item.get('acodec') or format_id}-{item['ext']}" - ) - v_format = format_id - elif item.get("height"): - height = item["height"] - ext = item["ext"] - fps = ( - item["fps"] - if item.get("fps") - else "" - ) - b_name = f"{height}p{fps}-{ext}" - ba_ext = ( - "[ext=m4a]" - if self._is_m4a - and ext == "mp4" - else "" - ) - v_format = f"{format_id}+ba{ba_ext}/b[height=?{height}]" - else: - continue - - self.formats.setdefault(b_name, {})[ - f"{item['tbr']}" - ] = [ - size, - v_format, - ] - - for b_name, tbr_dict in self.formats.items(): - if len(tbr_dict) == 1: - tbr, v_list = next(iter(tbr_dict.items())) - buttonName = f"{b_name} ({get_readable_file_size(v_list[0])})" - buttons.ibutton( - buttonName, - f"ytq sub {b_name} {tbr}" - ) - else: - buttons.ibutton( - b_name, - f"ytq dict {b_name}" - ) - buttons.ibutton( - "MP3", - "ytq mp3" - ) - buttons.ibutton( - "Audio Formats", - "ytq audio" - ) - buttons.ibutton( - "Best Video", - "ytq bv*+ba/b" - ) - buttons.ibutton( - "Best Audio", - "ytq ba/b" - ) - buttons.ibutton( - "Cancel", - "ytq cancel", - "footer" - ) - self._main_buttons = buttons.build_menu(2) - msg = f"Choose Video Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - self._reply_to = await sendMessage( - self.listener.message, - msg, - self._main_buttons - ) - await wrap_future(future) # type: ignore - if not self.listener.isCancelled: - await deleteMessage(self._reply_to) - return self.qual - - async def back_to_main(self): - if self._is_playlist: - msg = f"Choose Playlist Videos Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - else: - msg = f"Choose Video Quality:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - await editMessage( - self._reply_to, - msg, - self._main_buttons - ) - - async def qual_subbuttons(self, b_name): - buttons = ButtonMaker() - tbr_dict = self.formats[b_name] - for tbr, d_data in tbr_dict.items(): - button_name = f"{tbr}K ({get_readable_file_size(d_data[0])})" - buttons.ibutton( - button_name, - f"ytq sub {b_name} {tbr}" - ) - buttons.ibutton( - "Back", - "ytq back", - "footer" - ) - buttons.ibutton( - "Cancel", - "ytq cancel", - "footer" - ) - subbuttons = buttons.build_menu(2) - msg = f"Choose Bit rate for {b_name}:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - await editMessage( - self._reply_to, - msg, - subbuttons - ) - - async def mp3_subbuttons(self): - i = "s" if self._is_playlist else "" - buttons = ButtonMaker() - audio_qualities = [ - 64, - 128, - 320 - ] - for q in audio_qualities: - audio_format = f"ba/b-mp3-{q}" - buttons.ibutton( - f"{q}K-mp3", - f"ytq {audio_format}" - ) - buttons.ibutton( - "Back", - "ytq back" - ) - buttons.ibutton( - "Cancel", - "ytq cancel" - ) - subbuttons = buttons.build_menu(3) - msg = f"Choose mp3 Audio{i} Bitrate:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - await editMessage( - self._reply_to, - msg, - subbuttons - ) - - async def audio_format(self): - i = "s" if self._is_playlist else "" - buttons = ButtonMaker() - for frmt in [ - "aac", - "alac", - "flac", - "m4a", - "opus", - "vorbis", - "wav" - ]: - audio_format = f"ba/b-{frmt}-" - buttons.ibutton( - frmt, - f"ytq aq {audio_format}" - ) - buttons.ibutton( - "Back", - "ytq back", - "footer" - ) - buttons.ibutton( - "Cancel", - "ytq cancel", - "footer" - ) - subbuttons = buttons.build_menu(3) - msg = f"Choose Audio{i} Format:\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - await editMessage( - self._reply_to, - msg, - subbuttons - ) - - async def audio_quality(self, format): - i = "s" if self._is_playlist else "" - buttons = ButtonMaker() - for qual in range(11): - audio_format = f"{format}{qual}" - buttons.ibutton( - qual, - f"ytq {audio_format}" - ) - buttons.ibutton( - "Back", - "ytq aq back" - ) - buttons.ibutton( - "Cancel", - "ytq aq cancel" - ) - subbuttons = buttons.build_menu(5) - msg = f"Choose Audio{i} Qaulity:\n0 is best and 10 is worst\nTimeout: {get_readable_time(self._timeout - (time() - self._time))}\n\ncc: {self.tag}" # type: ignore - await editMessage( - self._reply_to, - msg, - subbuttons - ) - - -def extract_info(link, options): - with YoutubeDL(options) as ydl: - result = ydl.extract_info( - link, - download=False - ) - if result is None: - raise ValueError("Info result is None") - return result - - -async def _mdisk(link, name): - key = link.split("/")[-1] - async with AsyncClient(verify=False) as client: - resp = await client.get( - f"https://diskuploader.entertainvideo.com/v1/file/cdnurl?param={key}" - ) - if resp.status_code == 200: - resp_json = resp.json() - link = resp_json["source"] - if not name: - name = resp_json["filename"] - return name, link +from pyrogram.filters import command +from pyrogram.handlers import MessageHandler class YtDlp(TaskListener): @@ -597,7 +177,10 @@ async def newEvent(self): not self.link and (reply_to := self.message.reply_to_message) ): - self.link = reply_to.text.split("\n", 1)[0].strip() + self.link = reply_to.text.split( + "\n", + 1 + )[0].strip() if not is_url(self.link): hmsg = await sendMessage( @@ -614,7 +197,10 @@ async def newEvent(self): return if "mdisk.me" in self.link: - self.name, self.link = await _mdisk( + ( + self.name, + self.link + ) = await mdisk( self.link, self.name ) @@ -644,9 +230,15 @@ async def newEvent(self): if opt: yt_opts = opt.split("|") for ytopt in yt_opts: - key, value = map( + ( + key, + value + ) = map( str.strip, - ytopt.split(":", 1) + ytopt.split( + ":", + 1 + ) ) if key == "postprocessors": continue