public void UpdateShow(ShowControl sc) { Console.WriteLine("Updating RSS for " + sc.Title); if (sc.LocalFiles) { lock (_shows) { sc.ScanLocalFilesOnly(); } } else { XmlReader RSSFeed = sc.UpdateRSSFile(); if (RSSFeed == null) { Console.WriteLine("Failed to download rss feed"); sc.FailedCount++; return; } try { List <EpisodeControl> episodes = RSSHelper.ReadEpisodes(RSSFeed); lock (_shows) { sc.UpdateEpisode(episodes); } } catch { } } }
public void RemoveShow(ShowControl itemToRemove) { lock (_shows) { _shows.Remove(itemToRemove); PersistenceHelper <ShowControl> ph = new PersistenceHelper <ShowControl>(_outputFolder); ph.DeleteFile(itemToRemove); } }
public bool Add(ShowControl show) { lock (_shows) { show.Modifyed = true; if (Contains(show)) { return(false); } _shows.Add(show); } return(true); }
public bool UpdateNextRSSFeeds() { ShowControl nextShow = _shows.FirstOrDefault(x => x != null && !x.UpdatedRssTurn && (x.ShowOption.CheckforUpdates || x.ShowOption.ShowStorage == ShowStorageType.LocalStorage)); if (nextShow != null) { lock (_shows) { nextShow.UpdatedRssTurn = true; } UpdateShow(nextShow); return(false); } var nextShowDownload = _shows.FirstOrDefault(x => x != null && !x.AutoDownloadTurn && x.ShowOption.AudoDownloadEpisodes); if (nextShowDownload != null) { lock (_shows) { nextShowDownload.AutoDownloadTurn = true; Console.WriteLine($"Download all shows for {nextShowDownload.Title}"); ServiceLocator.Instance.GetService <LoggerService>().AddError($"Auto download {nextShowDownload.Title}"); nextShowDownload.Download(); return(false); } } Console.WriteLine("re set all shows to check for download"); lock (_shows) { foreach (ShowControl show in _shows) { if (show == null) { continue; } if (show.FailedCount < 2) { show.UpdatedRssTurn = false; show.AutoDownloadTurn = false; } } return(true); } }
public bool Contains(ShowControl show) { if (_shows.Any((x) => x != null && x.RssFeed == show.RssFeed)) { return(true); } if (_shows.Any((x) => x != null && x.Title == show.Title)) { return(true); } return(false); }