Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No sound Fixed #119

Merged
merged 2 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 62 additions & 33 deletions AlexaMusic/plugins/bot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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, _):
Expand All @@ -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)
Expand Down Expand Up @@ -508,4 +537,4 @@ async def cleanmode_mark(client, CallbackQuery, _):
reply_markup=InlineKeyboardMarkup(buttons)
)
except MessageNotModified:
return
return
59 changes: 28 additions & 31 deletions AlexaMusic/utils/database/memorydatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand All @@ -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)
102 changes: 62 additions & 40 deletions AlexaMusic/utils/inline/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
_,
Expand Down Expand Up @@ -220,4 +242,4 @@ def playmode_users_markup(
InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data="close"),
],
]
return buttons
return buttons
28 changes: 19 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Loading