INNER CODE UNIT · Python

download_video

liyupi/free-video-downloader · backend/main.py:85

async def download_video(req: DownloadRequest):
    """服务端下载视频后提供文件下载(抖音走专用模块)"""
    try:
        loop = asyncio.get_event_loop()
        if is_douyin_url(req.url):
            result = await loop.run_in_executor(None, douyin_parser.download, req.url)
        else:
            result = await loop.run_in_executor(
                None, downloader.download_video, req.url, req.format_id
            )
        filepath = result["filepath"]
        if not os.path.exists(filepath):
            raise HTTPException(status_code=500, detail="下载的文件不存在")

        return FileResponse(
            path=filepath,
            filename=result["filename"],
            media_type="application/octet-stream",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…