Skip to content

Commit

Permalink
Merge pull request #84 from TheTeamAlexa/autofix
Browse files Browse the repository at this point in the history
Updated To Pyro 2
  • Loading branch information
TheTeamAlexa authored Nov 28, 2023
2 parents 57eb8c0 + 203b953 commit 5f7d447
Showing 1 changed file with 21 additions and 46 deletions.
67 changes: 21 additions & 46 deletions AlexaMusic/plugins/tools/songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
import yt_dlp
from pykeyboard import InlineKeyboard
from pyrogram import enums, filters
from pyrogram.types import (InlineKeyboardButton,
InlineKeyboardMarkup, InputMediaAudio,
InputMediaVideo, Message)
from pyrogram.types import (
InlineKeyboardButton,
InlineKeyboardMarkup,
InputMediaAudio,
InputMediaVideo,
Message,
)

from config import (BANNED_USERS, SONG_DOWNLOAD_DURATION,
SONG_DOWNLOAD_DURATION_LIMIT)
from config import BANNED_USERS, SONG_DOWNLOAD_DURATION, SONG_DOWNLOAD_DURATION_LIMIT
from strings import get_command
from AlexaMusic import YouTube, app
from AlexaMusic.utils.decorators.language import language, languageCB
Expand All @@ -31,11 +34,7 @@
SONG_COMMAND = get_command("SONG_COMMAND")


@app.on_message(
filters.command(SONG_COMMAND)
& filters.group
& ~BANNED_USERS
)
@app.on_message(filters.command(SONG_COMMAND) & filters.group & ~BANNED_USERS)
@language
async def song_commad_group(client, message: Message, _):
upl = InlineKeyboardMarkup(
Expand All @@ -54,11 +53,7 @@ async def song_commad_group(client, message: Message, _):
# Song Module


@app.on_message(
filters.command(SONG_COMMAND)
& filters.private
& ~BANNED_USERS
)
@app.on_message(filters.command(SONG_COMMAND) & filters.private & ~BANNED_USERS)
@language
async def song_commad_private(client, message: Message, _):
await message.delete()
Expand All @@ -78,9 +73,7 @@ async def song_commad_private(client, message: Message, _):
return await mystic.edit_text(_["song_3"])
if int(duration_sec) > SONG_DOWNLOAD_DURATION_LIMIT:
return await mystic.edit_text(
_["play_4"].format(
SONG_DOWNLOAD_DURATION, duration_min
)
_["play_4"].format(SONG_DOWNLOAD_DURATION, duration_min)
)
buttons = song_markup(_, vidid)
await mystic.delete()
Expand Down Expand Up @@ -119,9 +112,7 @@ async def song_commad_private(client, message: Message, _):
)


@app.on_callback_query(
filters.regex(pattern=r"song_back") & ~BANNED_USERS
)
@app.on_callback_query(filters.regex(pattern=r"song_back") & ~BANNED_USERS)
@languageCB
async def songs_back_helper(client, CallbackQuery, _):
callback_data = CallbackQuery.data.strip()
Expand All @@ -133,9 +124,7 @@ async def songs_back_helper(client, CallbackQuery, _):
)


@app.on_callback_query(
filters.regex(pattern=r"song_helper") & ~BANNED_USERS
)
@app.on_callback_query(filters.regex(pattern=r"song_helper") & ~BANNED_USERS)
@languageCB
async def song_helper_cb(client, CallbackQuery, _):
callback_data = CallbackQuery.data.strip()
Expand All @@ -147,9 +136,7 @@ async def song_helper_cb(client, CallbackQuery, _):
pass
if stype == "audio":
try:
formats_available, link = await YouTube.formats(
vidid, True
)
formats_available, link = await YouTube.formats(vidid, True)
except:
return await CallbackQuery.edit_message_text(_["song_7"])
keyboard = InlineKeyboard()
Expand Down Expand Up @@ -177,18 +164,12 @@ async def song_helper_cb(client, CallbackQuery, _):
text=_["BACK_BUTTON"],
callback_data=f"song_back {stype}|{vidid}",
),
InlineKeyboardButton(
text=_["CLOSE_BUTTON"], callback_data=f"close"
),
)
return await CallbackQuery.edit_message_reply_markup(
reply_markup=keyboard
InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data=f"close"),
)
return await CallbackQuery.edit_message_reply_markup(reply_markup=keyboard)
else:
try:
formats_available, link = await YouTube.formats(
vidid, True
)
formats_available, link = await YouTube.formats(vidid, True)
except Exception as e:
print(e)
return await CallbackQuery.edit_message_text(_["song_7"])
Expand All @@ -215,21 +196,15 @@ async def song_helper_cb(client, CallbackQuery, _):
text=_["BACK_BUTTON"],
callback_data=f"song_back {stype}|{vidid}",
),
InlineKeyboardButton(
text=_["CLOSE_BUTTON"], callback_data=f"close"
),
)
return await CallbackQuery.edit_message_reply_markup(
reply_markup=keyboard
InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data=f"close"),
)
return await CallbackQuery.edit_message_reply_markup(reply_markup=keyboard)


# Downloading Songs Here


@app.on_callback_query(
filters.regex(pattern=r"song_download") & ~BANNED_USERS
)
@app.on_callback_query(filters.regex(pattern=r"song_download") & ~BANNED_USERS)
@languageCB
async def song_download_cb(client, CallbackQuery, _):
try:
Expand Down Expand Up @@ -309,4 +284,4 @@ async def song_download_cb(client, CallbackQuery, _):
except Exception as e:
print(e)
return await mystic.edit_text(_["song_10"])
os.remove(filename)
os.remove(filename)

0 comments on commit 5f7d447

Please sign in to comment.