1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-25 22:37:27 -04:00

Treat XEM aliases as SceneSeasonNumber

Fixed: Aliases used incorrectly when TVDB season number matched the seaon number of the alias
Closes #1140
This commit is contained in:
Mark McDowall
2016-02-11 21:00:25 -08:00
parent 44e09e2220
commit 942be364dc
16 changed files with 80 additions and 32 deletions
@@ -6,7 +6,6 @@ namespace NzbDrone.Core.DataAugmentation.Scene
public class SceneMapping : ModelBase
{
public string Title { get; set; }
public string ParseTerm { get; set; }
[JsonProperty("searchTitle")]
@@ -15,8 +14,9 @@ namespace NzbDrone.Core.DataAugmentation.Scene
public int TvdbId { get; set; }
[JsonProperty("season")]
public int SeasonNumber { get; set; }
public int? SeasonNumber { get; set; }
public int? SceneSeasonNumber { get; set; }
public string Type { get; set; }
}
}
@@ -14,10 +14,11 @@ namespace NzbDrone.Core.DataAugmentation.Scene
{
public interface ISceneMappingService
{
List<string> GetSceneNames(int tvdbId, IEnumerable<int> seasonNumbers);
List<string> GetSceneNamesBySeasonNumbers(int tvdbId, IEnumerable<int> seasonNumbers);
List<string> GetSceneNamesBySceneSeasonNumbers(int tvdbId, IEnumerable<int> sceneSeasonNumbers);
int? FindTvdbId(string title);
List<SceneMapping> FindByTvdbId(int tvdbId);
int? GetSeasonNumber(string title);
int? GetSceneSeasonNumber(string title);
}
public class SceneMappingService : ISceneMappingService,
@@ -46,7 +47,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
_findByTvdbIdCache = cacheManager.GetCacheDictionary<List<SceneMapping>>(GetType(), "find_tvdb_id");
}
public List<string> GetSceneNames(int tvdbId, IEnumerable<int> seasonNumbers)
public List<string> GetSceneNamesBySeasonNumbers(int tvdbId, IEnumerable<int> seasonNumbers)
{
var names = _findByTvdbIdCache.Find(tvdbId.ToString());
@@ -55,11 +56,25 @@ namespace NzbDrone.Core.DataAugmentation.Scene
return new List<string>();
}
return FilterNonEnglish(names.Where(s => seasonNumbers.Contains(s.SeasonNumber) ||
return FilterNonEnglish(names.Where(s => s.SeasonNumber.HasValue && seasonNumbers.Contains(s.SeasonNumber.Value) ||
s.SeasonNumber == -1)
.Select(m => m.SearchTerm).Distinct().ToList());
}
public List<string> GetSceneNamesBySceneSeasonNumbers(int tvdbId, IEnumerable<int> sceneSeasonNumbers)
{
var names = _findByTvdbIdCache.Find(tvdbId.ToString());
if (names == null)
{
return new List<string>();
}
return FilterNonEnglish(names.Where(s => s.SceneSeasonNumber.HasValue && sceneSeasonNumbers.Contains(s.SceneSeasonNumber.Value) ||
s.SceneSeasonNumber == -1)
.Select(m => m.SearchTerm).Distinct().ToList());
}
public int? FindTvdbId(string title)
{
var mapping = FindMapping(title);
@@ -87,14 +102,16 @@ namespace NzbDrone.Core.DataAugmentation.Scene
return mappings;
}
public int? GetSeasonNumber(string title)
public int? GetSceneSeasonNumber(string title)
{
var mapping = FindMapping(title);
if (mapping == null)
{
return null;
}
return mapping.SeasonNumber;
return mapping.SceneSeasonNumber;
}
private void UpdateMappings()
@@ -106,7 +106,7 @@ namespace NzbDrone.Core.DataAugmentation.Xem
{
Title = n.Key,
SearchTerm = n.Key,
SeasonNumber = seasonNumber,
SceneSeasonNumber = seasonNumber,
TvdbId = series.Key
});
}