Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,24 +58,29 @@ with gr.Blocks() as demo:
|
|
58 |
label="Clean Video URLs",
|
59 |
choices=[],
|
60 |
interactive=True,
|
61 |
-
allow_custom_value=True
|
62 |
-
value=None
|
63 |
)
|
64 |
video_player = gr.Video(label="Video Player")
|
65 |
|
66 |
def search_and_populate(keywords, api_key, scan_enabled):
|
67 |
urls = fetch_clean_videos(keywords, api_key, scan_enabled)
|
68 |
-
|
|
|
69 |
|
70 |
def update_player(selected_url):
|
71 |
-
|
|
|
72 |
|
73 |
run_btn.click(
|
74 |
fn=search_and_populate,
|
75 |
inputs=[kw_input, key_input, scan_toggle],
|
76 |
outputs=[url_dropdown]
|
77 |
)
|
78 |
-
url_dropdown.change(
|
|
|
|
|
|
|
|
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
demo.launch() # HF Spaces deployment
|
|
|
58 |
label="Clean Video URLs",
|
59 |
choices=[],
|
60 |
interactive=True,
|
61 |
+
allow_custom_value=True
|
|
|
62 |
)
|
63 |
video_player = gr.Video(label="Video Player")
|
64 |
|
65 |
def search_and_populate(keywords, api_key, scan_enabled):
|
66 |
urls = fetch_clean_videos(keywords, api_key, scan_enabled)
|
67 |
+
# Update dropdown with new choices and default selection
|
68 |
+
return gr.Dropdown.update(choices=urls, value=urls[0] if urls else None)
|
69 |
|
70 |
def update_player(selected_url):
|
71 |
+
# Update video component
|
72 |
+
return gr.Video.update(value=selected_url)
|
73 |
|
74 |
run_btn.click(
|
75 |
fn=search_and_populate,
|
76 |
inputs=[kw_input, key_input, scan_toggle],
|
77 |
outputs=[url_dropdown]
|
78 |
)
|
79 |
+
url_dropdown.change(
|
80 |
+
fn=update_player,
|
81 |
+
inputs=[url_dropdown],
|
82 |
+
outputs=[video_player]
|
83 |
+
)
|
84 |
|
85 |
if __name__ == "__main__":
|
86 |
demo.launch() # HF Spaces deployment
|