优化 直接使用 现有媒体资源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("参数无效"); return BadRequest("参数无效");
if(!string.IsNullOrWhiteSpace(task.MediaUrl)) if(!string.IsNullOrWhiteSpace(task.MediaUrl))
return Ok(task.MediaUrl); return Ok(task.MediaUrl);
try else
{ return BadRequest("此视频未能获取到视频");
var videoInfo = await vodClient.GetPlayInfoAsync(new GetPlayInfoRequest() //try
{ //{
VideoId = task.TagId, // var videoInfo = await vodClient.GetPlayInfoAsync(new GetPlayInfoRequest()
Formats = "mp4", // {
OutputType = "cdn", // VideoId = task.TagId,
AuthTimeout = 3600 * 24 * 12, // Formats = "mp4",
}); // OutputType = "cdn",
if (videoInfo is null || videoInfo.StatusCode != 200 && !videoInfo.Body.PlayInfoList.PlayInfo.Any()) // AuthTimeout = 3600 * 24 * 12,
return BadRequest("获取存储的视频信息失败!"); // });
return Ok(videoInfo.Body.PlayInfoList.PlayInfo.First().PlayURL); // 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) //catch (Exception ex)
{ //{
return BadRequest("获取存储的视频信息失败!" + ex.Message); // return BadRequest("获取存储的视频信息失败!" + ex.Message);
} //}
} }