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"));
        }
        public ActionResult Download([FromRoute] string format, [FromRoute] string vid, [FromQuery] string sub, [FromQuery] string ext, [FromQuery] bool hf = false)
        {
            if (!ValidateVid(vid))
            {
                return(BadRequest($"'{vid}' is not a valid video ID"));
            }
            var subFormats = sub?.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();

            if (subFormats != null && !ValidateFormat(format, subFormats))
            {
                return(BadRequest($"'{format}:{string.Join("+", subFormats)}' is not a valid format"));
            }
            if (!ValidateExtension(ext))
            {
                return(BadRequest($"'{ext}' is not a valid extension"));
            }

            var outputFilename = _processor.GetOutputFileName(vid, format, subFormats, ext, hf);
            var outputFilePath = $"{Output_Root}/yt/{outputFilename}";

            if (System.IO.File.Exists(outputFilePath))
            {
                var info        = YoutubeHelper.GetVideoInfo(vid);
                var contentType = ext == ".mp4" ? "video/mp4" : ext == ".zip" ? "application/zip" : "audio/mpeg";
                return(PhysicalFile(outputFilePath, contentType, info.Filename + ext));
            }
            return(Problem($"File {outputFilename} not found"));
        }
        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"));
        }