Update app.py
Browse files
app.py
CHANGED
|
@@ -5,19 +5,24 @@ def upload_to_litterbox(video_file):
|
|
| 5 |
"""
|
| 6 |
Uploads a video file to Litterbox and returns the direct URL.
|
| 7 |
"""
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
with gr.Blocks() as demo:
|
| 23 |
gr.Markdown("## Upload Video to Litterbox / Catbox")
|
|
|
|
| 5 |
"""
|
| 6 |
Uploads a video file to Litterbox and returns the direct URL.
|
| 7 |
"""
|
| 8 |
+
try:
|
| 9 |
+
with open(video_file.name, "rb") as f:
|
| 10 |
+
files = {"fileToUpload": (video_file.name, f, "video/mp4")}
|
| 11 |
+
data = {"reqtype": "fileupload"}
|
| 12 |
+
|
| 13 |
+
resp = requests.post(
|
| 14 |
+
"https://litter.catbox.moe/resources/internals/api.php",
|
| 15 |
+
files=files,
|
| 16 |
+
data=data
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if resp.status_code == 200 and resp.text.startswith("https://"):
|
| 20 |
+
return resp.text
|
| 21 |
+
else:
|
| 22 |
+
return f"Upload failed: {resp.status_code} - {resp.text}"
|
| 23 |
+
|
| 24 |
+
except Exception as e:
|
| 25 |
+
return f"Error: {e}"
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
gr.Markdown("## Upload Video to Litterbox / Catbox")
|