fix: detect platform on video create, remove hardcoded twitter default
This commit is contained in:
@@ -12,7 +12,7 @@ from app.schemas import DownloadRequest, DownloadResponse, TaskStatus
|
||||
from app.database import get_db, async_session
|
||||
from app.models import Video, DownloadLog
|
||||
from app.auth import get_current_user, optional_auth
|
||||
from app.services.downloader import download_video, get_video_path
|
||||
from app.services.downloader import download_video, get_video_path, detect_platform
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix="/api", tags=["download"])
|
||||
@@ -154,7 +154,8 @@ async def start_download(req: DownloadRequest, background_tasks: BackgroundTasks
|
||||
return DownloadResponse(task_id=existing.task_id, status="done")
|
||||
|
||||
task_id = str(uuid.uuid4())[:8]
|
||||
video = Video(task_id=task_id, url=req.url, quality=req.quality, format_id=req.format_id, status="pending")
|
||||
video = Video(task_id=task_id, url=req.url, quality=req.quality, format_id=req.format_id,
|
||||
status="pending", platform=detect_platform(req.url))
|
||||
db.add(video)
|
||||
await db.commit()
|
||||
background_tasks.add_task(_do_download, task_id, req.url, req.format_id)
|
||||
|
||||
Reference in New Issue
Block a user