Update app.py
Browse files
app.py
CHANGED
|
@@ -39,14 +39,16 @@ def initialize_agent():
|
|
| 39 |
# Initialize the agent
|
| 40 |
multimodal_Agent = initialize_agent()
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
def download_youtube_video(youtube_url):
|
| 44 |
"""
|
| 45 |
Downloads a YouTube video using yt-dlp with cookies for authentication.
|
| 46 |
-
|
| 47 |
Parameters:
|
| 48 |
- youtube_url: The URL of the YouTube video.
|
| 49 |
-
|
| 50 |
Returns:
|
| 51 |
- The path to the downloaded video file.
|
| 52 |
"""
|
|
@@ -57,10 +59,10 @@ def download_youtube_video(youtube_url):
|
|
| 57 |
# yt-dlp options
|
| 58 |
ydl_opts = {
|
| 59 |
'format': 'bestvideo+bestaudio/best', # Download best video and audio
|
| 60 |
-
'outtmpl': temp_video_path,
|
| 61 |
-
'merge_output_format': 'mp4',
|
| 62 |
-
'cookies': 'cookies.txt',
|
| 63 |
-
'quiet': True,
|
| 64 |
}
|
| 65 |
|
| 66 |
try:
|
|
@@ -73,6 +75,7 @@ def download_youtube_video(youtube_url):
|
|
| 73 |
except Exception as e:
|
| 74 |
raise RuntimeError(f"An error occurred while downloading the video: {str(e)}")
|
| 75 |
|
|
|
|
| 76 |
# YouTube video URL input
|
| 77 |
youtube_url = st.text_input(
|
| 78 |
"Enter the YouTube video link",
|
|
|
|
| 39 |
# Initialize the agent
|
| 40 |
multimodal_Agent = initialize_agent()
|
| 41 |
|
| 42 |
+
import tempfile
|
| 43 |
+
from yt_dlp import YoutubeDL
|
| 44 |
+
|
| 45 |
def download_youtube_video(youtube_url):
|
| 46 |
"""
|
| 47 |
Downloads a YouTube video using yt-dlp with cookies for authentication.
|
| 48 |
+
|
| 49 |
Parameters:
|
| 50 |
- youtube_url: The URL of the YouTube video.
|
| 51 |
+
|
| 52 |
Returns:
|
| 53 |
- The path to the downloaded video file.
|
| 54 |
"""
|
|
|
|
| 59 |
# yt-dlp options
|
| 60 |
ydl_opts = {
|
| 61 |
'format': 'bestvideo+bestaudio/best', # Download best video and audio
|
| 62 |
+
'outtmpl': temp_video_path, # Output file path
|
| 63 |
+
'merge_output_format': 'mp4', # Merge into MP4 format
|
| 64 |
+
'cookies': 'cookies.txt', # Path to the cookies file
|
| 65 |
+
'quiet': True, # Suppress yt-dlp output
|
| 66 |
}
|
| 67 |
|
| 68 |
try:
|
|
|
|
| 75 |
except Exception as e:
|
| 76 |
raise RuntimeError(f"An error occurred while downloading the video: {str(e)}")
|
| 77 |
|
| 78 |
+
|
| 79 |
# YouTube video URL input
|
| 80 |
youtube_url = st.text_input(
|
| 81 |
"Enter the YouTube video link",
|