mirror of
https://github.com/Radarr/Radarr
synced 2024-12-21 23:42:23 +00:00
Fixed: Augmenting languages from indexer for release with stale indexer ID
(cherry picked from commit cb7489ce8fe933920ea04297bd2941496a0c07c6) Closes #10768
This commit is contained in:
parent
4e024c51d3
commit
8c6ba9a543
2 changed files with 91 additions and 10 deletions
|
@ -74,7 +74,7 @@ public void should_return_multi_languages_when_indexer_id_has_multi_languages_co
|
|||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Setup(v => v.Find(1))
|
||||
.Returns(indexerDefinition);
|
||||
|
||||
_remoteMovie.ParsedMovieInfo = GetParsedMovieInfo(new List<Language> { }, releaseTitle);
|
||||
|
@ -82,7 +82,7 @@ public void should_return_multi_languages_when_indexer_id_has_multi_languages_co
|
|||
_remoteMovie.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().BeEquivalentTo(new List<Language> { _movie.MovieMetadata.Value.OriginalLanguage, Language.French });
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Get(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Find(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public void should_return_multi_languages_from_indexer_with_id_when_indexer_id_a
|
|||
};
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Setup(v => v.Find(1))
|
||||
.Returns(indexerDefinition1);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
|
@ -117,7 +117,7 @@ public void should_return_multi_languages_from_indexer_with_id_when_indexer_id_a
|
|||
_remoteMovie.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().BeEquivalentTo(new List<Language> { _movie.MovieMetadata.Value.OriginalLanguage, Language.French });
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Get(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Find(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public void should_return_multi_languages_when_release_as_unknown_as_default_lan
|
|||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Setup(v => v.Find(1))
|
||||
.Returns(indexerDefinition);
|
||||
|
||||
_remoteMovie.ParsedMovieInfo = GetParsedMovieInfo(new List<Language> { Language.Unknown }, releaseTitle);
|
||||
|
@ -163,7 +163,7 @@ public void should_return_multi_languages_when_release_as_unknown_as_default_lan
|
|||
_remoteMovie.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().BeEquivalentTo(new List<Language> { _movie.MovieMetadata.Value.OriginalLanguage, Language.French });
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Get(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Find(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ public void should_return_original_when_indexer_has_no_multi_languages_configura
|
|||
Settings = new TorrentRssIndexerSettings { }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Setup(v => v.Find(1))
|
||||
.Returns(indexerDefinition);
|
||||
|
||||
_remoteMovie.ParsedMovieInfo = GetParsedMovieInfo(new List<Language> { }, releaseTitle);
|
||||
|
@ -185,7 +185,7 @@ public void should_return_original_when_indexer_has_no_multi_languages_configura
|
|||
_remoteMovie.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().BeEquivalentTo(new List<Language> { _movie.MovieMetadata.Value.OriginalLanguage });
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Get(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Find(1), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
|
@ -248,5 +248,85 @@ public void should_use_reparse_language_after_determining_languages_that_are_in_
|
|||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().Equal(Language.Greek);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_multi_languages_from_indexer_with_name_when_indexer_id_does_not_exist()
|
||||
{
|
||||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition1 = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Name = "MyIndexer1",
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
var indexerDefinition2 = new IndexerDefinition
|
||||
{
|
||||
Id = 2,
|
||||
Name = "MyIndexer2",
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.German.Id } }
|
||||
};
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Find(1))
|
||||
.Returns(null as IndexerDefinition);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.FindByName("MyIndexer1"))
|
||||
.Returns(indexerDefinition1);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition1, indexerDefinition2 });
|
||||
|
||||
_remoteMovie.ParsedMovieInfo = GetParsedMovieInfo(new List<Language> { }, releaseTitle);
|
||||
_remoteMovie.Release.IndexerId = 10;
|
||||
_remoteMovie.Release.Indexer = "MyIndexer1";
|
||||
_remoteMovie.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().BeEquivalentTo(new List<Language> { _movie.MovieMetadata.Value.OriginalLanguage, Language.French });
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Find(10), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.FindByName("MyIndexer1"), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_multi_languages_from_indexer_with_name_when_indexer_id_not_available()
|
||||
{
|
||||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition1 = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Name = "MyIndexer1",
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
var indexerDefinition2 = new IndexerDefinition
|
||||
{
|
||||
Id = 2,
|
||||
Name = "MyIndexer2",
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.German.Id } }
|
||||
};
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Find(1))
|
||||
.Returns(null as IndexerDefinition);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.FindByName("MyIndexer1"))
|
||||
.Returns(indexerDefinition1);
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition1, indexerDefinition2 });
|
||||
|
||||
_remoteMovie.ParsedMovieInfo = GetParsedMovieInfo(new List<Language> { }, releaseTitle);
|
||||
_remoteMovie.Release.IndexerId = 0;
|
||||
_remoteMovie.Release.Indexer = "MyIndexer1";
|
||||
_remoteMovie.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteMovie).Languages.Should().BeEquivalentTo(new List<Language> { _movie.MovieMetadata.Value.OriginalLanguage, Language.French });
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.Find(10), Times.Never());
|
||||
Mocker.GetMock<IIndexerFactory>().Verify(c => c.FindByName("MyIndexer1"), Times.Once());
|
||||
Mocker.GetMock<IIndexerFactory>().VerifyNoOtherCalls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,9 +77,10 @@ public RemoteMovie Aggregate(RemoteMovie remoteMovie)
|
|||
|
||||
if (releaseInfo is { IndexerId: > 0 })
|
||||
{
|
||||
indexer = _indexerFactory.Get(releaseInfo.IndexerId);
|
||||
indexer = _indexerFactory.Find(releaseInfo.IndexerId);
|
||||
}
|
||||
else if (releaseInfo.Indexer?.IsNotNullOrWhiteSpace() == true)
|
||||
|
||||
if (indexer == null && releaseInfo.Indexer?.IsNotNullOrWhiteSpace() == true)
|
||||
{
|
||||
indexer = _indexerFactory.FindByName(releaseInfo.Indexer);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue