Spaces:
aiqcamp
/
Running on Zero

aiqcamp commited on
Commit
1354a37
โ€ข
1 Parent(s): f2a7798

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
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
- pixabay_video = Video(PIXABAY_API_KEY)
 
 
 
 
 
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 = """