Add deezer as default search
This commit is contained in:
33
bot/markups/deezer/search.py
Normal file
33
bot/markups/deezer/search.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from aiogram.types import (
|
||||
InlineQueryResultDocument, InlineQueryResultCachedAudio,
|
||||
InlineKeyboardMarkup, InlineKeyboardButton
|
||||
)
|
||||
|
||||
from bot.modules.deezer import deezer
|
||||
from bot.modules.database import db
|
||||
|
||||
|
||||
async def get_deezer_search_results(query: str) -> list[
|
||||
InlineQueryResultDocument | InlineQueryResultCachedAudio
|
||||
]:
|
||||
return [
|
||||
InlineQueryResultDocument(
|
||||
id='deez::' + audio.id_s,
|
||||
title=audio.name,
|
||||
description=audio.artist,
|
||||
thumb_url=audio.thumbnail,
|
||||
document_url=audio.preview_url or audio.thumbnail,
|
||||
mime_type='application/zip',
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text='Downloading...', callback_data='.')]
|
||||
]
|
||||
),
|
||||
caption=audio.full_name,
|
||||
) if audio.id_s not in list(db.deezer.keys()) else
|
||||
InlineQueryResultCachedAudio(
|
||||
id='deezc::' + audio.id_s,
|
||||
audio_file_id=db.deezer[audio.id_s],
|
||||
)
|
||||
for audio in await deezer.songs.search(query, limit=50)
|
||||
]
|
||||
Reference in New Issue
Block a user