Skip to content

Commit 8f3b04f

Browse files
committed
Fix transcripts not available bug
1 parent bfe3ae5 commit 8f3b04f

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

youtubevideotranscriptbot/telegram_bot.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ async def handle_youtube_link(update: Update, context: CallbackContext):
172172
}
173173
)
174174

175+
transcripts = []
175176
# Get video details
176177
video_details = get_video_details(video_id)
177178
channel_id = video_details.get('snippet', {}).get('channelId')
@@ -405,10 +406,10 @@ async def handle_youtube_link(update: Update, context: CallbackContext):
405406
original_language = normalize_language_code(original_language) # Get the language code of the first transcript
406407
logger.warning(f"Original video language determined as: {original_language}")
407408
except Exception as e:
408-
original_language = next(iter(transcript_list)).get('language_code', 'en')
409409
logger.error(f"Error determining the original language: {e}") # Get the language code of the first transcript
410410
logger.warning(f"Original language could not be determined. Falling back to first random or English: {original_language}")
411-
411+
original_language = next(iter(transcripts)).get('language_code', 'en')
412+
logger.info(f"Original language determined as: {original_language}")
412413
try:
413414
original_language = normalize_language_code(original_language)
414415
except:
@@ -423,6 +424,20 @@ async def handle_youtube_link(update: Update, context: CallbackContext):
423424
keyboard.append([InlineKeyboardButton("Summarize in Russian", callback_data=f"sum&{video_id}&ru&{transcript_request_id}")])
424425
reply_markup = InlineKeyboardMarkup(keyboard)
425426
await update.message.reply_text("🔮 Would you like a summary?", reply_markup=reply_markup)
427+
428+
track_event(
429+
user_id=user.id,
430+
event_type="handle_youtube_link_summarization_buttons_displayed",
431+
event_properties={
432+
"username": user.username,
433+
"is_bot": user.is_bot,
434+
"language_code": user.language_code,
435+
"is_premium": user.is_premium,
436+
"video_url": video_url,
437+
"video_id": video_id,
438+
"environment": ENVIRONMENT
439+
}
440+
)
426441

427442
else:
428443
logger.warning(f"No transcripts retrieved for video {video_id}.")

0 commit comments

Comments
 (0)