From 80156d9becd795911eda52898a38c19b1dac882d Mon Sep 17 00:00:00 2001 From: KSKOP69 <123794242+KSKOP69@users.noreply.github.com> Date: Fri, 12 Jan 2024 22:21:33 +0530 Subject: [PATCH] No Sound Fixed --- AlexaMusic/plugins/bot/settings.py | 93 +++++++++++------- AlexaMusic/utils/database/memorydatabase.py | 59 ++++++------ AlexaMusic/utils/inline/settings.py | 100 ++++++++++++-------- strings/langs/en.yml | 6 ++ 4 files changed, 156 insertions(+), 102 deletions(-) diff --git a/AlexaMusic/plugins/bot/settings.py b/AlexaMusic/plugins/bot/settings.py index 1061b4a4..c7dd9862 100644 --- a/AlexaMusic/plugins/bot/settings.py +++ b/AlexaMusic/plugins/bot/settings.py @@ -117,25 +117,30 @@ async def settings_back_markup(client, CallbackQuery: CallbackQuery, _): ## Audio and Video Quality async def gen_buttons_aud(_, aud): - if aud == "High": - buttons = audio_quality_markup(_, high=True) - elif aud == "Medium": - buttons = audio_quality_markup(_, medium=True) - elif aud == "Low": - buttons = audio_quality_markup(_, low=True) + if aud == "STUDIO": + buttons = audio_quality_markup(_, STUDIO=True) + elif aud == "HIGH": + buttons = audio_quality_markup(_, HIGH=True) + elif aud == "MEDIUM": + buttons = audio_quality_markup(_, MEDIUM=True) + elif aud == "LOW": + buttons = audio_quality_markup(_, LOW=True) return buttons async def gen_buttons_vid(_, aud): - if aud == "High": - buttons = video_quality_markup(_, high=True) - elif aud == "Medium": - buttons = video_quality_markup(_, medium=True) - elif aud == "Low": - buttons = video_quality_markup(_, low=True) + if aud == "QHD_2K": + buttons = video_quality_markup(_, QHD_2K=True) + elif aud == "FHD_1080p": + buttons = video_quality_markup(_, FHD_1080p=True) + elif aud == "HD_720p": + buttons = video_quality_markup(_, HD_720p=True) + elif aud == "SD_480p": + buttons = video_quality_markup(_, SD_480p=True) + elif aud == "SD_360p": + buttons = video_quality_markup(_, SD_360p=True) return buttons - # without admin rights @@ -258,7 +263,8 @@ async def without_Admin_rights(client, CallbackQuery, _): @app.on_callback_query( - filters.regex(pattern=r"^(LQA|MQA|HQA|LQV|MQV|HQV)$") & ~BANNED_USERS + filters.regex(pattern=r"^(LOW|MEDIUM|HIGH|STUDIO|SD_360p|SD_480p|HD_720p|FHD_1080p|QHD_2K)$") + & ~BANNED_USERS ) @ActualAdminCB async def aud_vid_cb(client, CallbackQuery, _): @@ -267,24 +273,47 @@ async def aud_vid_cb(client, CallbackQuery, _): await CallbackQuery.answer(_["set_cb_6"], show_alert=True) except: pass - if command == "LQA": - await save_audio_bitrate(CallbackQuery.message.chat.id, "Low") - buttons = audio_quality_markup(_, low=True) - if command == "MQA": - await save_audio_bitrate(CallbackQuery.message.chat.id, "Medium") - buttons = audio_quality_markup(_, medium=True) - if command == "HQA": - await save_audio_bitrate(CallbackQuery.message.chat.id, "High") - buttons = audio_quality_markup(_, high=True) - if command == "LQV": - await save_video_bitrate(CallbackQuery.message.chat.id, "Low") - buttons = video_quality_markup(_, low=True) - if command == "MQV": - await save_video_bitrate(CallbackQuery.message.chat.id, "Medium") - buttons = video_quality_markup(_, medium=True) - if command == "HQV": - await save_video_bitrate(CallbackQuery.message.chat.id, "High") - buttons = video_quality_markup(_, high=True) + if command == "LOW": + await save_audio_bitrate(CallbackQuery.message.chat.id, "LOW") + buttons = audio_quality_markup(_, LOW=True) + if command == "MEDIUM": + await save_audio_bitrate( + CallbackQuery.message.chat.id, "MEDIUM" + ) + buttons = audio_quality_markup(_, MEDIUM=True) + if command == "HIGH": + await save_audio_bitrate( + CallbackQuery.message.chat.id, "HIGH" + ) + buttons = audio_quality_markup(_, HIGH=True) + if command == "STUDIO": + await save_audio_bitrate( + CallbackQuery.message.chat.id, "STUDIO" + ) + buttons = audio_quality_markup(_, STUDIO=True) + if command == "SD_360p": + await save_video_bitrate(CallbackQuery.message.chat.id, "SD_360p") + buttons = video_quality_markup(_, SD_360p=True) + if command == "SD_480p": + await save_video_bitrate( + CallbackQuery.message.chat.id, "SD_480p" + ) + buttons = video_quality_markup(_, SD_480p=True) + if command == "HD_720p": + await save_video_bitrate( + CallbackQuery.message.chat.id, "HD_720p" + ) + buttons = video_quality_markup(_, HD_720p=True) + if command == "FHD_1080p": + await save_video_bitrate( + CallbackQuery.message.chat.id, "FHD_1080p" + ) + buttons = video_quality_markup(_, FHD_1080p=True) + if command == "QHD_2K": + await save_video_bitrate( + CallbackQuery.message.chat.id, "QHD_2K" + ) + buttons = video_quality_markup(_, QHD_2K=True) try: return await CallbackQuery.edit_message_reply_markup( reply_markup=InlineKeyboardMarkup(buttons) diff --git a/AlexaMusic/utils/database/memorydatabase.py b/AlexaMusic/utils/database/memorydatabase.py index 78386a08..e19ceb3a 100644 --- a/AlexaMusic/utils/database/memorydatabase.py +++ b/AlexaMusic/utils/database/memorydatabase.py @@ -459,13 +459,11 @@ async def maintenance_on(): # Audio Video Limit -from pytgcalls.types.input_stream.quality import ( - HighQualityAudio, - HighQualityVideo, - LowQualityAudio, - LowQualityVideo, - MediumQualityAudio, - MediumQualityVideo, +from pytgcalls.types import ( + AudioParameters, + AudioQuality, + VideoParameters, + VideoQuality ) @@ -479,43 +477,42 @@ async def save_video_bitrate(chat_id: int, bitrate: str): async def get_aud_bit_name(chat_id: int) -> str: mode = audio.get(chat_id) - if not mode: - return "High" - return mode + return "HIGH" if not mode else mode async def get_vid_bit_name(chat_id: int) -> str: mode = video.get(chat_id) - if not mode: - if PRIVATE_BOT_MODE == str(True): - return "High" - else: - return "Medium" - return mode + return "FHD_1080p" if not mode else mode async def get_audio_bitrate(chat_id: int) -> str: mode = audio.get(chat_id) if not mode: - return MediumQualityAudio() - if str(mode) == "High": - return HighQualityAudio() - elif str(mode) == "Medium": - return MediumQualityAudio() - elif str(mode) == "Low": - return LowQualityAudio() + return AudioParameters.from_quality(AudioQuality.STUDIO) + if str(mode) == "STUDIO": + return AudioParameters.from_quality(AudioQuality.STUDIO) + elif str(mode) == "HIGH": + return AudioParameters.from_quality(AudioQuality.HIGH) + elif str(mode) == "MEDIUM": + return AudioParameters.from_quality(AudioQuality.MEDIUM) + elif str(mode) == "LOW": + return AudioParameters.from_quality(AudioQuality.LOW) async def get_video_bitrate(chat_id: int) -> str: mode = video.get(chat_id) if not mode: if PRIVATE_BOT_MODE == str(True): - return HighQualityVideo() + return VideoParameters.from_quality(VideoQuality.FHD_1080p) else: - return MediumQualityVideo() - if str(mode) == "High": - return HighQualityVideo() - elif str(mode) == "Medium": - return MediumQualityVideo() - elif str(mode) == "Low": - return LowQualityVideo() + return VideoParameters.from_quality(VideoQuality.HD_720p) + if str(mode) == "QHD_2K": + return VideoParameters.from_quality(VideoQuality.QHD_2K) + elif str(mode) == "FHD_1080p": + return VideoParameters.from_quality(VideoQuality.FHD_1080p) + elif str(mode) == "HD_720p": + return VideoParameters.from_quality(VideoQuality.HD_720p) + elif str(mode) == "SD_480p": + return VideoParameters.from_quality(VideoQuality.SD_480p) + elif str(mode) == "SD_360p": + return VideoParameters.from_quality(VideoQuality.SD_360p) \ No newline at end of file diff --git a/AlexaMusic/utils/inline/settings.py b/AlexaMusic/utils/inline/settings.py index 59401d8f..e6e90ce1 100644 --- a/AlexaMusic/utils/inline/settings.py +++ b/AlexaMusic/utils/inline/settings.py @@ -42,85 +42,107 @@ def setting_markup(_): def audio_quality_markup( _, - low: Union[bool, str] = None, - medium: Union[bool, str] = None, - high: Union[bool, str] = None, + LOW: Union[bool, str] = None, + MEDIUM: Union[bool, str] = None, + HIGH: Union[bool, str] = None, + STUDIO: Union[bool, str] = None, ): - buttons = [ + return [ [ InlineKeyboardButton( - text=_["ST_B_8"].format("✅") if low == True else _["ST_B_8"].format(""), - callback_data="LQA", - ) - ], - [ + text=_["ST_B_8"].format("✅") + if LOW == True + else _["ST_B_8"].format(""), + callback_data="LOW", + ), InlineKeyboardButton( text=_["ST_B_9"].format("✅") - if medium == True + if MEDIUM == True else _["ST_B_9"].format(""), - callback_data="MQA", - ) + callback_data="MEDIUM", + ), ], [ InlineKeyboardButton( text=_["ST_B_10"].format("✅") - if high == True + if HIGH == True else _["ST_B_10"].format(""), - callback_data="HQA", - ) + callback_data="HIGH", + ), + InlineKeyboardButton( + text=_["ST_B_28"].format("✅") + if STUDIO == True + else _["ST_B_28"].format(""), + callback_data="STUDIO", + ), ], [ InlineKeyboardButton( text=_["BACK_BUTTON"], callback_data="settingsback_helper", ), - InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data="close"), + InlineKeyboardButton( + text=_["CLOSE_BUTTON"], callback_data="close" + ), ], ] - return buttons def video_quality_markup( _, - low: Union[bool, str] = None, - medium: Union[bool, str] = None, - high: Union[bool, str] = None, + SD_360p: Union[bool, str] = None, + SD_480p: Union[bool, str] = None, + HD_720p: Union[bool, str] = None, + FHD_1080p: Union[bool, str] = None, + QHD_2K: Union[bool, str] = None, ): - buttons = [ + return [ [ InlineKeyboardButton( - text=_["ST_B_11"].format("✅") - if low == True - else _["ST_B_11"].format(""), - callback_data="LQV", - ) + text=_["ST_B_29"].format("✅") + if SD_360p == True + else _["ST_B_29"].format(""), + callback_data="SD_360p", + ), + InlineKeyboardButton( + text=_["ST_B_30"].format("✅") + if SD_480p == True + else _["ST_B_30"].format(""), + callback_data="SD_480p", + ), ], [ InlineKeyboardButton( - text=_["ST_B_12"].format("✅") - if medium == True - else _["ST_B_12"].format(""), - callback_data="MQV", - ) + text=_["ST_B_31"].format("✅") + if HD_720p == True + else _["ST_B_31"].format(""), + callback_data="HD_720p", + ), + InlineKeyboardButton( + text=_["ST_B_32"].format("✅") + if FHD_1080p == True + else _["ST_B_32"].format(""), + callback_data="FHD_1080p", + ), ], [ InlineKeyboardButton( - text=_["ST_B_13"].format("✅") - if high == True - else _["ST_B_13"].format(""), - callback_data="HQV", - ) + text=_["ST_B_33"].format("✅") + if QHD_2K == True + else _["ST_B_33"].format(""), + callback_data="QHD_2K", + ), ], [ InlineKeyboardButton( text=_["BACK_BUTTON"], callback_data="settingsback_helper", ), - InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data="close"), + InlineKeyboardButton( + text=_["CLOSE_BUTTON"], callback_data="close" + ), ], ] - return buttons - def cleanmode_settings_markup( _, diff --git a/strings/langs/en.yml b/strings/langs/en.yml index 42203085..b607f9b8 100644 --- a/strings/langs/en.yml +++ b/strings/langs/en.yml @@ -313,6 +313,12 @@ ST_B_24 : "🌺 ᴄʜᴀɴɴᴇʟ" ST_B_25 : "🫂 ᴘʟᴀʏ ᴛʏᴘᴇ" ST_B_26 : "🥀 ᴄᴏᴍᴍᴀɴᴅ ᴄʟᴇᴀɴ" ST_B_27 : "🌈 sᴜɢɢᴇsᴛɪᴏɴ ᴍᴏᴅᴇ" +ST_B_28 : "{0} STUDIO AudioQuality" +ST_B_29 : "{0} SD-360p VideoQuality" +ST_B_30 : "{0} SD-480p VideoQuality" +ST_B_31 : "{0} HD-720p VideoQuality" +ST_B_32 : "{0} FHD-1080p VideoQuality" +ST_B_33 : "{0} QHD-2k VideoQuality" #Song SG_B_1 : "๏ ᴄʟɪᴄᴋ ʜᴇʀᴇ ๏"