Did some refactor, add YouTube as search variant
This commit is contained in:
6
bot/results/youtube/__init__.py
Normal file
6
bot/results/youtube/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from .search import get_youtube_search_results
|
||||
|
||||
|
||||
__all__ = [
|
||||
'get_youtube_search_results'
|
||||
]
|
||||
21
bot/results/youtube/search.py
Normal file
21
bot/results/youtube/search.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from aiogram.types import (
|
||||
InlineQueryResultDocument, InlineQueryResultCachedAudio
|
||||
)
|
||||
|
||||
from bot.modules.youtube import youtube
|
||||
from bot.modules.database import db
|
||||
|
||||
from ..common.search import get_common_search_result
|
||||
|
||||
|
||||
async def get_youtube_search_results(query: str) -> list[
|
||||
InlineQueryResultDocument | InlineQueryResultCachedAudio
|
||||
]:
|
||||
return [
|
||||
await get_common_search_result(
|
||||
audio=audio,
|
||||
db_table=db.youtube,
|
||||
service_id='yt'
|
||||
)
|
||||
for audio in youtube.songs.search(query, limit=40)
|
||||
]
|
||||
Reference in New Issue
Block a user