public ActionResult DirectDownloadAudio([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 outputFilePath = $"{Output_Root}/yt/{vid}.mp3"; if (System.IO.File.Exists(outputFilePath)) { return(PhysicalFile(outputFilePath, "audio/mpeg", $"{info.Filename}-{vid}.mp3")); } var audio = YoutubeHelper.DownloadAudioMp3(vid); if (System.IO.File.Exists(audio)) { return(PhysicalFile(audio, "audio/mpeg", $"{info.Filename}-{vid}.mp3")); } return(BadRequest("Video requested was not found")); }