Add changing preview type when searching track

This commit is contained in:
BarsTiger
2023-11-07 18:45:41 +02:00
parent 06c327933f
commit e99ba9daa3
12 changed files with 54 additions and 23 deletions

View File

@@ -4,6 +4,7 @@ from aiogram.types import (
)
from bot.modules.database.db import DBDict
from bot.modules.settings import UserSettings
from bot.modules.common.song import BaseSongItem
from typing import TypeVar
@@ -15,7 +16,8 @@ BaseSongT = TypeVar('BaseSongT', bound=BaseSongItem)
async def get_common_search_result(
audio: BaseSongT,
db_table: DBDict,
service_id: str
service_id: str,
settings: UserSettings
) -> InlineQueryResultDocument | InlineQueryResultCachedAudio:
return (
InlineQueryResultDocument(
@@ -23,7 +25,8 @@ async def get_common_search_result(
title=audio.name,
description=audio.all_artists,
thumb_url=audio.thumbnail,
document_url=audio.preview_url or audio.thumbnail,
document_url=(audio.preview_url or audio.thumbnail) if
settings['search_preview'].value == 'preview' else audio.thumbnail,
mime_type='application/zip',
reply_markup=InlineKeyboardMarkup(
inline_keyboard=[