Fixed: Calculating custom formats with languages in queue
This commit is contained in:
parent
2f04b037a1
commit
566af75c4d
|
@ -65,16 +65,17 @@ namespace NzbDrone.Core.Test.Download.Aggregation.Aggregators
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_multi_languages_when_indexer_has_multi_languages_configuration()
|
||||
public void should_return_multi_languages_when_indexer_id_has_multi_languages_configuration()
|
||||
{
|
||||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(indexerDefinition);
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition });
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = GetParsedEpisodeInfo(new List<Language> { }, releaseTitle);
|
||||
_remoteEpisode.Release.IndexerId = 1;
|
||||
|
@ -83,17 +84,40 @@ namespace NzbDrone.Core.Test.Download.Aggregation.Aggregators
|
|||
Subject.Aggregate(_remoteEpisode).Languages.Should().BeEquivalentTo(new List<Language> { _series.OriginalLanguage, Language.French });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_multi_languages_when_indexer_name_has_multi_languages_configuration()
|
||||
{
|
||||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Name = "MyIndexer (Prowlarr)",
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition });
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = GetParsedEpisodeInfo(new List<Language> { }, releaseTitle);
|
||||
_remoteEpisode.Release.Indexer = "MyIndexer (Prowlarr)";
|
||||
_remoteEpisode.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteEpisode).Languages.Should().BeEquivalentTo(new List<Language> { _series.OriginalLanguage, Language.French });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_multi_languages_when_release_as_unknown_as_default_language_and_indexer_has_multi_languages_configuration()
|
||||
{
|
||||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(indexerDefinition);
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition });
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = GetParsedEpisodeInfo(new List<Language> { Language.Unknown }, releaseTitle);
|
||||
_remoteEpisode.Release.IndexerId = 1;
|
||||
|
@ -108,11 +132,12 @@ namespace NzbDrone.Core.Test.Download.Aggregation.Aggregators
|
|||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Settings = new TorrentRssIndexerSettings { }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(1))
|
||||
.Returns(indexerDefinition);
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition });
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = GetParsedEpisodeInfo(new List<Language> { }, releaseTitle);
|
||||
_remoteEpisode.Release.IndexerId = 1;
|
||||
|
@ -121,6 +146,25 @@ namespace NzbDrone.Core.Test.Download.Aggregation.Aggregators
|
|||
Subject.Aggregate(_remoteEpisode).Languages.Should().BeEquivalentTo(new List<Language> { _series.OriginalLanguage });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_original_when_no_indexer_value()
|
||||
{
|
||||
var releaseTitle = "Series.Title.S01E01.MULTi.1080p.WEB.H265-RlsGroup";
|
||||
var indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Settings = new TorrentRssIndexerSettings { }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition });
|
||||
|
||||
_remoteEpisode.ParsedEpisodeInfo = GetParsedEpisodeInfo(new List<Language> { }, releaseTitle);
|
||||
_remoteEpisode.Release.Title = releaseTitle;
|
||||
|
||||
Subject.Aggregate(_remoteEpisode).Languages.Should().BeEquivalentTo(new List<Language> { _series.OriginalLanguage });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_exclude_language_that_is_part_of_episode_title_when_release_tokens_contains_episode_title()
|
||||
{
|
||||
|
|
|
@ -7,6 +7,8 @@ using NzbDrone.Core.Download;
|
|||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.TorrentRss;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -84,6 +86,80 @@ namespace NzbDrone.Core.Test.Download.TrackedDownloads
|
|||
trackedDownload.RemoteEpisode.MappedSeasonNumber.Should().Be(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_set_indexer()
|
||||
{
|
||||
var episodeHistory = new EpisodeHistory()
|
||||
{
|
||||
DownloadId = "35238",
|
||||
SourceTitle = "TV Series S01",
|
||||
SeriesId = 5,
|
||||
EpisodeId = 4,
|
||||
EventType = EpisodeHistoryEventType.Grabbed,
|
||||
};
|
||||
episodeHistory.Data.Add("indexer", "MyIndexer (Prowlarr)");
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.FindByDownloadId(It.Is<string>(sr => sr == "35238")))
|
||||
.Returns(new List<EpisodeHistory>()
|
||||
{
|
||||
episodeHistory
|
||||
});
|
||||
|
||||
var indexerDefinition = new IndexerDefinition
|
||||
{
|
||||
Id = 1,
|
||||
Name = "MyIndexer (Prowlarr)",
|
||||
Settings = new TorrentRssIndexerSettings { MultiLanguages = new List<int> { Language.Original.Id, Language.French.Id } }
|
||||
};
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.Get(indexerDefinition.Id))
|
||||
.Returns(indexerDefinition);
|
||||
Mocker.GetMock<IIndexerFactory>()
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<IndexerDefinition>() { indexerDefinition });
|
||||
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
Series = new Series() { Id = 5 },
|
||||
Episodes = new List<Episode> { new Episode { Id = 4 } },
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo()
|
||||
{
|
||||
SeriesTitle = "TV Series",
|
||||
SeasonNumber = 1
|
||||
},
|
||||
MappedSeasonNumber = 1
|
||||
};
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), null))
|
||||
.Returns(remoteEpisode);
|
||||
|
||||
var client = new DownloadClientDefinition()
|
||||
{
|
||||
Id = 1,
|
||||
Protocol = DownloadProtocol.Torrent
|
||||
};
|
||||
|
||||
var item = new DownloadClientItem()
|
||||
{
|
||||
Title = "TV.Series.S01.MULTi.1080p.WEB.H265-RlsGroup",
|
||||
DownloadId = "35238",
|
||||
DownloadClientInfo = new DownloadClientItemClientInfo
|
||||
{
|
||||
Protocol = client.Protocol,
|
||||
Id = client.Id,
|
||||
Name = client.Name
|
||||
}
|
||||
};
|
||||
|
||||
var trackedDownload = Subject.TrackDownload(client, item);
|
||||
|
||||
trackedDownload.Should().NotBeNull();
|
||||
trackedDownload.RemoteEpisode.Should().NotBeNull();
|
||||
trackedDownload.RemoteEpisode.Release.Should().NotBeNull();
|
||||
trackedDownload.RemoteEpisode.Release.Indexer.Should().Be("MyIndexer (Prowlarr)");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_parse_as_special_when_source_title_parsing_fails()
|
||||
{
|
||||
|
|
|
@ -76,9 +76,14 @@ namespace NzbDrone.Core.Download.Aggregation.Aggregators
|
|||
languages = languages.Except(languagesToRemove).ToList();
|
||||
}
|
||||
|
||||
if ((languages.Count == 0 || (languages.Count == 1 && languages.First() == Language.Unknown)) && releaseInfo is { IndexerId: > 0 } && releaseInfo.Title.IsNotNullOrWhiteSpace())
|
||||
if ((languages.Count == 0 || (languages.Count == 1 && languages.First() == Language.Unknown)) &&
|
||||
releaseInfo?.Title?.IsNotNullOrWhiteSpace() == true &&
|
||||
(releaseInfo is { IndexerId: > 0 } || releaseInfo.Indexer?.IsNotNullOrWhiteSpace() == true))
|
||||
{
|
||||
var indexer = _indexerFactory.Get(releaseInfo.IndexerId);
|
||||
var indexer = _indexerFactory.All()
|
||||
.FirstOrDefault(v =>
|
||||
(releaseInfo is { IndexerId: > 0 } && releaseInfo.IndexerId == v.Id) ||
|
||||
(releaseInfo.Indexer?.IsNotNullOrWhiteSpace() == true && v.Name.EqualsIgnoreCase(releaseInfo.Indexer)));
|
||||
|
||||
if (indexer?.Settings is IIndexerSettings settings && settings.MultiLanguages.Any() && Parser.Parser.HasMultipleLanguages(releaseInfo.Title))
|
||||
{
|
||||
|
|
|
@ -120,8 +120,6 @@ namespace NzbDrone.Core.Download.TrackedDownloads
|
|||
if (parsedEpisodeInfo != null)
|
||||
{
|
||||
trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0, 0, null);
|
||||
|
||||
_aggregationService.Augment(trackedDownload.RemoteEpisode);
|
||||
}
|
||||
|
||||
var downloadHistory = _downloadHistoryService.GetLatestDownloadHistoryItem(downloadItem.DownloadId);
|
||||
|
@ -158,17 +156,24 @@ namespace NzbDrone.Core.Download.TrackedDownloads
|
|||
}
|
||||
}
|
||||
|
||||
if (trackedDownload.RemoteEpisode != null &&
|
||||
Enum.TryParse(grabbedEvent?.Data?.GetValueOrDefault("indexerFlags"), true, out IndexerFlags flags))
|
||||
if (trackedDownload.RemoteEpisode != null)
|
||||
{
|
||||
trackedDownload.RemoteEpisode.Release ??= new ReleaseInfo();
|
||||
trackedDownload.RemoteEpisode.Release.Indexer = trackedDownload.Indexer;
|
||||
trackedDownload.RemoteEpisode.Release.Title = trackedDownload.RemoteEpisode.ParsedEpisodeInfo?.ReleaseTitle;
|
||||
|
||||
if (Enum.TryParse(grabbedEvent?.Data?.GetValueOrDefault("indexerFlags"), true, out IndexerFlags flags))
|
||||
{
|
||||
trackedDownload.RemoteEpisode.Release.IndexerFlags = flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate custom formats
|
||||
if (trackedDownload.RemoteEpisode != null)
|
||||
{
|
||||
_aggregationService.Augment(trackedDownload.RemoteEpisode);
|
||||
|
||||
// Calculate custom formats
|
||||
trackedDownload.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(trackedDownload.RemoteEpisode, downloadItem.TotalSize);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue