Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,18 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
|
4 |
def download_video(video_url):
|
5 |
try:
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
return f"β
Downloaded: {video_title}"
|
10 |
except Exception as e:
|
11 |
return f"β Error: {str(e)}"
|
|
|
1 |
+
import yt_dlp
|
2 |
import gradio as gr
|
3 |
|
4 |
def download_video(video_url):
|
5 |
try:
|
6 |
+
# Set download options
|
7 |
+
ydl_opts = {
|
8 |
+
'outtmpl': '%(title)s.%(ext)s', # Save file with video title as the name
|
9 |
+
'format': 'best', # Download the best available format
|
10 |
+
}
|
11 |
+
|
12 |
+
# Download the video
|
13 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
14 |
+
info_dict = ydl.extract_info(video_url, download=True)
|
15 |
+
video_title = info_dict.get('title', 'Video')
|
16 |
return f"β
Downloaded: {video_title}"
|
17 |
except Exception as e:
|
18 |
return f"β Error: {str(e)}"
|