File size: 819 Bytes
8626295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from youtubesearchpython import VideosSearch
import gradio as gr

def search_youtube_videos(keyword, limit=5):
    videos_search = VideosSearch(keyword, limit=limit)
    results = videos_search.result()

    video_urls = [video['link'] for video in results['result']]
    return video_urls

def gradio_interface(keyword):
    video_urls = search_youtube_videos(keyword, limit=5)
    return "\n".join(video_urls)

interface = gr.Interface(
    fn=gradio_interface,
    inputs=gr.Textbox(label="검색 ν‚€μ›Œλ“œλ₯Ό μž…λ ₯ν•˜μ„Έμš”"),
    outputs=gr.Textbox(label="κ²€μƒ‰λœ 유튜브 λ™μ˜μƒ URL"),
    title="유튜브 검색 λ„μš°λ―Έ",
    description="ν‚€μ›Œλ“œλ₯Ό μž…λ ₯ν•˜λ©΄ μœ νŠœλΈŒμ—μ„œ ν•΄λ‹Ή ν‚€μ›Œλ“œλ‘œ κ²€μƒ‰ν•œ ν›„ λ™μ˜μƒ URL을 λ³΄μ—¬μ€λ‹ˆλ‹€."
)

if __name__ == "__main__":
    interface.launch()