JUNGU commited on
Commit
f231b32
·
1 Parent(s): 3a86b56

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +25 -0
App.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import youtube_dl
3
+
4
+ def download_video(url):
5
+ ydl_opts = {
6
+ 'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4',
7
+ 'outtmpl': '%(id)s.%(ext)s',
8
+ }
9
+
10
+ with youtube_dl.YoutubeDL(ydl_opts) as ydl:
11
+ ydl.download([url])
12
+ info_dict = ydl.extract_info(url, download=False)
13
+ filename = ydl.prepare_filename(info_dict)
14
+ return filename
15
+
16
+ iface = gr.Interface(
17
+ fn=download_video,
18
+ inputs=gr.inputs.Textbox(placeholder="Enter YouTube URL here..."),
19
+ outputs="text",
20
+ title="YouTube Video Downloader",
21
+ description="Enter a YouTube URL to download it as an MP4 file."
22
+ )
23
+
24
+ if __name__ == "__main__":
25
+ iface.launch()