Fix yt-dlp title error, and inline title

This commit is contained in:
2025-12-05 22:16:33 +03:00
parent 5c280a4d3a
commit ec0fd18317
4 changed files with 188 additions and 7 deletions

View File

@@ -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")