Update app.py
Browse files52 unmodified lines5354555657585960616263646556575859666768697071727374757677787952 unmodified lines """ yt = YouTube(youtube_url)
# List available caption tracks caption_tracks = yt.caption_tracks available_languages = [track.language_code for track in caption_tracks]
if available_languages: st.write(f"Available caption languages: {', '.join(available_languages)}")
# You can set a fallback language or prompt the user to select language = 'en' # Change this to any available language from the list # Check if captions are available in English (you can modify this language) if 'en' in yt.captions: caption = yt.captions['en'] return caption.generate_srt_captions() # Return captions in SRT format # Check if the chosen language exists in the video if language in yt.captions: caption = yt.captions[language] return caption.generate_srt_captions() # Return captions in SRT format else: return f"Captions not available in the selected language ({language})." else: return "No captions available for this video."
# YouTube video URL inputyoutube_url = st.text_input( "Enter the YouTube video link",app.py+18-4