From aa6e07fc6063339fe72683692640c0d67a508897 Mon Sep 17 00:00:00 2001 From: Josh Creek Date: Sun, 29 Aug 2021 15:47:37 +0100 Subject: [PATCH] feat(*): Add main logic flow --- YouTubeChannelDownloader/Program.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/YouTubeChannelDownloader/Program.cs b/YouTubeChannelDownloader/Program.cs index 2a83df5..54022be 100644 --- a/YouTubeChannelDownloader/Program.cs +++ b/YouTubeChannelDownloader/Program.cs @@ -28,5 +28,24 @@ namespace YouTubeChannelDownloader private static async Task Main(string[] args) { + // Check every night if there's any new videos on the channel and download them + // Could change the interval and channel via a config file or environment variables + IReadOnlyList newVideos = await CheckForNewVideosAsync(); + + YoutubeExplode.Channels.Channel channel = await _youtube.Channels.GetAsync(_channelId); + + Console.WriteLine($"There are {newVideos.Count} new videos to download from {channel.Title}"); + + foreach (YouTubeVideo video in newVideos) + { + Console.WriteLine($"Starting {channel.Title} - {video.PlaylistVideo.Title}"); + string pathString = await DownloadVideoAsync(video, channel.Title); + await RecordSuccessfulVideoDownload(video, channel.Title); + + // TODO? - set this up with a discard to run in a separate thread so more downloads can happen, need to be careful of error handling and logging + TransferFileToNasShare(pathString); + DeleteLocalFile(pathString); + } + } } }