Blane187 commited on
Commit
eeb7f74
·
verified ·
1 Parent(s): 29ded09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
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': 'downloaded_videos/%(title)s.%(ext)s',
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
- return f"Video '{video_title}' downloaded successfully!"
 
15
 
16
- iface = gr.Interface(
17
  fn=download_video,
18
- inputs=gr.Textbox(label="YouTube URL"),
19
- outputs=gr.Textbox(label="Download Status"),
20
- title = "yt_dlp",
21
- description = "This space was made by [Blane187](https://huggingface.co/Blane187). Please credit me if you use this thing :D"
22
-
23
  )
24
 
25
- iface.launch()
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()