优化 直接使用 现有媒体资源url 如果没有则报错

This commit is contained in:
小肥羊 2026-04-22 16:38:14 +08:00
parent ada94793cb
commit e3c97ef0b2
1 changed files with 19 additions and 17 deletions

View File

@ -394,24 +394,26 @@ namespace VideoAnalysisCore.Controllers
return BadRequest("参数无效");
if(!string.IsNullOrWhiteSpace(task.MediaUrl))
return Ok(task.MediaUrl);
try
{
var videoInfo = await vodClient.GetPlayInfoAsync(new GetPlayInfoRequest()
{
VideoId = task.TagId,
Formats = "mp4",
OutputType = "cdn",
AuthTimeout = 3600 * 24 * 12,
});
if (videoInfo is null || videoInfo.StatusCode != 200 && !videoInfo.Body.PlayInfoList.PlayInfo.Any())
return BadRequest("获取存储的视频信息失败!");
return Ok(videoInfo.Body.PlayInfoList.PlayInfo.First().PlayURL);
else
return BadRequest("此视频未能获取到视频");
//try
//{
// var videoInfo = await vodClient.GetPlayInfoAsync(new GetPlayInfoRequest()
// {
// VideoId = task.TagId,
// Formats = "mp4",
// OutputType = "cdn",
// AuthTimeout = 3600 * 24 * 12,
// });
// if (videoInfo is null || videoInfo.StatusCode != 200 && !videoInfo.Body.PlayInfoList.PlayInfo.Any())
// return BadRequest("获取存储的视频信息失败!");
// return Ok(videoInfo.Body.PlayInfoList.PlayInfo.First().PlayURL);
}
catch (Exception ex)
{
return BadRequest("获取存储的视频信息失败!" + ex.Message);
}
//}
//catch (Exception ex)
//{
// return BadRequest("获取存储的视频信息失败!" + ex.Message);
//}
}