예제 #1
0
        public async Task <IActionResult> Multi([Bind("Url")] DownloadModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            List <string> urls = model.Url.Split("\r\n").ToList();

            try
            {
                List <DownloadResultModel> results = new List <DownloadResultModel>();
                Parallel.ForEach(urls, async(url) =>
                {
                    DownloadResultModel result = new DownloadResultModel();
                    result.Url      = url;
                    result.VideoUrl = await RushDownloader.GetVidDownloadLink(url) ?? "None";
                    result.Title    = RushDownloader.GetVideoTitle(url) ?? "None";
                    results.Add(result);
                });
                return(View("Results", results));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View(model));
            }
        }
예제 #2
0
        public async Task <IActionResult> Index([Bind("Url")] DownloadModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                DownloadResultModel result = new DownloadResultModel();
                result.Url      = model.Url;
                result.VideoUrl = await RushDownloader.GetVidDownloadLink(model.Url) ?? "None";

                result.Title = RushDownloader.GetVideoTitle(model.Url) ?? "None";
                return(View("Result", result));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View(model));
            }
        }