mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01: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:
parent
44e09e2220
commit
942be364dc
@ -6,5 +6,6 @@ public class AlternateTitleResource
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public int SceneSeasonNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -187,16 +187,15 @@ public void should_return_single_match(string parseTitle, string title, int expe
|
||||
{
|
||||
var mappings = new List<SceneMapping>
|
||||
{
|
||||
new SceneMapping { Title = "Working!!", ParseTerm = "working", SearchTerm = "Working!!", TvdbId = 100, SeasonNumber = -1 },
|
||||
new SceneMapping { Title = "Working!!", ParseTerm = "working", SearchTerm = "Working!!", TvdbId = 100, SeasonNumber = 1 },
|
||||
new SceneMapping { Title = "Working`!!", ParseTerm = "working", SearchTerm = "Working`!!", TvdbId = 100, SeasonNumber = 2 },
|
||||
new SceneMapping { Title = "Working!!!", ParseTerm = "working", SearchTerm = "Working!!!", TvdbId = 100, SeasonNumber = 3 },
|
||||
new SceneMapping { Title = "Working!!", ParseTerm = "working", SearchTerm = "Working!!", TvdbId = 100, SceneSeasonNumber = 1 },
|
||||
new SceneMapping { Title = "Working`!!", ParseTerm = "working", SearchTerm = "Working`!!", TvdbId = 100, SceneSeasonNumber = 2 },
|
||||
new SceneMapping { Title = "Working!!!", ParseTerm = "working", SearchTerm = "Working!!!", TvdbId = 100, SceneSeasonNumber = 3 },
|
||||
};
|
||||
|
||||
Mocker.GetMock<ISceneMappingRepository>().Setup(c => c.All()).Returns(mappings);
|
||||
|
||||
var tvdbId = Subject.FindTvdbId(parseTitle);
|
||||
var seasonNumber = Subject.GetSeasonNumber(parseTitle);
|
||||
var seasonNumber = Subject.GetSceneSeasonNumber(parseTitle);
|
||||
|
||||
tvdbId.Should().Be(100);
|
||||
seasonNumber.Should().Be(expectedSeasonNumber);
|
||||
@ -217,7 +216,7 @@ private void AssertMappingUpdated()
|
||||
|
||||
foreach (var sceneMapping in _fakeMappings)
|
||||
{
|
||||
Subject.GetSceneNames(sceneMapping.TvdbId, _fakeMappings.Select(m => m.SeasonNumber)).Should().Contain(sceneMapping.SearchTerm);
|
||||
Subject.GetSceneNamesBySeasonNumbers(sceneMapping.TvdbId, _fakeMappings.Select(m => m.SeasonNumber.Value)).Should().Contain(sceneMapping.SearchTerm);
|
||||
Subject.FindTvdbId(sceneMapping.ParseTerm).Should().Be(sceneMapping.TvdbId);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,11 @@ public void SetUp()
|
||||
.Returns<int, int>((i, j) => _xemEpisodes.Where(d => d.SeasonNumber == j).ToList());
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Setup(s => s.GetSceneNames(It.IsAny<int>(), It.IsAny<IEnumerable<int>>()))
|
||||
.Setup(s => s.GetSceneNamesBySeasonNumbers(It.IsAny<int>(), It.IsAny<IEnumerable<int>>()))
|
||||
.Returns(new List<string>());
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Setup(s => s.GetSceneNamesBySceneSeasonNumbers(It.IsAny<int>(), It.IsAny<IEnumerable<int>>()))
|
||||
.Returns(new List<string>());
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ public void should_use_scene_numbering_when_scene_season_number_has_value(int se
|
||||
GivenAbsoluteNumberingSeries();
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Setup(s => s.GetSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
|
||||
.Setup(s => s.GetSceneSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
|
||||
.Returns(seasonNumber);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
@ -234,7 +234,7 @@ public void should_find_episode_by_season_and_scene_absolute_episode_number(int
|
||||
GivenAbsoluteNumberingSeries();
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Setup(s => s.GetSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
|
||||
.Setup(s => s.GetSceneSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
|
||||
.Returns(seasonNumber);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
@ -258,7 +258,7 @@ public void should_find_episode_by_season_and_absolute_episode_number_when_scene
|
||||
GivenAbsoluteNumberingSeries();
|
||||
|
||||
Mocker.GetMock<ISceneMappingService>()
|
||||
.Setup(s => s.GetSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
|
||||
.Setup(s => s.GetSceneSeasonNumber(_parsedEpisodeInfo.SeriesTitle))
|
||||
.Returns(seasonNumber);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
|
@ -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 @@ public class SceneMapping : ModelBase
|
||||
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 @@ public SceneMappingService(ISceneMappingRepository repository,
|
||||
_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 @@ public List<string> GetSceneNames(int tvdbId, IEnumerable<int> seasonNumbers)
|
||||
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 @@ public List<SceneMapping> FindByTvdbId(int tvdbId)
|
||||
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 @@ public List<SceneMapping> GetSceneTvdbNames()
|
||||
{
|
||||
Title = n.Key,
|
||||
SearchTerm = n.Key,
|
||||
SeasonNumber = seasonNumber,
|
||||
SceneSeasonNumber = seasonNumber,
|
||||
TvdbId = series.Key
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(100)]
|
||||
public class add_scene_season_number : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("SceneMappings").AlterColumn("SeasonNumber").AsInt32().Nullable();
|
||||
Alter.Table("SceneMappings").AddColumn("SceneSeasonNumber").AsInt32().Nullable();
|
||||
}
|
||||
}
|
||||
}
|
@ -2,17 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Queue;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
namespace NzbDrone.Core.IndexerSearch
|
||||
{
|
||||
|
@ -233,10 +233,12 @@ private List<DownloadDecision> SearchAnimeSeason(Series series, List<Episode> ep
|
||||
var spec = new TSpec();
|
||||
|
||||
spec.Series = series;
|
||||
spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId,
|
||||
episodes.Select(e => e.SeasonNumber)
|
||||
.Concat(episodes.Where(v => v.SceneSeasonNumber.HasValue).Select(e => e.SceneSeasonNumber.Value)
|
||||
.Distinct()));
|
||||
spec.SceneTitles = _sceneMapping.GetSceneNamesBySeasonNumbers(series.TvdbId, episodes.Select(e => e.SeasonNumber))
|
||||
.Concat(_sceneMapping.GetSceneNamesBySceneSeasonNumbers(series.TvdbId,
|
||||
episodes.Where(v => v.SceneSeasonNumber.HasValue)
|
||||
.Select(e => e.SceneSeasonNumber.Value)))
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
spec.Episodes = episodes;
|
||||
|
||||
|
@ -274,6 +274,7 @@
|
||||
<Compile Include="Datastore\Migration\091_added_indexerstatus.cs" />
|
||||
<Compile Include="Datastore\Migration\093_naming_config_replace_characters.cs" />
|
||||
<Compile Include="Datastore\Migration\092_add_unverifiedscenenumbering.cs" />
|
||||
<Compile Include="Datastore\Migration\100_add_scene_season_number.cs" />
|
||||
<Compile Include="Datastore\Migration\094_add_tvmazeid.cs" />
|
||||
<Compile Include="Datastore\Migration\098_remove_titans_of_tv.cs">
|
||||
<SubType>Code</SubType>
|
||||
|
@ -168,7 +168,7 @@ public List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series ser
|
||||
|
||||
if (parsedEpisodeInfo.IsAbsoluteNumbering)
|
||||
{
|
||||
var sceneSeasonNumber = _sceneMappingService.GetSeasonNumber(parsedEpisodeInfo.SeriesTitle);
|
||||
var sceneSeasonNumber = _sceneMappingService.GetSceneSeasonNumber(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
foreach (var absoluteEpisodeNumber in parsedEpisodeInfo.AbsoluteEpisodeNumbers)
|
||||
{
|
||||
@ -195,8 +195,7 @@ public List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series ser
|
||||
|
||||
if (episode == null)
|
||||
{
|
||||
episode = _episodeService.FindEpisode(series.Id, sceneSeasonNumber.Value,
|
||||
absoluteEpisodeNumber);
|
||||
episode = _episodeService.FindEpisode(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ module.exports = NzbDroneCell.extend({
|
||||
if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {
|
||||
|
||||
if (this.model.get('sceneSeasonNumber') > 0) {
|
||||
alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySeasonNumber, this.model.get('seriesId'), this.model.get('sceneSeasonNumber'));
|
||||
alternateTitles = reqres.request(reqres.Requests.GetAlternateNameBySceneSeasonNumber, this.model.get('seriesId'), this.model.get('sceneSeasonNumber'));
|
||||
}
|
||||
|
||||
if (alternateTitles.length === 0) {
|
||||
|
@ -55,6 +55,10 @@
|
||||
{{#if_eq seasonNumber compare="-1"}}
|
||||
<span class="label label-default">{{title}}</span>
|
||||
{{/if_eq}}
|
||||
|
||||
{{#if_eq sceneSeasonNumber compare="-1"}}
|
||||
<span class="label label-default">{{title}}</span>
|
||||
{{/if_eq}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -182,6 +182,14 @@ module.exports = Marionette.Layout.extend({
|
||||
return _.where(self.model.get('alternateTitles'), { seasonNumber : seasonNumber });
|
||||
});
|
||||
|
||||
reqres.setHandler(reqres.Requests.GetAlternateNameBySceneSeasonNumber, function(seriesId, sceneSeasonNumber) {
|
||||
if (self.model.get('id') !== seriesId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return _.where(self.model.get('alternateTitles'), { sceneSeasonNumber : sceneSeasonNumber });
|
||||
});
|
||||
|
||||
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function() {
|
||||
var seasonCollectionView = new SeasonCollectionView({
|
||||
collection : self.seasonCollection,
|
||||
|
@ -3,8 +3,9 @@ var Wreqr = require('./JsLibraries/backbone.wreqr');
|
||||
var reqres = new Wreqr.RequestResponse();
|
||||
|
||||
reqres.Requests = {
|
||||
GetEpisodeFileById : 'GetEpisodeFileById',
|
||||
GetAlternateNameBySeasonNumber : 'GetAlternateNameBySeasonNumber'
|
||||
GetEpisodeFileById : 'GetEpisodeFileById',
|
||||
GetAlternateNameBySeasonNumber : 'GetAlternateNameBySeasonNumber',
|
||||
GetAlternateNameBySceneSeasonNumber : 'GetAlternateNameBySceneSeasonNumber'
|
||||
};
|
||||
|
||||
module.exports = reqres;
|
Loading…
Reference in New Issue
Block a user