Fix yt-dlp title error, and inline title
This commit is contained in:
@@ -588,6 +588,8 @@ async def url_handler(client: Client, message: Message):
|
||||
text += "Выберите видео для загрузки:\n\n"
|
||||
|
||||
# Create inline keyboard with video selection buttons
|
||||
from bot.modules.message_handler.video_selection_cache import store_video_selection
|
||||
|
||||
buttons = []
|
||||
for idx, video in enumerate(videos[:10], 1): # Limit to 10 videos
|
||||
title = video.get('title', f'Видео {idx}')[:50] # Limit title length
|
||||
@@ -597,8 +599,10 @@ async def url_handler(client: Client, message: Message):
|
||||
duration_str = format_duration(duration)
|
||||
title += f" ({duration_str})"
|
||||
|
||||
# Use callback data format: video_select:<video_url>
|
||||
callback_data = f"video_select:{video['url']}"
|
||||
# Store video URL in cache and use short identifier in callback_data
|
||||
# This avoids Telegram's 64-byte limit on callback_data
|
||||
selection_id = store_video_selection(video['url'], user_id)
|
||||
callback_data = f"video_select:{selection_id}"
|
||||
buttons.append([InlineKeyboardButton(f"{idx}. {title}", callback_data=callback_data)])
|
||||
|
||||
keyboard = InlineKeyboardMarkup(buttons)
|
||||
@@ -779,4 +783,3 @@ def register_commands(app: Client):
|
||||
app.add_handler(MessageHandler(url_handler, filters=is_url_message))
|
||||
|
||||
logger.info("Commands registered")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user