mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-29 09:18:21 +00:00
servers hate libmagic i guess
This commit is contained in:
@@ -10,13 +10,13 @@ import os
|
|||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
from typing import Dict, Any, Optional
|
from typing import Dict, Any, Optional
|
||||||
|
import mimetypes
|
||||||
|
|
||||||
from fastapi import FastAPI, File, UploadFile, HTTPException, Form
|
from fastapi import FastAPI, File, UploadFile, HTTPException, Form
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
import requests
|
import requests
|
||||||
from jsonpath_ng import jsonpath, parse
|
from jsonpath_ng import jsonpath, parse
|
||||||
from moviepy.editor import ImageClip
|
from moviepy.editor import ImageClip
|
||||||
import magic
|
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
lock = asyncio.Lock() # Create an asyncio lock
|
lock = asyncio.Lock() # Create an asyncio lock
|
||||||
@@ -129,7 +129,7 @@ async def preview_request(request: str = Form(...), input_file: UploadFile = Fil
|
|||||||
with open(temp_filename, "wb") as buffer:
|
with open(temp_filename, "wb") as buffer:
|
||||||
shutil.copyfileobj(input_file.file, buffer)
|
shutil.copyfileobj(input_file.file, buffer)
|
||||||
|
|
||||||
mime_type = magic.from_file(temp_filename, mime=True)
|
mime_type, _ = mimetypes.guess_type(temp_filename)
|
||||||
|
|
||||||
if 'video' in mime_type:
|
if 'video' in mime_type:
|
||||||
input_filename = f"{temp_filename}.mp4"
|
input_filename = f"{temp_filename}.mp4"
|
||||||
|
|||||||
@@ -4,5 +4,4 @@ fastapi~=0.110.0
|
|||||||
python-multipart~=0.0.9
|
python-multipart~=0.0.9
|
||||||
pydantic~=2.6.4
|
pydantic~=2.6.4
|
||||||
jsonpath-ng~=1.6.1
|
jsonpath-ng~=1.6.1
|
||||||
moviepy
|
moviepy
|
||||||
python-magic
|
|
||||||
Reference in New Issue
Block a user