Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Commit
โข
294797a
1
Parent(s):
7990584
Update app.py
Browse files
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)
|