From 4aa1c2829b249e69852e713662d55fa535cb752d Mon Sep 17 00:00:00 2001 From: KSKOP69 <123794242+KSKOP69@users.noreply.github.com> Date: Sat, 13 Jan 2024 13:43:42 +0530 Subject: [PATCH] No sound Fixed --- AlexaMusic/plugins/bot/settings.py | 95 +++++++++++------- AlexaMusic/utils/database/memorydatabase.py | 59 ++++++----- AlexaMusic/utils/inline/settings.py | 102 ++++++++++++-------- Dockerfile | 28 ++++-- requirements.txt | 10 +- strings/langs/en.yml | 6 ++ 6 files changed, 182 insertions(+), 118 deletions(-) diff --git a/AlexaMusic/plugins/bot/settings.py b/AlexaMusic/plugins/bot/settings.py index 1061b4a4..6ef0c23a 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) @@ -508,4 +537,4 @@ async def cleanmode_mark(client, CallbackQuery, _): reply_markup=InlineKeyboardMarkup(buttons) ) except MessageNotModified: - return + return \ No newline at end of file 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..27ba709b 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( _, @@ -220,4 +242,4 @@ def playmode_users_markup( InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data="close"), ], ] - return buttons + return buttons \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2c1abcf3..483dd46c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,22 @@ -FROM nikolaik/python-nodejs:python3.9-nodejs19 +FROM python:3.11-bookworm -RUN apt-get update \ - && apt-get install -y --no-install-recommends ffmpeg \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" -COPY . /app/ -WORKDIR /app/ -RUN pip3 install --no-cache-dir -U -r requirements.txt +WORKDIR /app +ENV PIP_NO_CACHE_DIR=1 PYTHONUNBUFFERED=1 -CMD bash start +RUN apt update && \ + apt upgrade -y && \ + apt install -y ffmpeg apt-utils build-essential python3-dev && \ + pip3 install -U pip wheel setuptools && \ + apt-get clean + +COPY . . + +RUN pip3 install --no-cache-dir -U -r requirements.txt && \ + apt update && apt autoremove -y && \ + apt clean && rm -rf /var/lib/apt/lists/* ~/.thumbs/* ~/.cache + +CMD python3 -m AlexaMusic diff --git a/requirements.txt b/requirements.txt index 3aa1fb72..be4bc0e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,17 @@ aiofiles -aiohttp==3.8.5 +aiohttp asyncio -dnspython +dnspython==2.3.0 ffmpeg-python gitpython hachoir heroku3 lyricsgenius motor==3.0.0 +ntgcalls==1.0.4 pillow==9.5.0 psutil -py-tgcalls -ntgcalls +py-tgcalls==1.1.2 pykeyboard pyrofork python-dotenv @@ -23,4 +23,4 @@ tgcrypto youtube-search youtube-search-python yt-dlp -numpy +numpy \ No newline at end of file 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 : "๏ ᴄʟɪᴄᴋ ʜᴇʀᴇ ๏"