seawolf2357 commited on
Commit
e1097ba
โ€ข
1 Parent(s): 294797a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
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 = 'YOUR_PEXELS_API_KEY' # 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
- videos_urls = [{"url": video['url'], "image": video['image']} for video in data['videos']]
 
 
 
 
 
 
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 ๋™์˜์ƒ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ํ‘œ์‹œ ํ•จ์ˆ˜