public Series GetSeries(string title) { var parsedEpisodeInfo = Parser.ParseTitle(title); if (parsedEpisodeInfo == null) { return(_seriesService.FindByTitle(title)); } var tvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle, parsedEpisodeInfo.ReleaseTitle); if (tvdbId.HasValue) { return(_seriesService.FindByTvdbId(tvdbId.Value)); } var series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle); if (series == null) { series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, parsedEpisodeInfo.SeriesTitleInfo.Year); } return(series); }
public Series GetSeries(string title) { var parsedEpisodeInfo = Parser.ParseTitle(title); if (parsedEpisodeInfo == null) { return _seriesService.FindByTitle(title); } var tvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle, parsedEpisodeInfo.ReleaseTitle, parsedEpisodeInfo.SeasonNumber); if (tvdbId.HasValue) { return _seriesService.FindByTvdbId(tvdbId.Value); } var series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle); if (series == null && parsedEpisodeInfo.SeriesTitleInfo.AllTitles != null) { series = GetSeriesByAllTitles(parsedEpisodeInfo); } if (series == null) { series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitleInfo.TitleWithoutYear, parsedEpisodeInfo.SeriesTitleInfo.Year); } return series; }
public ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null) { if (searchCriteria != null) { if (tvdbId == 0) { tvdbId = _sceneMappingService.FindTvdbId(title) ?? 0; } if (tvdbId != 0 && tvdbId == searchCriteria.Series.TvdbId) { return(ParseSpecialEpisodeTitle(title, searchCriteria.Series)); } if (tvRageId != 0 && tvRageId == searchCriteria.Series.TvRageId) { return(ParseSpecialEpisodeTitle(title, searchCriteria.Series)); } } var series = GetSeries(title); if (series == null) { series = _seriesService.FindByTitleInexact(title); } if (series == null && tvdbId > 0) { series = _seriesService.FindByTvdbId(tvdbId); } if (series == null && tvRageId > 0) { series = _seriesService.FindByTvRageId(tvRageId); } if (series == null) { _logger.Debug("No matching series {0}", title); return(null); } return(ParseSpecialEpisodeTitle(title, series)); }
public Series FindByTitle(string title) { var tvdbId = _sceneMappingService.FindTvdbId(title); if (tvdbId.HasValue) { return(_seriesRepository.FindByTvdbId(tvdbId.Value)); } return(_seriesRepository.FindByTitle(title.CleanSeriesTitle())); }
private IEnumerable <DownloadDecision> GetDecisions(List <ReleaseInfo> reports, SearchCriteriaBase searchCriteria = null) { if (reports.Any()) { _logger.ProgressInfo("Processing {0} releases", reports.Count); } else { _logger.ProgressInfo("No results found"); } var reportNumber = 1; foreach (var report in reports) { DownloadDecision decision = null; _logger.ProgressTrace("Processing release {0}/{1}", reportNumber, reports.Count); _logger.Debug("Processing release '{0}' from '{1}'", report.Title, report.Indexer); try { var parsedEpisodeInfo = Parser.Parser.ParseTitle(report.Title); if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode) { var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(parsedEpisodeInfo, report.Title, report.TvdbId, report.TvRageId, searchCriteria); if (specialEpisodeInfo != null) { parsedEpisodeInfo = specialEpisodeInfo; } } if (parsedEpisodeInfo != null && !parsedEpisodeInfo.SeriesTitle.IsNullOrWhiteSpace()) { var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvdbId, report.TvRageId, searchCriteria); remoteEpisode.Release = report; if (remoteEpisode.Series == null) { var reason = "Unknown Series"; var matchingTvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle, parsedEpisodeInfo.ReleaseTitle, parsedEpisodeInfo.SeasonNumber); if (matchingTvdbId.HasValue) { reason = $"{parsedEpisodeInfo.SeriesTitle} matches an alias for series with TVDB ID: {matchingTvdbId}"; } decision = new DownloadDecision(remoteEpisode, new Rejection(reason)); } else if (remoteEpisode.Episodes.Empty()) { decision = new DownloadDecision(remoteEpisode, new Rejection("Unable to identify correct episode(s) using release name and scene mappings")); } else { _aggregationService.Augment(remoteEpisode); remoteEpisode.DownloadAllowed = remoteEpisode.Episodes.Any(); decision = GetDecisionForReport(remoteEpisode, searchCriteria); } } if (searchCriteria != null) { if (parsedEpisodeInfo == null) { parsedEpisodeInfo = new ParsedEpisodeInfo { Language = LanguageParser.ParseLanguage(report.Title), Quality = QualityParser.ParseQuality(report.Title) }; } if (parsedEpisodeInfo.SeriesTitle.IsNullOrWhiteSpace()) { var remoteEpisode = new RemoteEpisode { Release = report, ParsedEpisodeInfo = parsedEpisodeInfo }; decision = new DownloadDecision(remoteEpisode, new Rejection("Unable to parse release")); } } } catch (Exception e) { _logger.Error(e, "Couldn't process release."); var remoteEpisode = new RemoteEpisode { Release = report }; decision = new DownloadDecision(remoteEpisode, new Rejection("Unexpected error processing release")); } reportNumber++; if (decision != null) { if (decision.Rejections.Any()) { _logger.Debug("Release rejected for the following reasons: {0}", string.Join(", ", decision.Rejections)); } else { _logger.Debug("Release accepted"); } yield return(decision); } } }