Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,23 @@
|
|
1 |
-
|
2 |
-
|
3 |
import gradio as gr
|
4 |
import yt_dlp
|
5 |
|
6 |
def download_video(url):
|
7 |
ydl_opts = {
|
8 |
'format': 'best',
|
9 |
-
'outtmpl': '
|
10 |
}
|
11 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
12 |
info_dict = ydl.extract_info(url, download=True)
|
13 |
video_title = info_dict.get('title', None)
|
14 |
-
|
|
|
15 |
|
16 |
-
|
17 |
fn=download_video,
|
18 |
-
inputs=gr.Textbox(
|
19 |
-
outputs=
|
20 |
-
title
|
21 |
-
description
|
22 |
-
|
23 |
)
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import yt_dlp
|
3 |
|
4 |
def download_video(url):
|
5 |
ydl_opts = {
|
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 |
+
video_filename = ydl.prepare_filename(info_dict)
|
13 |
+
return video_filename
|
14 |
|
15 |
+
interface = gr.Interface(
|
16 |
fn=download_video,
|
17 |
+
inputs=gr.inputs.Textbox(lines=1, placeholder="Enter video URL here..."),
|
18 |
+
outputs="text",
|
19 |
+
title="Video Downloader",
|
20 |
+
description="Enter a video URL from a supported site to download the video."
|
|
|
21 |
)
|
22 |
|
23 |
+
interface.launch()
|
|
|
|
|
|