Blane187 commited on
Commit
90be0a7
·
verified ·
1 Parent(s): c247b16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
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
- video_filename = ydl.prepare_filename(info_dict)
13
- return video_filename
 
 
 
14
 
15
- interface = gr.Interface(
16
- fn=download_video,
17
- inputs=gr.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()
 
 
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()