Spaces:
Running
on
Zero
Running
on
Zero
Update my_functions.py
Browse files- my_functions.py +0 -27
my_functions.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
import yfinance as yf
|
2 |
-
# youtube-search-python ์ถ๊ฐ ์ํฌํธ
|
3 |
-
from youtubesearchpython import VideosSearch
|
4 |
|
5 |
product_catalog = {
|
6 |
"807ZPKBL9V": "SuperWidget",
|
@@ -23,28 +21,3 @@ def get_stock_price(ticker: str) -> float:
|
|
23 |
return data['Close'].iloc[-1]
|
24 |
return float('nan')
|
25 |
|
26 |
-
def search_youtube(query: str) -> str:
|
27 |
-
"""
|
28 |
-
Searches YouTube for the given query and returns top 3 video titles & links.
|
29 |
-
"""
|
30 |
-
# youtube-search-python ์ด์ฉ
|
31 |
-
try:
|
32 |
-
videosSearch = VideosSearch(query, limit=3)
|
33 |
-
results = videosSearch.result()["result"] # ์ค์ ๊ฒ์ ๊ฒฐ๊ณผ
|
34 |
-
|
35 |
-
if not results:
|
36 |
-
return "No videos found for your query."
|
37 |
-
|
38 |
-
# ๊ฒฐ๊ณผ์์ ํ์ดํ๊ณผ ๋งํฌ๋ฅผ ์ถ์ถ
|
39 |
-
formatted_list = []
|
40 |
-
for idx, item in enumerate(results, start=1):
|
41 |
-
title = item.get("title", "No Title")
|
42 |
-
link = item.get("link", "#")
|
43 |
-
formatted_list.append(f"{idx}) [{title}]({link})")
|
44 |
-
|
45 |
-
# ์ฌ๋ฌ ์ค๋ก ๋ฌถ์ด์ ๋ฐํ
|
46 |
-
return "\n".join(formatted_list)
|
47 |
-
|
48 |
-
except Exception as e:
|
49 |
-
# ์ด๋ค ์๋ฌ๋ ๋ฐ์ ์ ์์ ํ๊ฒ ๋ฉ์์ง ๋ฐํ
|
50 |
-
return f"Error searching YouTube: {str(e)}"
|
|
|
1 |
import yfinance as yf
|
|
|
|
|
2 |
|
3 |
product_catalog = {
|
4 |
"807ZPKBL9V": "SuperWidget",
|
|
|
21 |
return data['Close'].iloc[-1]
|
22 |
return float('nan')
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|