Create app.py
Browse files
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()
|