Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Commit
โข
e1097ba
1
Parent(s):
294797a
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,18 @@ from moviepy.editor import VideoFileClip
|
|
8 |
from moviepy.audio.AudioClip import AudioClip
|
9 |
|
10 |
def search_pexels_videos(query):
|
11 |
-
API_KEY = '
|
12 |
url = f"https://api.pexels.com/videos/search?query={query}&per_page=10"
|
13 |
headers = {"Authorization": API_KEY}
|
14 |
response = requests.get(url, headers=headers)
|
15 |
data = response.json()
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
return videos_urls
|
18 |
|
19 |
# Pexels ๋์์ ๊ฒ์ ๊ฒฐ๊ณผ ํ์ ํจ์
|
|
|
8 |
from moviepy.audio.AudioClip import AudioClip
|
9 |
|
10 |
def search_pexels_videos(query):
|
11 |
+
API_KEY = '5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62' # ์ค์ Pexels API ํค๋ก ๊ต์ฒดํ์ธ์.
|
12 |
url = f"https://api.pexels.com/videos/search?query={query}&per_page=10"
|
13 |
headers = {"Authorization": API_KEY}
|
14 |
response = requests.get(url, headers=headers)
|
15 |
data = response.json()
|
16 |
+
|
17 |
+
# 'videos' ํค์ ์กด์ฌ ์ฌ๋ถ๋ฅผ ํ์ธํ๊ณ , ์กด์ฌํ์ง ์์ ๊ฒฝ์ฐ ๋น ๋ฆฌ์คํธ ๋ฐํ
|
18 |
+
if 'videos' in data:
|
19 |
+
videos_urls = [{"url": video['url'], "image": video['image']} for video in data['videos']]
|
20 |
+
else:
|
21 |
+
print("No 'videos' key in response data. Returning empty list.")
|
22 |
+
videos_urls = []
|
23 |
return videos_urls
|
24 |
|
25 |
# Pexels ๋์์ ๊ฒ์ ๊ฒฐ๊ณผ ํ์ ํจ์
|