used black
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from aiogram import Router, Bot, F
|
||||
from aiogram.types import (
|
||||
BufferedInputFile, URLInputFile, InputMediaAudio,
|
||||
BufferedInputFile,
|
||||
URLInputFile,
|
||||
InputMediaAudio,
|
||||
ChosenInlineResult,
|
||||
)
|
||||
|
||||
@@ -12,19 +14,20 @@ from bot.modules.settings import UserSettings
|
||||
router = Router()
|
||||
|
||||
|
||||
@router.chosen_inline_result(F.result_id.startswith('yt::'))
|
||||
async def on_new_chosen(chosen_result: ChosenInlineResult, bot: Bot,
|
||||
settings: UserSettings):
|
||||
song = youtube.songs.from_id(chosen_result.result_id.removeprefix('yt::'))
|
||||
@router.chosen_inline_result(F.result_id.startswith("yt::"))
|
||||
async def on_new_chosen(
|
||||
chosen_result: ChosenInlineResult, bot: Bot, settings: UserSettings
|
||||
):
|
||||
song = youtube.songs.from_id(chosen_result.result_id.removeprefix("yt::"))
|
||||
|
||||
try:
|
||||
bytestream = await song.to_bytestream()
|
||||
except AgeRestrictedError:
|
||||
await bot.edit_message_caption(
|
||||
inline_message_id=chosen_result.inline_message_id,
|
||||
caption='🔞 This song is age restricted, so I can\'t download it. '
|
||||
'Try downloading it from Deezer or SoundCloud',
|
||||
reply_markup=None
|
||||
caption="🔞 This song is age restricted, so I can't download it. "
|
||||
"Try downloading it from Deezer or SoundCloud",
|
||||
reply_markup=None,
|
||||
)
|
||||
return
|
||||
|
||||
@@ -45,14 +48,14 @@ async def on_new_chosen(chosen_result: ChosenInlineResult, bot: Bot,
|
||||
await bot.edit_message_media(
|
||||
inline_message_id=chosen_result.inline_message_id,
|
||||
media=InputMediaAudio(media=audio.audio.file_id),
|
||||
reply_markup=None
|
||||
reply_markup=None,
|
||||
)
|
||||
|
||||
if settings['recode_youtube'].value == 'yes':
|
||||
if settings["recode_youtube"].value == "yes":
|
||||
await bot.edit_message_caption(
|
||||
inline_message_id=chosen_result.inline_message_id,
|
||||
caption='🔄 Recoding...',
|
||||
reply_markup=None
|
||||
caption="🔄 Recoding...",
|
||||
reply_markup=None,
|
||||
)
|
||||
|
||||
await bytestream.rerender()
|
||||
@@ -75,7 +78,7 @@ async def on_new_chosen(chosen_result: ChosenInlineResult, bot: Bot,
|
||||
await bot.edit_message_media(
|
||||
inline_message_id=chosen_result.inline_message_id,
|
||||
media=InputMediaAudio(media=audio.audio.file_id),
|
||||
reply_markup=None
|
||||
reply_markup=None,
|
||||
)
|
||||
else:
|
||||
db.recoded[song.id] = audio.message_id
|
||||
|
||||
Reference in New Issue
Block a user