Spaces:
Running
on
Zero
Running
on
Zero
Update core/input_handler.py
Browse files- core/input_handler.py +23 -0
core/input_handler.py
CHANGED
@@ -120,6 +120,29 @@ def validate_video(path):
|
|
120 |
logger.error(f"Error validating video: {e}")
|
121 |
return False, str(e)
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
# Input Resolution
|
124 |
def resolve_input(mode, media_upload, url):
|
125 |
"""
|
|
|
120 |
logger.error(f"Error validating video: {e}")
|
121 |
return False, str(e)
|
122 |
|
123 |
+
def show_preview_from_upload(files):
|
124 |
+
if not files:
|
125 |
+
return gr.update(visible=False), gr.update(visible=False)
|
126 |
+
|
127 |
+
file = files[0]
|
128 |
+
name = file.name.lower()
|
129 |
+
if name.endswith((".png", ".jpg", ".jpeg", ".webp")):
|
130 |
+
return gr.update(value=file, visible=True), gr.update(visible=False)
|
131 |
+
elif name.endswith((".mp4", ".mov", ".avi")):
|
132 |
+
return gr.update(visible=False), gr.update(value=file, visible=True)
|
133 |
+
return gr.update(visible=False), gr.update(visible=False)
|
134 |
+
|
135 |
+
def show_preview_from_url(url):
|
136 |
+
if not url:
|
137 |
+
return gr.update(visible=False), gr.update(visible=False)
|
138 |
+
|
139 |
+
url = url.strip().lower()
|
140 |
+
if url.endswith((".png", ".jpg", ".jpeg", ".webp")):
|
141 |
+
return gr.update(value=url, visible=True), gr.update(visible=False)
|
142 |
+
elif url.endswith((".mp4", ".mov", ".avi")):
|
143 |
+
return gr.update(visible=False), gr.update(value=url, visible=True)
|
144 |
+
return gr.update(visible=False), gr.update(visible=False)
|
145 |
+
|
146 |
# Input Resolution
|
147 |
def resolve_input(mode, media_upload, url):
|
148 |
"""
|