Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,8 +44,33 @@ setup_eval_logging()
|
|
| 44 |
|
| 45 |
# ๋ฒ์ญ๊ธฐ ๋ฐ Pixabay API ์ค์
|
| 46 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
PIXABAY_API_KEY = "33492762-a28a596ec4f286f84cd328b17"
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# CSS ์คํ์ผ ์ ์
|
| 51 |
custom_css = """
|
|
|
|
| 44 |
|
| 45 |
# ๋ฒ์ญ๊ธฐ ๋ฐ Pixabay API ์ค์
|
| 46 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
import requests
|
| 51 |
+
|
| 52 |
+
def search_pixabay_videos(query, api_key):
|
| 53 |
+
base_url = "https://pixabay.com/api/videos/"
|
| 54 |
+
params = {
|
| 55 |
+
"key": api_key,
|
| 56 |
+
"q": query,
|
| 57 |
+
"per_page": 80
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
response = requests.get(base_url, params=params)
|
| 61 |
+
if response.status_code == 200:
|
| 62 |
+
data = response.json()
|
| 63 |
+
return [video['videos']['large']['url'] for video in data.get('hits', [])]
|
| 64 |
+
return []
|
| 65 |
+
|
| 66 |
+
# ๋ฉ์ธ ์ฝ๋์์ pixabay ๊ด๋ จ ๋ถ๋ถ ์์
|
| 67 |
PIXABAY_API_KEY = "33492762-a28a596ec4f286f84cd328b17"
|
| 68 |
+
|
| 69 |
+
def search_videos(query):
|
| 70 |
+
query = translate_prompt(query)
|
| 71 |
+
return search_pixabay_videos(query, PIXABAY_API_KEY)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
|
| 75 |
# CSS ์คํ์ผ ์ ์
|
| 76 |
custom_css = """
|