Update app.py
Browse files52 unmodified lines5354555657585960616263646552 unmodified lines"""yt = YouTube(youtube_url)# 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 formatelse:return "No captions available for this video."# YouTube video URL inputyoutube_url = st.text_input("Enter the YouTube video link",52 unmodified lines53545556575859606162636465666768697071727374757677787952 unmodified lines"""yt = YouTube(youtube_url)# List available caption trackscaption_tracks = yt.caption_tracksavailable_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 selectlanguage = 'en' # Change this to any available language from the list# Check if the chosen language exists in the videoif language in yt.captions:caption = yt.captions[language]return caption.generate_srt_captions() # Return captions in SRT formatelse: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