private List <SceneSeasonMapping> GetSceneSeasonMappings(Series series, List <Episode> episodes) { var dict = new Dictionary <SceneSeasonMapping, SceneSeasonMapping>(); var sceneMappings = _sceneMapping.FindByTvdbId(series.TvdbId); // Group the episode by SceneSeasonNumber/SeasonNumber, in 99% of cases this will result in 1 groupedEpisode var groupedEpisodes = episodes.ToLookup(v => (v.SceneSeasonNumber ?? v.SeasonNumber) * 100000 + v.SeasonNumber); foreach (var groupedEpisode in groupedEpisodes) { var episodeMappings = GetSceneEpisodeMappings(series, groupedEpisode.First(), sceneMappings); foreach (var episodeMapping in episodeMappings) { var seasonMapping = new SceneSeasonMapping { Episodes = groupedEpisode.ToList(), EpisodeMapping = episodeMapping, SceneTitles = episodeMapping.SceneTitles, SearchMode = episodeMapping.SearchMode, SeasonNumber = episodeMapping.SeasonNumber }; if (dict.TryGetValue(seasonMapping, out var existing)) { existing.Episodes.AddRange(seasonMapping.Episodes); existing.SceneTitles.AddRange(seasonMapping.SceneTitles); } else { dict[seasonMapping] = seasonMapping; } } } foreach (var item in dict) { item.Value.Episodes = item.Value.Episodes.Distinct().ToList(); item.Value.SceneTitles = item.Value.SceneTitles.Distinct().ToList(); } return(dict.Values.ToList()); }
private void PopulateAlternateTitles(SeriesResource resource) { var mappings = _sceneMappingService.FindByTvdbId(resource.TvdbId); if (mappings == null) { return; } resource.AlternateTitles = mappings.InjectTo <List <AlternateTitleResource> >(); }
private void PopulateAlternateTitles(SeriesResource resource) { var mappings = _sceneMappingService.FindByTvdbId(resource.TvdbId); if (mappings == null) { return; } resource.AlternateTitles = mappings.ConvertAll(AlternateTitleResourceMapper.ToResource); }
private void PopulateAlternateTitles(SeriesResource resource) { var mappings = _sceneMappingService.FindByTvdbId(resource.TvdbId); if (mappings == null) { return; } //resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList(); }
private void PopulateAlternateTitles(SeriesResource resource) { var mappings = _sceneMappingService.FindByTvdbId(resource.TvdbId); if (mappings == null) { return; } resource.AlternateTitles = mappings.ConvertAll(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber, SceneOrigin = v.SceneOrigin, Comment = v.Comment }); }