mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: Parsing release group from file rather than folder in case of season packs
This commit is contained in:
parent
d4bcf28d08
commit
b4405b0600
@ -0,0 +1,122 @@
|
|||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators;
|
||||||
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Aggregation.Aggregators
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class AggregateReleaseGroupFixture : CoreTest<AggregateReleaseGroup>
|
||||||
|
{
|
||||||
|
private Series _series;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_series = Builder<Series>.CreateNew().Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_use_downloadclient_for_full_season()
|
||||||
|
{
|
||||||
|
var fileEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Wizzy");
|
||||||
|
var downloadClientEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01.WEB-DL-Viva");
|
||||||
|
var localEpisode = new LocalEpisode
|
||||||
|
{
|
||||||
|
FileEpisodeInfo = fileEpisodeInfo,
|
||||||
|
DownloadClientEpisodeInfo = downloadClientEpisodeInfo,
|
||||||
|
Path = @"C:\Test\Unsorted TV\Series.Title.S01\Series.Title.S01E01.WEB-DL.mkv".AsOsAgnostic(),
|
||||||
|
Series = _series
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Aggregate(localEpisode, false);
|
||||||
|
|
||||||
|
localEpisode.ReleaseGroup.Should().Be("Wizzy");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_use_folder_for_full_season()
|
||||||
|
{
|
||||||
|
var fileEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Wizzy");
|
||||||
|
var folderEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01.WEB-DL-Drone");
|
||||||
|
var localEpisode = new LocalEpisode
|
||||||
|
{
|
||||||
|
FileEpisodeInfo = fileEpisodeInfo,
|
||||||
|
FolderEpisodeInfo = folderEpisodeInfo,
|
||||||
|
Path = @"C:\Test\Unsorted TV\Series.Title.S01\Series.Title.S01E01.WEB-DL.mkv".AsOsAgnostic(),
|
||||||
|
Series = _series
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Aggregate(localEpisode, false);
|
||||||
|
|
||||||
|
localEpisode.ReleaseGroup.Should().Be("Wizzy");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_prefer_downloadclient()
|
||||||
|
{
|
||||||
|
var fileEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Wizzy");
|
||||||
|
var folderEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Drone");
|
||||||
|
var downloadClientEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Viva");
|
||||||
|
var localEpisode = new LocalEpisode
|
||||||
|
{
|
||||||
|
FileEpisodeInfo = fileEpisodeInfo,
|
||||||
|
FolderEpisodeInfo = folderEpisodeInfo,
|
||||||
|
DownloadClientEpisodeInfo = downloadClientEpisodeInfo,
|
||||||
|
Path = @"C:\Test\Unsorted TV\Series.Title.S01\Series.Title.S01E01.WEB-DL.mkv".AsOsAgnostic(),
|
||||||
|
Series = _series
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Aggregate(localEpisode, false);
|
||||||
|
|
||||||
|
localEpisode.ReleaseGroup.Should().Be("Viva");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_prefer_folder()
|
||||||
|
{
|
||||||
|
var fileEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Wizzy");
|
||||||
|
var folderEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Drone");
|
||||||
|
var downloadClientEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL");
|
||||||
|
var localEpisode = new LocalEpisode
|
||||||
|
{
|
||||||
|
FileEpisodeInfo = fileEpisodeInfo,
|
||||||
|
FolderEpisodeInfo = folderEpisodeInfo,
|
||||||
|
DownloadClientEpisodeInfo = downloadClientEpisodeInfo,
|
||||||
|
Path = @"C:\Test\Unsorted TV\Series.Title.S01\Series.Title.S01E01.WEB-DL.mkv".AsOsAgnostic(),
|
||||||
|
Series = _series
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Aggregate(localEpisode, false);
|
||||||
|
|
||||||
|
localEpisode.ReleaseGroup.Should().Be("Drone");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_fallback_to_file()
|
||||||
|
{
|
||||||
|
var fileEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL-Wizzy");
|
||||||
|
var folderEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL");
|
||||||
|
var downloadClientEpisodeInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.WEB-DL");
|
||||||
|
var localEpisode = new LocalEpisode
|
||||||
|
{
|
||||||
|
FileEpisodeInfo = fileEpisodeInfo,
|
||||||
|
FolderEpisodeInfo = folderEpisodeInfo,
|
||||||
|
DownloadClientEpisodeInfo = downloadClientEpisodeInfo,
|
||||||
|
Path = @"C:\Test\Unsorted TV\Series.Title.S01\Series.Title.S01E01.mkv".AsOsAgnostic(),
|
||||||
|
Series = _series
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Aggregate(localEpisode, false);
|
||||||
|
|
||||||
|
localEpisode.ReleaseGroup.Should().Be("Wizzy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,21 +7,42 @@ public class AggregateReleaseGroup : IAggregateLocalEpisode
|
|||||||
{
|
{
|
||||||
public LocalEpisode Aggregate(LocalEpisode localEpisode, bool otherFiles)
|
public LocalEpisode Aggregate(LocalEpisode localEpisode, bool otherFiles)
|
||||||
{
|
{
|
||||||
var releaseGroup = localEpisode.DownloadClientEpisodeInfo?.ReleaseGroup;
|
// Prefer ReleaseGroup from DownloadClient/Folder if they're not a season pack
|
||||||
|
var releaseGroup = GetReleaseGroup(localEpisode.DownloadClientEpisodeInfo, true);
|
||||||
|
|
||||||
if (releaseGroup.IsNullOrWhiteSpace())
|
if (releaseGroup.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
releaseGroup = localEpisode.FolderEpisodeInfo?.ReleaseGroup;
|
releaseGroup = GetReleaseGroup(localEpisode.FolderEpisodeInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (releaseGroup.IsNullOrWhiteSpace())
|
if (releaseGroup.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
releaseGroup = localEpisode.FileEpisodeInfo?.ReleaseGroup;
|
releaseGroup = GetReleaseGroup(localEpisode.FileEpisodeInfo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseGroup.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
releaseGroup = GetReleaseGroup(localEpisode.DownloadClientEpisodeInfo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseGroup.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
releaseGroup = GetReleaseGroup(localEpisode.FolderEpisodeInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
localEpisode.ReleaseGroup = releaseGroup;
|
localEpisode.ReleaseGroup = releaseGroup;
|
||||||
|
|
||||||
return localEpisode;
|
return localEpisode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetReleaseGroup(ParsedEpisodeInfo episodeInfo, bool skipFullSeason)
|
||||||
|
{
|
||||||
|
if (episodeInfo == null || episodeInfo.FullSeason && skipFullSeason)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return episodeInfo.ReleaseGroup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user