private void YouTubeCheckWorker_DoWork(object sender, DoWorkEventArgs e) { try { if (string.IsNullOrWhiteSpace(SettingsManager.Configuration.YouTubeAPIKey)) { LoggingManager.Log.Error(new ArgumentNullException(nameof(SettingsManager.Configuration.YouTubeAPIKey)), "The YouTubeAPIKey can not be: null, blank, or just whitespace. Aborted YouTubeCheckWorker."); return; } List <string> videosToGetInfo = new List <string>(); foreach (Database.Types.Channel channel in Database.Channels.GetAll()) { List <string> videoIDs = new YouTube.Channel().RecentVideoIDs(channel.ID); foreach (string id in videoIDs) { if (!Database.Videos.Exists(id)) { videosToGetInfo.Add(id); } } } List <Database.Types.Video> videoInfo = new YouTube.Videos().Bulk(videosToGetInfo); foreach (Database.Types.Video video in videoInfo) { Database.Videos.Insert(video); Database.ImageFile.Insert(video.ThumbnailURL, video.ID, ImageType.VideoThumbnail); } e.Result = true; } catch (Exception ex) { LoggingManager.Log.Error(ex, "There was an error while checking for new videos."); e.Result = false; } }