mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-25 22:46:31 -04:00
New: Searching for episodes with season level scene mapping now possible instead of only via RssSync (Newznab/Torznab only)
This commit is contained in:
@@ -15,11 +15,13 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
public interface ISceneMappingService
|
||||
{
|
||||
List<string> GetSceneNames(int tvdbId, List<int> seasonNumbers, List<int> sceneSeasonNumbers);
|
||||
List<SceneMapping> GetSceneMappings(int tvdbId, List<int> seasonNumbers);
|
||||
int? FindTvdbId(string sceneTitle, string releaseTitle);
|
||||
List<SceneMapping> FindByTvdbId(int tvdbId);
|
||||
SceneMapping FindSceneMapping(string sceneTitle, string releaseTitle);
|
||||
int? GetSceneSeasonNumber(string seriesTitle, string releaseTitle);
|
||||
int? GetTvdbSeasonNumber(string seriesTitle, string releaseTitle);
|
||||
int GetTvdbSeasonNumber(string seriesTitle, string releaseTitle, int sceneSeasonNumber);
|
||||
int? GetSceneSeasonNumber(int tvdbId, int seasonNumber);
|
||||
}
|
||||
|
||||
@@ -66,6 +68,21 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
return FilterNonEnglish(names);
|
||||
}
|
||||
|
||||
public List<SceneMapping> GetSceneMappings(int tvdbId, List<int> seasonNumbers)
|
||||
{
|
||||
var mappings = FindByTvdbId(tvdbId);
|
||||
|
||||
if (mappings == null)
|
||||
{
|
||||
return new List<SceneMapping>();
|
||||
}
|
||||
|
||||
return mappings.Where(n => seasonNumbers.Contains(n.SeasonNumber ?? -1) &&
|
||||
(n.SceneSeasonNumber ?? -1) != -1)
|
||||
.Where(n => IsEnglish(n.SearchTerm))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public int? FindTvdbId(string seriesTitle)
|
||||
{
|
||||
return FindTvdbId(seriesTitle, null);
|
||||
@@ -129,6 +146,20 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
return FindSceneMapping(seriesTitle, releaseTitle)?.SeasonNumber;
|
||||
}
|
||||
|
||||
public int GetTvdbSeasonNumber(string seriesTitle, string releaseTitle, int sceneSeasonNumber)
|
||||
{
|
||||
var sceneMapping = FindSceneMapping(seriesTitle, releaseTitle);
|
||||
|
||||
if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 &&
|
||||
sceneMapping.SceneSeasonNumber <= sceneSeasonNumber)
|
||||
{
|
||||
var offset = sceneSeasonNumber - sceneMapping.SceneSeasonNumber.Value;
|
||||
return sceneMapping.SeasonNumber.Value + offset;
|
||||
}
|
||||
|
||||
return sceneSeasonNumber;
|
||||
}
|
||||
|
||||
public int? GetSceneSeasonNumber(int tvdbId, int seasonNumber)
|
||||
{
|
||||
var mappings = FindByTvdbId(tvdbId);
|
||||
@@ -266,7 +297,12 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
|
||||
private List<string> FilterNonEnglish(List<string> titles)
|
||||
{
|
||||
return titles.Where(title => title.All(c => c <= 255)).ToList();
|
||||
return titles.Where(IsEnglish).ToList();
|
||||
}
|
||||
|
||||
private bool IsEnglish(string title)
|
||||
{
|
||||
return title.All(c => c <= 255);
|
||||
}
|
||||
|
||||
public void Handle(SeriesRefreshStartingEvent message)
|
||||
|
||||
Reference in New Issue
Block a user