public List <string> GetSceneNames(int tvdbId, IEnumerable <int> seasonNumbers) { var names = _findByTvdbIdCache.Find(tvdbId.ToString()); if (names == null) { return(new List <string>()); } return(FilterNonEnglish(names.Where(s => seasonNumbers.Contains(s.SeasonNumber) || s.SeasonNumber == -1) .Select(m => m.SearchTerm).Distinct().ToList())); }
private SceneMapping FindMapping(string title) { if (_getTvdbIdCache.Count == 0) { RefreshCache(); } var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle()); if (candidates == null) { return(null); } if (candidates.Count == 1) { return(candidates.First()); } var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber) .FirstOrDefault(v => v.Title == title); if (exactMatch != null) { return(exactMatch); } var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10)) .ThenByDescending(v => v.SeasonNumber) .First(); return(closestMatch); }
public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria) { var status = _blockedIndexerCache.Find(subject.Release.IndexerId.ToString()); if (status != null) { return(Decision.Reject($"Indexer {subject.Release.Indexer} is blocked till {status.DisabledTill} due to failures, cannot grab release.")); } return(Decision.Accept()); }
public List <SceneMapping> FindByTvdbId(int tvdbId) { if (_findByTvdbIdCache.Count == 0) { RefreshCache(); } var mappings = _findByTvdbIdCache.Find(tvdbId.ToString()); if (mappings == null) { return(new List <SceneMapping>()); } return(mappings); }
public void Handle(SeriesUpdatedEvent message) { if (_cache.IsExpired(TimeSpan.FromHours(3))) { UpdateXemSeriesIds(); } if (_cache.Count == 0) { _logger.Debug("Scene numbering is not available"); return; } if (!_cache.Find(message.Series.TvdbId.ToString()) && !message.Series.UseSceneNumbering) { _logger.Debug("Scene numbering is not available for {0} [{1}]", message.Series.Title, message.Series.TvdbId); return; } PerformUpdate(message.Series); }
private List <SceneMapping> FindMappings(string seriesTitle, string releaseTitle) { if (_getTvdbIdCache.Count == 0) { RefreshCache(); } var candidates = _getTvdbIdCache.Find(seriesTitle.CleanSeriesTitle()); if (candidates == null) { return(null); } candidates = FilterSceneMappings(candidates, releaseTitle); if (candidates.Count <= 1) { return(candidates); } var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber) .Where(v => v.Title == seriesTitle) .ToList(); if (exactMatch.Any()) { return(exactMatch); } var closestMatch = candidates.OrderBy(v => seriesTitle.LevenshteinDistance(v.Title, 10, 1, 10)) .ThenByDescending(v => v.SeasonNumber) .First(); return(candidates.Where(v => v.Title == closestMatch.Title).ToList()); }