Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,18 +6,24 @@ def download_video(url):
|
|
6 |
'format': 'best',
|
7 |
'outtmpl': 'downloads/%(title)s.%(ext)s',
|
8 |
}
|
|
|
9 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
10 |
info_dict = ydl.extract_info(url, download=True)
|
11 |
video_title = info_dict.get('title', None)
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
19 |
title="Video Downloader",
|
20 |
-
description="Enter
|
21 |
)
|
22 |
|
23 |
-
interface
|
|
|
|
6 |
'format': 'best',
|
7 |
'outtmpl': 'downloads/%(title)s.%(ext)s',
|
8 |
}
|
9 |
+
|
10 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
11 |
info_dict = ydl.extract_info(url, download=True)
|
12 |
video_title = info_dict.get('title', None)
|
13 |
+
file_extension = info_dict.get('ext', None)
|
14 |
+
file_name = f"{video_title}.{file_extension}"
|
15 |
+
file_path = f"downloads/{file_name}"
|
16 |
+
|
17 |
+
return file_path
|
18 |
|
19 |
+
# Create a Gradio interface
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=download_video,
|
22 |
+
inputs="text",
|
23 |
+
outputs="file",
|
24 |
title="Video Downloader",
|
25 |
+
description="Enter the URL of the video you want to download."
|
26 |
)
|
27 |
|
28 |
+
# Launch the interface
|
29 |
+
iface.launch()
|