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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -7,6 +7,20 @@ import re
7
  from moviepy.editor import VideoFileClip
8
  from moviepy.audio.AudioClip import AudioClip
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Pexels ์ด๋ฏธ์ง€ ๊ฒ€์ƒ‰ ํ•จ์ˆ˜
11
  def search_pexels_images(query):
12
  API_KEY = '5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62'
@@ -180,4 +194,17 @@ with gr.Blocks() as app:
180
  outputs=images_output
181
  )
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  app.launch(debug=True)
 
7
  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 ๋™์˜์ƒ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ํ‘œ์‹œ ํ•จ์ˆ˜
20
+ def show_video_search_results(query):
21
+ videos_urls = search_pexels_videos(query)
22
+ return videos_urls
23
+
24
  # Pexels ์ด๋ฏธ์ง€ ๊ฒ€์ƒ‰ ํ•จ์ˆ˜
25
  def search_pexels_images(query):
26
  API_KEY = '5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62'
 
194
  outputs=images_output
195
  )
196
 
197
+ with gr.TabItem("FREE Video Search"):
198
+ with gr.Column():
199
+ gr.Markdown("### FREE Video Search")
200
+ video_search_query = gr.Textbox(label="๋น„๋””์˜ค ๊ฒ€์ƒ‰")
201
+ video_search_btn = gr.Button("๊ฒ€์ƒ‰")
202
+ videos_output = gr.Gallery(label="๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ ๋™์˜์ƒ", show_label=False)
203
+ video_search_btn.click(
204
+ fn=show_video_search_results,
205
+ inputs=video_search_query,
206
+ outputs=videos_output
207
+ )
208
+
209
+
210
  app.launch(debug=True)