Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,13 +56,14 @@ def transcribe_audio(audio_file):
|
|
56 |
except sr.RequestError:
|
57 |
return "Could not request results from Google Speech Recognition service."
|
58 |
|
59 |
-
# Function to extract video download URL using yt-dlp
|
60 |
-
def extract_video_url(youtube_url):
|
61 |
try:
|
62 |
-
# Set up yt-dlp options
|
63 |
ydl_opts = {
|
64 |
'format': 'bestaudio/best', # Get best audio or best video
|
65 |
'quiet': True, # Suppress output
|
|
|
66 |
}
|
67 |
|
68 |
# Create a yt-dlp object with the provided options
|
@@ -209,11 +210,13 @@ elif tab == "YouTube":
|
|
209 |
st.write("""This app allows you to download YouTube videos in various formats. Simply enter the YouTube URL below and click "Get Download Link".""")
|
210 |
|
211 |
youtube_url = st.text_input("Enter YouTube Video URL", "https://www.youtube.com/watch?v=YPvtz1lHRiw")
|
|
|
|
|
212 |
|
213 |
if st.button("Get Download Link"):
|
214 |
if youtube_url:
|
215 |
try:
|
216 |
-
download_url = extract_video_url(youtube_url)
|
217 |
st.success("Download link generated successfully!")
|
218 |
st.write("Click below to download the video:")
|
219 |
st.markdown(f"[Download Video]({download_url})", unsafe_allow_html=True)
|
|
|
56 |
except sr.RequestError:
|
57 |
return "Could not request results from Google Speech Recognition service."
|
58 |
|
59 |
+
# Function to extract video download URL using yt-dlp with cookies
|
60 |
+
def extract_video_url(youtube_url, cookies_file=None):
|
61 |
try:
|
62 |
+
# Set up yt-dlp options with cookies if provided
|
63 |
ydl_opts = {
|
64 |
'format': 'bestaudio/best', # Get best audio or best video
|
65 |
'quiet': True, # Suppress output
|
66 |
+
'cookiefile': cookies_file if cookies_file else None, # Use cookies if provided
|
67 |
}
|
68 |
|
69 |
# Create a yt-dlp object with the provided options
|
|
|
210 |
st.write("""This app allows you to download YouTube videos in various formats. Simply enter the YouTube URL below and click "Get Download Link".""")
|
211 |
|
212 |
youtube_url = st.text_input("Enter YouTube Video URL", "https://www.youtube.com/watch?v=YPvtz1lHRiw")
|
213 |
+
|
214 |
+
cookies_file = st.file_uploader("Upload Cookies File", type=["txt"])
|
215 |
|
216 |
if st.button("Get Download Link"):
|
217 |
if youtube_url:
|
218 |
try:
|
219 |
+
download_url = extract_video_url(youtube_url, cookies_file=cookies_file)
|
220 |
st.success("Download link generated successfully!")
|
221 |
st.write("Click below to download the video:")
|
222 |
st.markdown(f"[Download Video]({download_url})", unsafe_allow_html=True)
|