Fix results not shown when no preview_url

This commit is contained in:
BarsTiger
2023-10-16 20:22:32 +03:00
parent b515fdfd65
commit 6b7f613e09
2 changed files with 4 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ async def default_inline_query(inline_query: InlineQuery, bot: Bot):
title=audio.name, title=audio.name,
description=audio.all_artists, description=audio.all_artists,
thumb_url=audio.thumbnail, thumb_url=audio.thumbnail,
document_url=audio.preview_url, document_url=audio.preview_url or audio.thumbnail,
mime_type='application/zip', mime_type='application/zip',
reply_markup=InlineKeyboardMarkup( reply_markup=InlineKeyboardMarkup(
inline_keyboard=[ inline_keyboard=[

View File

@@ -7,7 +7,7 @@ class SongItem:
name: str name: str
id: str id: str
artists: list[str] artists: list[str]
preview_url: str preview_url: str | None
thumbnail: str thumbnail: str
@classmethod @classmethod
@@ -16,7 +16,8 @@ class SongItem:
name=song_item['name'], name=song_item['name'],
id=song_item['id'], id=song_item['id'],
artists=[artist['name'] for artist in song_item['artists']], artists=[artist['name'] for artist in song_item['artists']],
preview_url=song_item['preview_url'].split('?')[0], preview_url=song_item['preview_url'].split('?')[0] if
song_item['preview_url'] is not None else None,
thumbnail=song_item['album']['images'][1]['url'] thumbnail=song_item['album']['images'][1]['url']
) )