Skip to content

Commit

Permalink
Update youtube2text_web.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mshojaei77 authored Mar 1, 2024
1 parent b149121 commit c9728b1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions youtube2text_web.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import streamlit as st
from youtube_transcript_api import YouTubeTranscriptApi
from yt_dlp import YoutubeDL
Expand Down Expand Up @@ -27,7 +28,7 @@ def get_video_info(video_url):
info = yt.extract_info(video_url, download=False)
return info.get("title", ""), info.get("description", ""), info.get("thumbnails", [])[-1]["url"]

st.title('YouTube Transcript Extractor')
st.title('🎥 YouTube Transcript Extractor')

video_url_input = st.text_input("Enter YouTube Video URL", "")
submit_button = st.button("Extract Transcript")
Expand All @@ -41,9 +42,14 @@ def get_video_info(video_url):
with st.spinner('Fetching transcript...'):
transcript_text = fetch_transcript(video_id)

if video_title: st.markdown(f"## [{video_title}]({video_url})")
if video_thumbnail: st.image(video_thumbnail, caption="Video Thumbnail", use_column_width=True)
if video_description: st.markdown(f" {video_description}")
# Display video title and thumbnail in the main area
if video_title: st.markdown(f"## {video_title}")
# Display video description in the sidebar
with st.sidebar:
if video_title: st.markdown(f"### [{video_title}]({video_url})")
if video_thumbnail: st.image(video_thumbnail, use_column_width=True)
if video_description: st.markdown(f" {video_description}")

st.markdown(f"``` {transcript_text} ```")

except Exception as e:
Expand Down

0 comments on commit c9728b1

Please sign in to comment.