private bool IsArchivedNzb(FeedItem feedItem) { string rssTitle = feedItem.Title; string rssTitleFix = feedItem.TitleFix; Log("Checking for Imported NZB for [{0}] or [{1}]", rssTitle, rssTitleFix); bool inNzbArchive = false; string nzbFileName = ReplaceSeparatorChars(CleanString(rssTitle.TrimEnd('.'))); foreach (FileInfo fi in Config.NzbDir.GetFiles("*.nzb.gz")) { string archiveFileName = ReplaceSeparatorChars(fi.Name.Replace(".nzb.gz", string.Empty)); if (nzbFileName == archiveFileName) { inNzbArchive = true; break; } } // TODO: would this ever be true? string nzbFileNameFix = CleanString(rssTitleFix.TrimEnd('.')); if (File.Exists(Path.Combine(Config.NzbDir.FullName, nzbFileNameFix + ".nzb.gz"))) { inNzbArchive = true; } if (inNzbArchive) { RejectArchivedNzbCount++; Log("Episode in archive: '{0}'", true, nzbFileName + ".nzb.gz"); return true; } return false; }
private Episode MatchFirstAiredEpisode(FeedItem item) { Match match = Regex.Match(item.Title, PatternDaily); if (!match.Success) return null; return new Episode { FeedItem = item, ShowName = ParseShowName(item, PatternDaily), AirDate = DateTime.Parse(string.Format("{0}-{1}-{2}", match.Groups["Year"].Value, match.Groups["Month"].Value, match.Groups["Day"].Value)), }; }
private string ParseShowName(FeedItem item, string pattern) { string showName = Regex.Split(item.Title, pattern)[0].Replace('.', ' ').TrimEnd(' ', '-'); return ShowAlias(showName); }
private Episode MatchSeasonEpisode(FeedItem item) { string episodeName = null; string pattern = PatternS01E01; Match match = Regex.Match(item.Title, pattern); if (!match.Success) { pattern = Pattern1X01; match = Regex.Match(item.Title, Pattern1X01); if (!match.Success) return null; } else { // Get episode name from title (used for lilx.net feeds) string[] part = Regex.Split(item.Title, PatternS01E01); if (part.Length > 2 && part[3].StartsWith(" - ")) episodeName = part[3].TrimStart('-', ' '); } return new Episode { FeedItem = item, ShowName = ParseShowName(item, pattern), SeasonNumber = int.Parse(match.Groups["Season"].Value), EpisodeNumber = int.Parse(match.Groups["Episode"].Value), EpisodeName = episodeName, }; }
private Episode MatchSeasonEpisodeMulti(FeedItem item) { Match match = Regex.Match(item.Title, PatternS01E01E02); if (!match.Success) return null; return new Episode { FeedItem = item, ShowName = ParseShowName(item, PatternS01E01E02), SeasonNumber = int.Parse(match.Groups["Season"].Value), EpisodeNumber = int.Parse(match.Groups["EpisodeOne"].Value), EpisodeNumber2 = int.Parse(match.Groups["EpisodeTwo"].Value), }; }
private Episode ParseEpisode(FeedItem feedItem) { return MatchSeasonEpisodeMulti(feedItem) ?? MatchSeasonEpisode(feedItem) ?? MatchFirstAiredEpisode(feedItem); }
private void QueueIfWanted(NzbInfo nzb) { Log(string.Empty); Log("----------------------------------------------------------------"); Log("Verifying '{0}'", nzb.Title); try { if (nzb.IsPassworded()) { RejectPasswordedCount++; Log("Skipping Passworded Report {0}", nzb.Title); return; } var feedItem = new FeedItem { NzbId = nzb.Id, Title = nzb.Title, Description = nzb.Description }; Episode episode = ParseEpisode(feedItem); if (episode == null) { Log("Unsupported Title: {0}", feedItem.Title); return; } if (!IsShowWanted(episode.ShowName)) return; if (!IsEpisodeWanted(episode)) return; nzb.Title = episode.FeedItem.TitleFix; string queueResponse = Sab.AddByUrl(nzb); Database.AddToHistory(episode, nzb); DatabaseChangedHandler handler = DbChanged; if (handler != null) handler("history"); // TODO: check if Queued.Add need unfixed Title (was previously) AcceptCount++; Queued.Add(string.Format("{0}: {1}", nzb.Title, queueResponse)); } catch (Exception e) { Log("Unsupported Title: {0} - {1}", nzb.Title, e); } }
public static Episode Parse(FeedItem feedItem) { Match match = Regex.Match(feedItem.Title, EpisodePattern, RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase); if (!match.Success) return null; return new Episode { ShowName = ReplaceSeparatorChars(match.Groups["showName"].Value), SeasonNumber = ParseInt(match.Groups["seasonNumber"].Value), EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value), EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value), EpisodeName = ReplaceSeparatorChars(match.Groups["episodeName"].Value), Release = ReplaceSeparatorChars(match.Groups["release"].Value) }; }