@@ -600,10 +600,24 @@ async def transcribe_audio(bot, update, audio_path, output_dir, youtube_url, vid
600600 logger .error (f"An error occurred during transcription: { e } " )
601601 return {}, ""
602602
603+ # debugger for yt-dlp version
604+ async def debug_yt_dlp_version ():
605+ proc = await asyncio .create_subprocess_exec (
606+ "yt-dlp" , "--version" ,
607+ stdout = asyncio .subprocess .PIPE ,
608+ stderr = asyncio .subprocess .PIPE
609+ )
610+ out , err = await proc .communicate ()
611+ logger .info (f"DEBUG: 'yt-dlp --version' -> { out .decode ().strip ()} " )
603612
604613# Process the message's URL and keep the user informed
605614# (Added in the new GPU logging function call to the process_url_message function)
606615async def process_url_message (message_text , bot , update , model , language ):
616+
617+ # fetch delays
618+ config = ConfigLoader .get_config ()
619+ desc_fetch_delay = config .getfloat ('Delays' , 'descriptionfetchdelay' , fallback = 0.0 )
620+
607621 try :
608622 # Get transcription settings
609623 transcription_settings = get_transcription_settings ()
@@ -613,6 +627,9 @@ async def process_url_message(message_text, bot, update, model, language):
613627 should_send_detailed_info = notification_settings ['send_detailed_info' ]
614628 send_video_info = notification_settings ['send_video_info' ]
615629
630+ # for yt-dlp version debugging
631+ await debug_yt_dlp_version ()
632+
616633 logger .info (f"Transcription settings in process_url_message: { transcription_settings } " )
617634
618635 user_id = update .effective_user .id
@@ -645,32 +662,82 @@ async def process_url_message(message_text, bot, update, model, language):
645662 audio_path = os .path .join (audio_dir , audio_file_name )
646663 video_info_message = "Transcription initiated."
647664
648- # Wrap fetch_video_details in try-except
665+ # get the video details first; graceful passthrough if broken
649666 try :
650667 logger .info ("Fetching video details..." )
651668 details = await fetch_video_details (normalized_url )
652669 details ['video_url' ] = normalized_url
653- video_info_message = create_video_info_message (details )
654-
655- # Only send if config says so
656- if send_video_info :
657- for part in split_message (video_info_message ):
658- await bot .send_message (
659- chat_id = update .effective_chat .id ,
660- text = f"<code>{ part } </code>" ,
661- parse_mode = 'HTML'
662- )
663670
664671 except Exception as e :
665- error_message = str (e )
666- logger .error (f"An error occurred while fetching video details: { error_message } " )
667- # await bot.send_message(chat_id=update.effective_chat.id, text=f"❌ Error: {error_message}")
672+ # WARN instead of abort
673+ logger .warning (f"Could not fetch video details for '{ normalized_url } '. Continuing anyway.\n Error: { e } " )
668674 await bot .send_message (
669675 chat_id = update .effective_chat .id ,
670- text = f"❌ Error: { error_message } " ,
676+ text = "⚠️ WARNING: Could not fetch video description. Continuing with audio download..." ,
671677 disable_web_page_preview = True
672678 )
673- continue # Skip to the next URL if any
679+ # Provide a fallback for create_video_info_message()
680+ details = {
681+ 'title' : '???' ,
682+ 'duration' : 0 ,
683+ 'channel' : '???' ,
684+ 'upload_date' : '?' ,
685+ 'views' : '?' ,
686+ 'likes' : '?' ,
687+ 'average_rating' : '?' ,
688+ 'comment_count' : '?' ,
689+ 'channel_id' : '?' ,
690+ 'video_id' : '?' ,
691+ 'video_url' : normalized_url ,
692+ 'tags' : [],
693+ 'description' : 'No description available' ,
694+ 'audio_duration' : 0
695+ }
696+
697+ # Now create a (possibly placeholder) message
698+ video_info_message = create_video_info_message (details )
699+
700+ # Only send if config says so
701+ if send_video_info and video_info_message .strip ():
702+ for part in split_message (video_info_message ):
703+ await bot .send_message (
704+ chat_id = update .effective_chat .id ,
705+ text = f"<code>{ part } </code>" ,
706+ parse_mode = 'HTML'
707+ )
708+
709+ # # // (old method)
710+ # # Wrap fetch_video_details in try-except
711+ # try:
712+ # logger.info("Fetching video details...")
713+ # details = await fetch_video_details(normalized_url)
714+ # details['video_url'] = normalized_url
715+ # video_info_message = create_video_info_message(details)
716+
717+ # # Only send if config says so
718+ # if send_video_info:
719+ # for part in split_message(video_info_message):
720+ # await bot.send_message(
721+ # chat_id=update.effective_chat.id,
722+ # text=f"<code>{part}</code>",
723+ # parse_mode='HTML'
724+ # )
725+
726+ # except Exception as e:
727+ # error_message = str(e)
728+ # logger.error(f"An error occurred while fetching video details: {error_message}")
729+ # # await bot.send_message(chat_id=update.effective_chat.id, text=f"❌ Error: {error_message}")
730+ # await bot.send_message(
731+ # chat_id=update.effective_chat.id,
732+ # text=f"❌ Error: {error_message}",
733+ # disable_web_page_preview=True
734+ # )
735+ # continue # Skip to the next URL if any
736+
737+ # If we do want to wait after any attempt:
738+ if desc_fetch_delay > 0 :
739+ logger .info (f"Waiting { desc_fetch_delay } second(s) after fetching description..." )
740+ await asyncio .sleep (desc_fetch_delay )
674741
675742 await bot .send_message (chat_id = update .effective_chat .id , text = "📥 Fetching the audio track..." )
676743
0 commit comments