public ActionResult DirectDownloadVideo([FromRoute] string vid) { if (!ValidateVid(vid)) { return(BadRequest($"'{vid}' is not a valid video ID")); } var info = YoutubeHelper.GetVideoInfo(vid); if (info.DurationSeconds > (Max_Duration_Seconds * 2)) { return(BadRequest($"Cannot process videos longer than {Max_Duration_Seconds * 2} seconds")); } var video = YoutubeHelper.DownloadVideo(vid, true); if (System.IO.File.Exists(video.VideoFileFullPath)) { return(PhysicalFile(video.VideoFileFullPath, "video/mp4", $"{info.Filename}-{vid}.mp4")); } return(BadRequest("Video requested was not found")); }