コード例 #1
0
ファイル: YoutubeDL.cs プロジェクト: Alicg/IASoft.Commons
 /// <summary>
 ///     Convert class into parameters to pass to youtube-dl process, then create and run process.
 ///     Also handle output from process.
 /// </summary>
 /// <param name="videoUrl">URL of video to download</param>
 public void Download(string videoUrl)
 {
     this.semaphore.Wait();
     this.UpdateExecutable().Wait();
     DownloadService.Download(this, videoUrl, downloadTokenSource.Token);
     this.semaphore.Release();
 }
コード例 #2
0
        private void Handle(string[] args)
        {
            var parameters = ParameterUtility.GetParameters(args);

            var filePathParameter = parameters.FirstOrDefault(x => x.GetType() == typeof(FilePathParameter));

            if (filePathParameter == null || string.IsNullOrEmpty(filePathParameter.Value) || !File.Exists(filePathParameter.Value))
            {
                Console.WriteLine("Error: the file path parameter not found.");
                return;
            }

            var outputPath         = parameters.First(x => x is OutputPathParameter).Value;
            var threadCount        = int.Parse(parameters.First(x => x is ThreadParameter).Value);
            var speedConfiguration = GetSpeedCofiguration(parameters.First(x => x is SpeedParameter).Value);

            timer.Start();
            var downloadService = new DownloadService(
                FileLinkUtility.GetFileLinks(filePathParameter.Value),
                outputPath,
                threadCount,
                speedConfiguration.Speed);

            downloadService.Download();
            timer.Stop();
            Console.WriteLine("Elapsed time - {0}ms", timer.ElapsedMilliseconds);
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            textBox2.Text = string.Empty;
            var address = textBox1.Text;

            var response = DownloadService.Download(address);

            textBox2.Text = response;
        }
コード例 #4
0
        public void Download_should_download_file()
        {
            //Arrange
            string       id       = "1";
            string       fileName = string.Empty;
            MemoryStream stream   = new MemoryStream(new byte[10]);

            _mainController.Stub(t => t.Download(id, ref fileName)).Return(stream);
            _mockResponseProvider.Stub(t => t.ResponseContentType(null)).Return("");
            _mockResponseProvider.Stub(t => t.ResponseInternalServerError(null)).Return(HttpStatusCode.OK);
            //Act
            var result = _service.Download(id);

            //Assert
            _mainController.AssertWasCalled(t => t.Download(id, ref fileName));
            _mockResponseProvider.AssertWasCalled(t => t.ResponseContentType(null));
            _mockResponseProvider.AssertWasCalled(t => t.ResponseOk(null));
            Assert.AreEqual(result.Length, 10);
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //TODO: make this method not to block the UI thread while I/O operation

            textBox2.Text = string.Empty;
            var address = textBox1.Text;

            var response = DownloadService.Download(address);

            textBox2.Text = response;
        }
コード例 #6
0
        public static void HardWork(int item)
        {
            var content = DownloadService.Download(Address);

            var value = Random.Next(1, 10);

            if (value > 6)
            {
                throw new Exception($"Processing item \"{item}\" failed cause random value is {value}. Test data {content.Substring(0, 50)}");
            }
        }
コード例 #7
0
ファイル: DownloadAction.cs プロジェクト: wlevel/egg-pie
        protected override void DoHandle(Dictionary <string, object> parameters)
        {
            Console.WriteLine("Please input the file directory path:");
            var confimKey = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(confimKey))
            {
                Console.WriteLine("Please enter the correct path!");
                return;
            }
            DownloadService.Download(confimKey);
        }
コード例 #8
0
ファイル: DumpsController.cs プロジェクト: zhangz/superdump
        [RequestSizeLimit(4294967295)]         //set max allowed request content length to 4GB - 1byte, the configuration in the web.config file does not work in .net core 3.0 preview 6
        public async Task <IActionResult> PostFile(IFormFile file, IDictionary <string, string> customProperties)
        {
            var tempFileHandle = await downloadService.Download(file.OpenReadStream(), file.FileName);

            string bundleId = superDumpRepo.ProcessLocalInputfile(file.FileName, tempFileHandle, customProperties);

            if (bundleId != null)
            {
                logger.LogFileUpload("Api Upload", HttpContext, bundleId, customProperties, file.FileName);
                return(CreatedAtAction(nameof(HomeController.BundleCreated), "Home", new { bundleId = bundleId }, null));
            }
            else
            {
                // in case the input was just symbol files, we don't get a bundleid.
                return(BadRequest("No dump was found in bundle."));
            }
        }
コード例 #9
0
        public async Task DownloadTest_NOK()
        {
            var response = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.BadRequest,
                Content    =
                    new StringContent("test"),
            };

            httpFake
            .Setup(
                x => x.GetAsync((It.IsAny <string>())))

            .Returns(Task.FromResult <HttpResponseMessage>(response));

            service = new DownloadService(httpFake.Object);
            var fileNames = await service.Download("test.txt");

            Assert.IsTrue(!fileNames);
        }
コード例 #10
0
        [RequestSizeLimit(4294967295)]         //set max allowed request content length to 4GB - 1byte, the configuration in the web.config file does not work in .net core 3.0 preview 6
        public async Task <IActionResult> Upload(IFormFile file, string refurl, string note)
        {
            if (ModelState.IsValid)
            {
                pathHelper.PrepareDirectories();
                if (file.Length > 0)
                {
                    var tempFileHandle = await downloadService.Download(file.OpenReadStream(), file.FileName);

                    string bundleId = superDumpRepo.ProcessLocalInputfile(file.FileName, tempFileHandle, new Dictionary <string, string> {
                        { "ref", refurl }, { "note", note }
                    });
                    return(RedirectToAction("BundleCreated", "Home", new { bundleId = bundleId }));
                }
                return(View("UploadError", new Error("No filename was provided.", "")));
            }
            else
            {
                return(View("UploadError", new Error("Invalid model", "Invalid model")));
            }
        }
コード例 #11
0
 public MainWindow()
 {
     this.DataContext = new MainWindowViewModel();
     DownloadService.Download(this.DataContext as MainWindowViewModel);
 }
コード例 #12
0
 /// <summary>
 ///     Convert class into parameters to pass to youtube-dl process, then create and run process.
 ///     Also handle output from process.
 /// </summary>
 /// <param name="videoUrl">URL of video to download</param>
 public void Download(string videoUrl)
 {
     this.semaphore.Wait();
     DownloadService.Download(this, videoUrl);
     this.semaphore.Release();
 }
コード例 #13
0
 /// <summary>
 ///     Convert class into parameters to pass to youtube-dl process, then create and run process.
 ///     Also handle output from process.
 /// </summary>
 public void Download()
 {
     this.semaphore.Wait();
     DownloadService.Download(this);
     this.semaphore.Release();
 }
コード例 #14
0
 /// <summary>
 ///     Convert class into parameters to pass to youtube-dl process, then create and run process.
 ///     Also handle output from process.
 /// </summary>
 public void Download()
 {
     this.semaphore.Wait();
     DownloadService.Download(this, downloadTokenSource.Token);
     this.semaphore.Release();
 }