Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,6 +156,23 @@ def _ffprobe_streams(path: str) -> Optional[dict]:
|
|
| 156 |
except Exception:
|
| 157 |
return None
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
def worker(url: str, prompt: str, key: str, progress=gr.Progress()):
|
| 160 |
try:
|
| 161 |
if not url: return ("error", "**Error:** No URL provided.", "")
|
|
|
|
| 156 |
except Exception:
|
| 157 |
return None
|
| 158 |
|
| 159 |
+
def determine_media_type(src: str, progress=None) -> Tuple[bool, bool]:
|
| 160 |
+
is_image = is_video = False
|
| 161 |
+
ext = ext_from_src(src)
|
| 162 |
+
if ext in IMAGE_EXTS:
|
| 163 |
+
is_image = True
|
| 164 |
+
if ext in VIDEO_EXTS:
|
| 165 |
+
is_video = True
|
| 166 |
+
if is_remote(src):
|
| 167 |
+
head = safe_head(src)
|
| 168 |
+
if head:
|
| 169 |
+
ctype = (head.headers.get("content-type") or "").lower()
|
| 170 |
+
if ctype.startswith("image/"):
|
| 171 |
+
is_image, is_video = True, False
|
| 172 |
+
elif ctype.startswith("video/"):
|
| 173 |
+
is_video, is_image = True, False
|
| 174 |
+
return is_image, is_video
|
| 175 |
+
|
| 176 |
def worker(url: str, prompt: str, key: str, progress=gr.Progress()):
|
| 177 |
try:
|
| 178 |
if not url: return ("error", "**Error:** No URL provided.", "")
|