Exemplo n.º 1
0
        private void ProcessVideos(IEnumerable <YTVideo> videos, SeenItems seenItems, string downloadFolder, int season, LocalMetadata localMetadata)
        {
            var client       = new YoutubeClient();
            var seasonFolder = Path.Combine(downloadFolder, $"Season {season}");

            Directory.CreateDirectory(seasonFolder);
            var episodeNumber = GetLastEpisodeNumber(seasonFolder);

            videos.ToList().ForEach(video =>
            {
                episodeNumber++;

                Console.WriteLine($"  0.00% Downloading {video.Id} {episodeNumber} {video.Title}");
                Console.SetCursorPosition(0, Console.CursorTop - 1);

                var videoFileNameBase = $"S{season.ToString().PadLeft(2, '0')}E{episodeNumber.ToString("N0").PadLeft(2, '0')} " + video.Title.Aggregate("", (agg, cur) => Path.GetInvalidFileNameChars().Contains(cur) ? agg : agg + cur);

                var progress = new ConcurrentProgress <double>(d =>
                {
                    Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write((d * 100).ToString("N2").PadLeft(6));
                });

                Downloaders.DownloadVideo(client, video, seasonFolder, videoFileNameBase, progress);
                Downloaders.DownloadAllCaptions(client, video, seasonFolder, videoFileNameBase, progress);
                CreateMetadata(video, seasonFolder, videoFileNameBase, localMetadata);

                seenItems.SaveId(video.Id);

                Console.WriteLine();
            });
        }
Exemplo n.º 2
0
        private void SaveVideo(YTVideo video, string downloadFolder, string videoFileNameBase)
        {
            var client = new YoutubeClient();

            Console.WriteLine($"  0.00% Downloading {video.Id} {video.Title}");
            Console.SetCursorPosition(0, Console.CursorTop - 1);

            var progress = new ConcurrentProgress <double>(d =>
            {
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write((d * 100).ToString("N2").PadLeft(6));
            });

            Downloaders.DownloadVideo(client, video, downloadFolder, videoFileNameBase, progress);
            Downloaders.DownloadAllCaptions(client, video, downloadFolder, videoFileNameBase, progress);

            Console.WriteLine();
        }