Update app.py
Browse files14 unmodified lines15161718192021222315 unmodified lines3940414243444546474814 unmodified lines"""# Extract video ID from YouTube URL (for both regular videos and Shorts)if "shorts" in youtube_url:video_id = youtube_url.split("shorts/")[-1].split("?")[0]else:video_id = youtube_url.split("v=")[-1].split("&")[0]try:# Fetch transcript for the video15 unmodified lines)if youtube_url:try:with st.spinner("Fetching and processing the YouTube video..."):# Get captions using youtube-transcript-apicaptions = get_youtube_captions(youtube_url)# Check if captions are availableif "Error" not in captions:14 unmodified lines151617181920212223242526272815 unmodified lines4445464748495051525354555614 unmodified lines"""# Extract video ID from YouTube URL (for both regular videos and Shorts)if "shorts" in youtube_url:# For YouTube Shorts, extract the video ID after "shorts/"video_id = youtube_url.split("shorts/")[-1].split("?")[0]else:# For regular YouTube videos, extract the video ID after "v="video_id = youtube_url.split("v=")[-1].split("&")[0]# Print extracted video ID for debuggingprint(f"Extracted Video ID: {video_id}")try:# Fetch transcript for the video15 unmodified lines)if youtube_url:# Clean URL before passing to the function (remove extra parts)youtube_url_cleaned = youtube_url.split("?")[0] # Remove URL parameterstry:with st.spinner("Fetching and processing the YouTube video..."):# Get captions using youtube-transcript-apicaptions = get_youtube_captions(youtube_url_cleaned)# Check if captions are availableif "Error" not in captions:
app.py+9-1