Update app.py
Browse files14 unmodified lines151617181920212223242526272815 unmodified lines444546474849505152455354555614 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 debugging print(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 parameters try: with st.spinner("Fetching and processing the YouTube video..."): # Get captions using youtube-transcript-api captions = get_youtube_captions(youtube_url) captions = get_youtube_captions(youtube_url_cleaned)
# Check if captions are available if "Error" not in captions:app.py+9-1