Update app.py
Browse files
app.py
CHANGED
@@ -12,40 +12,57 @@ def search_youtube_videos(keyword, limit=5, order='date'):
|
|
12 |
video_urls = [video['link'] for video in results['result']]
|
13 |
return video_urls
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
def
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
summaries.append(f"URL: {url}\nSummary: {summary}\n")
|
37 |
-
except Exception as e:
|
38 |
-
summaries.append(f"URL: {url}\nError: {str(e)}\n")
|
39 |
-
return "\n".join(summaries)
|
40 |
|
41 |
-
#
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
-
interface.launch()
|
49 |
|
50 |
|
51 |
# from youtubesearchpython import VideosSearch
|
|
|
12 |
video_urls = [video['link'] for video in results['result']]
|
13 |
return video_urls
|
14 |
|
15 |
+
# Gradio ์ธํฐํ์ด์ค ์ค์
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=search_youtube_videos,
|
18 |
+
inputs=[
|
19 |
+
gr.Textbox(label="๊ฒ์ ํค์๋", placeholder="YouTube์์ ๊ฒ์ํ ํค์๋๋ฅผ ์
๋ ฅํ์ธ์."),
|
20 |
+
gr.Slider(minimum=1, maximum=10, default=5, label="๊ฒ์ ๊ฒฐ๊ณผ ๊ฐ์"),
|
21 |
+
gr.Radio(choices=['date', 'relevance', 'rating', 'title', 'viewCount'], label="์ ๋ ฌ ์์", default='date')
|
22 |
+
],
|
23 |
+
outputs=gr.Textbox(label="๊ฒ์ ๊ฒฐ๊ณผ"),
|
24 |
+
title="YouTube ๋น๋์ค ๊ฒ์",
|
25 |
+
description="YouTube์์ ๋น๋์ค๋ฅผ ๊ฒ์ํ๊ณ ๊ฒฐ๊ณผ์ ๋งํฌ๋ฅผ ๋ฐ์๋ณด์ธ์."
|
26 |
+
)
|
27 |
|
28 |
+
# Gradio ์ฑ ์คํ
|
29 |
+
if __name__ == "__main__":
|
30 |
+
interface.launch()
|
31 |
+
|
32 |
+
# def get_transcript(url):
|
33 |
+
# loader = YoutubeLoader()
|
34 |
+
# transcript = loader.load(url)
|
35 |
+
# text = " ".join([segment['text'] for segment in transcript['segments']])
|
36 |
+
# return text
|
37 |
|
38 |
+
# def summarize_text(text):
|
39 |
+
# response = openai.Completion.create(
|
40 |
+
# engine="text-davinci-003",
|
41 |
+
# prompt=f"์์ฝ: {text}",
|
42 |
+
# max_tokens=150
|
43 |
+
# )
|
44 |
+
# return response.choices[0].text.strip()
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
# def process_keyword(keyword):
|
47 |
+
# video_urls = search_youtube_videos(keyword)
|
48 |
+
# summaries = []
|
49 |
+
# for url in video_urls:
|
50 |
+
# try:
|
51 |
+
# text = get_transcript(url)
|
52 |
+
# summary = summarize_text(text)
|
53 |
+
# summaries.append(f"URL: {url}\nSummary: {summary}\n")
|
54 |
+
# except Exception as e:
|
55 |
+
# summaries.append(f"URL: {url}\nError: {str(e)}\n")
|
56 |
+
# return "\n".join(summaries)
|
57 |
+
|
58 |
+
# # Gradio ์ธํฐํ์ด์ค
|
59 |
+
# interface = gr.Interface(
|
60 |
+
# fn=process_keyword,
|
61 |
+
# inputs=gr.Textbox(label="๊ฒ์ ํค์๋"),
|
62 |
+
# outputs=gr.Textbox(label="๊ฒฐ๊ณผ"),
|
63 |
+
# )
|
64 |
|
65 |
+
# interface.launch()
|
66 |
|
67 |
|
68 |
# from youtubesearchpython import VideosSearch
|