feat(*): Add main logic flow

This commit is contained in:
Josh Creek
2021-08-29 15:47:37 +01:00
parent c02ffb5a88
commit aa6e07fc60
+19
View File
@@ -28,5 +28,24 @@ namespace YouTubeChannelDownloader
private static async Task Main(string[] args) 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<YouTubeVideo> 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);
}
}
} }
} }