springwater commited on
Commit
8626295
Β·
verified Β·
1 Parent(s): f6db359

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from youtubesearchpython import VideosSearch
2
+ import gradio as gr
3
+
4
+ def search_youtube_videos(keyword, limit=5):
5
+ videos_search = VideosSearch(keyword, limit=limit)
6
+ results = videos_search.result()
7
+
8
+ video_urls = [video['link'] for video in results['result']]
9
+ return video_urls
10
+
11
+ def gradio_interface(keyword):
12
+ video_urls = search_youtube_videos(keyword, limit=5)
13
+ return "\n".join(video_urls)
14
+
15
+ interface = gr.Interface(
16
+ fn=gradio_interface,
17
+ inputs=gr.Textbox(label="검색 ν‚€μ›Œλ“œλ₯Ό μž…λ ₯ν•˜μ„Έμš”"),
18
+ outputs=gr.Textbox(label="κ²€μƒ‰λœ 유튜브 λ™μ˜μƒ URL"),
19
+ title="유튜브 검색 λ„μš°λ―Έ",
20
+ description="ν‚€μ›Œλ“œλ₯Ό μž…λ ₯ν•˜λ©΄ μœ νŠœλΈŒμ—μ„œ ν•΄λ‹Ή ν‚€μ›Œλ“œλ‘œ κ²€μƒ‰ν•œ ν›„ λ™μ˜μƒ URL을 λ³΄μ—¬μ€λ‹ˆλ‹€."
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ interface.launch()