JUNGU commited on
Commit
2e18f1a
·
verified ·
1 Parent(s): 2af23ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -1,14 +1,28 @@
1
- from youtube_video import download_youtube_video
2
  import gradio as gr
 
3
 
4
- def app(video_link):
5
- video_path = download_youtube_video(video_link)
6
- return video_path
 
 
7
 
8
- interface = gr.Interface(
9
- fn=app,
10
- inputs=gr.Textbox(label="Enter YouTube link 🔗 To Download Video⬇️ "),
11
- outputs=gr.Video(label = "video_path")
 
 
 
 
 
 
 
 
 
 
 
12
  )
13
 
14
- interface.launch(debug=True)
 
 
 
1
  import gradio as gr
2
+ import yt_dlp as youtube_dl
3
 
4
+ def download_youtube_videos(urls):
5
+ ydl_opts = {
6
+ 'format': 'best',
7
+ 'outtmpl': '%(title)s.%(ext)s',
8
+ }
9
 
10
+ with youtube_dl.YoutubeDL(ydl_opts) as ydl:
11
+ ydl.download(urls)
12
+ return "다운로드 완료!"
13
+
14
+ def start_download(urls):
15
+ url_list = urls.split('\n')
16
+ download_youtube_videos(url_list)
17
+ return "모든 비디오가 다운로드 되었습니다."
18
+
19
+ iface = gr.Interface(
20
+ fn=start_download,
21
+ inputs=gr.inputs.Textbox(lines=10, placeholder="여기에 YouTube 링크를 입력하세요 (각 링크를 줄바꿈으로 구분)"),
22
+ outputs="text",
23
+ title="YouTube 비디오 다운로드",
24
+ description="여러 YouTube 비디오 링크를 입력하고 다운로드 버튼을 눌러 비디오를 다운로드하세요."
25
  )
26
 
27
+ if __name__ == "__main__":
28
+ iface.launch()