public void RemoveIgnored() { ItemList toRemove = new ItemList(); foreach (Item item in TheActionList) { if (TVSettings.Instance.Ignore.Any(ii => ii.SameFileAs(item.Ignore))) { toRemove.Add(item); } if (TVSettings.Instance.IgnorePreviouslySeen) { if (TVSettings.Instance.PreviouslySeenEpisodes.Includes(item)) { toRemove.Add(item); } } } foreach (Item action in toRemove) { TheActionList.Remove(action); } }
private static void RemoveDuplicates([NotNull] ItemList newItemsForThisMissingEpisode) { foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode)) { newItemsForThisMissingEpisode.Remove(x); } }
private static void FindMissingEpisode([NotNull] ShowItemMissing action, ItemList toRemove, ItemList newItems) { ProcessedEpisode processedEpisode = action.MissingEpisode; string url = TVSettings.Instance.UseJackettTextSearch ? TextJackettUrl(processedEpisode) : NormalJackettUrl(processedEpisode); RssItemList rssList = new RssItemList(); rssList.DownloadRSS(url, false, "Jackett"); ItemList newItemsForThisMissingEpisode = new ItemList(); foreach (RSSItem rss in rssList.Where(rss => RssMatch(rss, processedEpisode))) { if (TVSettings.Instance.DetailedRSSJSONLogging) { LOGGER.Info( $"Adding {rss.URL} from RSS feed as it appears to be match for {processedEpisode.Show.ShowName} S{processedEpisode.AppropriateSeasonNumber}E{processedEpisode.AppropriateEpNum}"); } newItemsForThisMissingEpisode.Add(new ActionTDownload(rss, action.TheFileNoExt, action)); toRemove.Add(action); } foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode)) { newItemsForThisMissingEpisode.Remove(x); } newItems.AddNullableRange(newItemsForThisMissingEpisode); }
private static void FindMissingEpisode([NotNull] MovieItemMissing action, ItemList toRemove, ItemList newItems) { string url = TVSettings.Instance.UseJackettTextSearch ? TextJackettUrl(action.MovieConfig) : NormalJackettUrl(action.MovieConfig); RssItemList rssList = new RssItemList(); rssList.DownloadRSS(url, false, "Jackett"); ItemList newItemsForThisMissingEpisode = new ItemList(); foreach (RSSItem rss in rssList.Where(rss => RssMatch(rss, action.MovieConfig))) { if (TVSettings.Instance.DetailedRSSJSONLogging) { LOGGER.Info( $"Adding {rss.URL} from RSS feed as it appears to be match for {action.MovieConfig.ShowName}"); } ItemDownloading becomes = new ItemDownloading(new FutureTorrentEntry(rss.URL, action.TheFileNoExt), action.MovieConfig, action.TheFileNoExt, DownloadingFinder.DownloadApp.qBitTorrent, action); newItemsForThisMissingEpisode.Add(new ActionTDownload(rss, action, becomes)); toRemove.Add(action); } foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode)) { newItemsForThisMissingEpisode.Remove(x); } newItems.AddNullableRange(newItemsForThisMissingEpisode); }
protected override void DoCheck(SetProgressDelegate prog, TVDoc.ScanSettings settings) { if (TVSettings.Instance.SearchRSSManualScanOnly && settings.Unattended) { LOGGER.Info("Searching RSS Feeds is cancelled as this is an unattended scan"); return; } int c = ActionList.Missing.Count + 2; int n = 1; UpdateStatus(n, c, "Searching on RSS Feed..."); // ReSharper disable once InconsistentNaming RssItemList RSSList = new RssItemList(); foreach (string s in TVSettings.Instance.RSSURLs) { RSSList.DownloadRSS(s, TVSettings.Instance.RSSUseCloudflare, "RSS"); } ItemList newItems = new ItemList(); ItemList toRemove = new ItemList(); foreach (ShowItemMissing action in ActionList.MissingEpisodes.ToList()) { if (settings.Token.IsCancellationRequested) { return; } UpdateStatus(n++, c, action.Filename); ProcessedEpisode pe = action.MissingEpisode; ItemList newItemsForThisMissingEpisode = new ItemList(); foreach (RSSItem rss in RSSList.Where(rss => RssMatch(rss, pe))) { LOGGER.Info( $"Adding {rss.URL} from RSS feed as it appears to be match for {pe.Show.ShowName} {pe}"); ItemDownloading eventualItem = new ItemDownloading(new FutureTorrentEntry(rss.URL, action.TheFileNoExt), action.MissingEpisode, action.TheFileNoExt, DownloadingFinder.DownloadApp.qBitTorrent, action); newItemsForThisMissingEpisode.Add(new ActionTDownload(rss, action, eventualItem)); toRemove.Add(action); } foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode)) { newItemsForThisMissingEpisode.Remove(x); } newItems.AddNullableRange(newItemsForThisMissingEpisode); } ActionList.Replace(toRemove, newItems); }
public override void Check(SetProgressDelegate prog, int startpct, int totPct) { int c = this.ActionList.Count + 2; int n = 1; prog.Invoke(startpct); // ReSharper disable once InconsistentNaming RSSItemList RSSList = new RSSItemList(); foreach (string s in TVSettings.Instance.RSSURLs) { RSSList.DownloadRSS(s, TVSettings.Instance.FNPRegexs); } ItemList newItems = new ItemList(); ItemList toRemove = new ItemList(); foreach (Item testItem in this.ActionList) { if (this.ActionCancel) { return; } prog.Invoke(startpct + (totPct - startpct) * (++n) / (c)); if (!(testItem is ItemMissing action)) { continue; } ProcessedEpisode pe = action.Episode; string simpleShowName = Helpers.SimplifyName(pe.SI.ShowName); string simpleSeriesName = Helpers.SimplifyName(pe.TheSeries.Name); foreach (RSSItem rss in RSSList) { if ( !FileHelper.SimplifyAndCheckFilename(rss.ShowName, simpleShowName, true, false) && !( string.IsNullOrEmpty(rss.ShowName) && FileHelper.SimplifyAndCheckFilename(rss.Title, simpleSeriesName, true, false) ) ) { continue; } if (rss.Season != pe.AppropriateSeasonNumber) { continue; } if (rss.Episode != pe.AppropriateEpNum) { continue; } Logger.Info($"Adding {rss.URL} as it appears to be match for {testItem.Episode.SI.ShowName} S{testItem.Episode.AppropriateSeasonNumber}E{testItem.Episode.AppropriateEpNum}"); newItems.Add(new ActionRSS(rss, action.TheFileNoExt, pe)); toRemove.Add(testItem); } } //We now want to rationlise the newItems - just in case we've added duplicates List <ActionRSS> duplicateActionRSS = new List <ActionRSS>(); foreach (Item x in newItems) { if (!(x is ActionRSS testActionRSSOne)) { continue; } foreach (Item y in newItems) { if (!(y is ActionRSS testActionRSSTwo)) { continue; } if (x.Equals(y)) { continue; } string[] preferredTerms = TVSettings.Instance.PreferredRSSSearchTerms(); if (testActionRSSOne.RSS.ShowName.ContainsOneOf(preferredTerms) && !testActionRSSTwo.RSS.ShowName.ContainsOneOf(preferredTerms)) { duplicateActionRSS.Add(testActionRSSTwo); Logger.Info($"Removing {testActionRSSTwo.RSS.URL} as it is not as good a match as {testActionRSSOne.RSS.URL }"); } if (testActionRSSOne.RSS.Title.ContainsOneOf(preferredTerms) && !testActionRSSTwo.RSS.Title.ContainsOneOf(preferredTerms)) { duplicateActionRSS.Add(testActionRSSTwo); Logger.Info( $"Removing {testActionRSSTwo.RSS.URL} as it is not as good a match as {testActionRSSOne.RSS.URL}"); } } } foreach (ActionRSS x in duplicateActionRSS) { newItems.Remove(x); } foreach (Item i in toRemove) { this.ActionList.Remove(i); } foreach (Item action in newItems) { this.ActionList.Add(action); } prog.Invoke(totPct); }
protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings) { if (TVSettings.Instance.SearchRSSManualScanOnly && settings.Unattended) { LOGGER.Info("Searching RSS Feeds is cancelled as this is an unattended scan"); return; } int c = ActionList.MissingItems().Count() + 2; int n = 1; UpdateStatus(n, c, "Searching on RSS Feed..."); // ReSharper disable once InconsistentNaming RssItemList RSSList = new RssItemList(); foreach (string s in TVSettings.Instance.RSSURLs) { RSSList.DownloadRSS(s, TVSettings.Instance.FNPRegexs, TVSettings.Instance.RSSUseCloudflare); } ItemList newItems = new ItemList(); ItemList toRemove = new ItemList(); foreach (ItemMissing action in ActionList.MissingItems().ToList()) { if (settings.Token.IsCancellationRequested) { return; } UpdateStatus(n++, c, action.Filename); ProcessedEpisode pe = action.Episode; string simpleShowName = Helpers.SimplifyName(pe.Show.ShowName); string simpleSeriesName = Helpers.SimplifyName(pe.TheSeries.Name); ItemList newItemsForThisMissingEpisode = new ItemList(); foreach (RSSItem rss in RSSList) { if ( !FileHelper.SimplifyAndCheckFilename(rss.ShowName, simpleShowName, true, false) && !( string.IsNullOrEmpty(rss.ShowName) && FileHelper.SimplifyAndCheckFilename(rss.Title, simpleSeriesName, true, false) ) ) { continue; } if (rss.Season != pe.AppropriateSeasonNumber) { continue; } if (rss.Episode != pe.AppropriateEpNum) { continue; } LOGGER.Info($"Adding {rss.URL} from RSS feed as it appears to be match for {action.Episode.Show.ShowName} S{action.Episode.AppropriateSeasonNumber}E{action.Episode.AppropriateEpNum}"); newItemsForThisMissingEpisode.Add(new ActionTDownload(rss, action.TheFileNoExt, pe, action)); toRemove.Add(action); } foreach (ActionTDownload x in FindDuplicates(newItemsForThisMissingEpisode)) { newItemsForThisMissingEpisode.Remove(x); } newItems.AddNullableRange(newItemsForThisMissingEpisode); } ActionList.Replace(toRemove, newItems); }
public override void Check(SetProgressDelegate prog, int startpct, int totPct) { int c = ActionList.Count + 2; int n = 1; prog.Invoke(startpct); ItemList newItems = new ItemList(); ItemList toRemove = new ItemList(); try { foreach (ItemMissing action in ActionList.MissingItems()) { if (ActionCancel) { return; } prog.Invoke(startpct + ((totPct - startpct) * (++n) / (c))); ProcessedEpisode pe = action.Episode; string simpleShowName = Helpers.SimplifyName(action.Episode.Show.ShowName); string simpleSeriesName = Helpers.SimplifyName(action.Episode.TheSeries.Name); string imdbId = action.Episode.TheSeries.GetImdbNumber(); if (string.IsNullOrWhiteSpace(imdbId)) { continue; } WebClient client = new WebClient(); client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); string response = client.DownloadString($"{TVSettings.Instance.SearchJSONURL}{imdbId}"); JObject jsonResponse = JObject.Parse(response); if (jsonResponse.ContainsKey(TVSettings.Instance.SearchJSONRootNode)) { foreach (JToken item in jsonResponse[TVSettings.Instance.SearchJSONRootNode]) { if (item != null && item is JObject episodeResponse) { if (episodeResponse.ContainsKey(TVSettings.Instance.SearchJSONFilenameToken) && episodeResponse.ContainsKey(TVSettings.Instance.SearchJSONURLToken)) { string itemName = (string)item[TVSettings.Instance.SearchJSONFilenameToken]; string itemUrl = (string)item[TVSettings.Instance.SearchJSONURLToken]; if (TVSettings.Instance.DetailedRSSJSONLogging) { LOGGER.Info("Processing JSON Item"); LOGGER.Info(episodeResponse.ToString); LOGGER.Info("Extracted"); LOGGER.Info($"Name: {itemName}"); LOGGER.Info($"URL: {itemUrl}"); } if (!FileHelper.SimplifyAndCheckFilename(itemName, simpleShowName, true, false) && !FileHelper.SimplifyAndCheckFilename(itemName, simpleSeriesName, true, false)) { continue; } if (!TVDoc.FindSeasEp(itemName, out int seas, out int ep, out int _, action.Episode.Show)) { continue; } if (TVSettings.Instance.DetailedRSSJSONLogging) { LOGGER.Info($"Season: {seas}"); LOGGER.Info($"Episode: {ep}"); } if (seas != pe.AppropriateSeasonNumber) { continue; } if (ep != pe.AppropriateEpNum) { continue; } LOGGER.Info( $"Adding {itemUrl} as it appears to be match for {pe.Show.ShowName} S{pe.AppropriateSeasonNumber}E{pe.AppropriateEpNum}"); newItems.Add(new ActionTDownload(itemName, itemUrl, action.TheFileNoExt, pe)); toRemove.Add(action); } else { LOGGER.Info( $"{TVSettings.Instance.SearchJSONFilenameToken} or {TVSettings.Instance.SearchJSONURLToken} not found in {TVSettings.Instance.SearchJSONURL}{imdbId} for {action.Episode.TheSeries.Name}"); } } } } else { LOGGER.Info( $"{TVSettings.Instance.SearchJSONRootNode} not found in {TVSettings.Instance.SearchJSONURL}{imdbId} for {action.Episode.TheSeries.Name}"); } } } catch (WebException ex) { LOGGER.Info(ex, $"Failed to Access {TVSettings.Instance.SearchJSONURL}"); } foreach (ActionTDownload x in FindDuplicates(newItems)) { newItems.Remove(x); } foreach (Item i in toRemove) { ActionList.Remove(i); } foreach (Item action in newItems) { ActionList.Add(action); } prog.Invoke(totPct); }