|
|
|
@ -10,209 +10,404 @@ namespace ErsatzTV.Core.Tests.Metadata |
|
|
|
[TestFixture] |
|
|
|
[TestFixture] |
|
|
|
public class TestMediaScannerTests |
|
|
|
public class TestMediaScannerTests |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly TestMediaScanner _scanner = new(); |
|
|
|
[TestFixture] |
|
|
|
|
|
|
|
public class NewMovieTests |
|
|
|
[Test] |
|
|
|
|
|
|
|
public void NewMovieFile_WithoutNfo_WithoutPoster() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
private readonly TestMediaScanner _scanner = new(); |
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
|
|
|
|
string[] fileNames = { movieFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.FallbackMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
[Test] |
|
|
|
public void NewMovieFile_WithNfo_WithoutPoster( |
|
|
|
public void WithoutNfo_WithoutPoster() |
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
{ |
|
|
|
string nfoFile) |
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
{ |
|
|
|
string[] fileNames = { movieFileName }; |
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
|
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
|
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
|
|
|
|
string[] fileNames = { movieFileName, nfoFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
public void NewMovieFile_WithoutNfo_WithPoster( |
|
|
|
MediaType.Movie, |
|
|
|
[Values("", "test (2021)-")] |
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
string basePosterName, |
|
|
|
fileNames.ToSeq()); |
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
|
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
|
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] fileNames = { movieFileName, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.FallbackMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
result.Count.Should().Be(1); |
|
|
|
public void NewMovieFile_WithNfo_WithPoster( |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
string nfoFile, |
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
[Values("", "test (2021)-")] |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
string basePosterName, |
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.FallbackMetadata), |
|
|
|
string posterExtension) |
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
{ |
|
|
|
} |
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
|
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
[Test] |
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
public void WithNfo_WithoutPoster( |
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
|
|
|
|
string nfoFile) |
|
|
|
string[] fileNames = { movieFileName, nfoFileName, posterFileName }; |
|
|
|
{ |
|
|
|
|
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
MediaType.Movie, |
|
|
|
string[] fileNames = { movieFileName, nfoFileName }; |
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
result.Count.Should().Be(1); |
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
fileNames.ToSeq()); |
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
result.Count.Should().Be(1); |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithoutNfo_WithPoster( |
|
|
|
|
|
|
|
[Values("", "test (2021)-")] |
|
|
|
|
|
|
|
string basePosterName, |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
|
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] fileNames = { movieFileName, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.FallbackMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNfo_WithPoster( |
|
|
|
|
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
|
|
|
|
string nfoFile, |
|
|
|
|
|
|
|
[Values("", "test (2021)-")] |
|
|
|
|
|
|
|
string basePosterName, |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var movieFileName = "/movies/test (2021)/test (2021).mkv"; |
|
|
|
|
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
|
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] fileNames = { movieFileName, nfoFileName, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(movieFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: mtime should affect this
|
|
|
|
[TestFixture] |
|
|
|
[Test] |
|
|
|
public class ExistingMovieTests |
|
|
|
public void ExistingMovieFile_WithNewNfo_WithoutPoster( |
|
|
|
|
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
|
|
|
|
string nfoFile) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
private readonly TestMediaScanner _scanner = new(); |
|
|
|
var movieMediaItem = new MediaItem |
|
|
|
|
|
|
|
|
|
|
|
// TODO: mtime should affect this
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNewNfo_WithoutPoster( |
|
|
|
|
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
|
|
|
|
string nfoFile) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
var movieMediaItem = new MediaItem |
|
|
|
Path = "/movies/test (2021)/test (2021).mkv" |
|
|
|
{ |
|
|
|
}; |
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
|
|
|
|
Path = "/movies/test (2021)/test (2021).mkv" |
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
}; |
|
|
|
string[] fileNames = { movieMediaItem.Path, nfoFileName }; |
|
|
|
|
|
|
|
|
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
string[] fileNames = { movieMediaItem.Path, nfoFileName }; |
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq.create(movieMediaItem), |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
fileNames.ToSeq()); |
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq.create(movieMediaItem), |
|
|
|
result.Count.Should().Be(1); |
|
|
|
fileNames.ToSeq()); |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
result.Count.Should().Be(1); |
|
|
|
source.RightToSeq().Should().BeEquivalentTo(movieMediaItem); |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
source.RightToSeq().Should().BeEquivalentTo(movieMediaItem); |
|
|
|
new ItemScanningPlan(movieMediaItem.Path, ScanningAction.Collections)); |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieMediaItem.Path, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithoutNfo_WithNewPoster( |
|
|
|
|
|
|
|
[Values("", "test (2021)-")] |
|
|
|
|
|
|
|
string basePosterName, |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var movieMediaItem = new MediaItem |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
|
|
|
|
Path = "/movies/test (2021)/test (2021).mkv" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
|
|
|
|
string[] fileNames = { movieMediaItem.Path, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq.create(movieMediaItem), |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
|
|
|
|
source.RightToSeq().Should().BeEquivalentTo(movieMediaItem); |
|
|
|
|
|
|
|
itemScanningPlans.Should() |
|
|
|
|
|
|
|
.BeEquivalentTo(new ItemScanningPlan(posterFileName, ScanningAction.Poster)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNewNfo_WithNewPoster( |
|
|
|
|
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
|
|
|
|
string nfoFile, |
|
|
|
|
|
|
|
[Values("", "test (2021)-")] |
|
|
|
|
|
|
|
string basePosterName, |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var movieMediaItem = new MediaItem |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
|
|
|
|
Path = "/movies/test (2021)/test (2021).mkv" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
|
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
|
|
|
|
string[] fileNames = { movieMediaItem.Path, nfoFileName, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
|
|
|
|
Seq.create(movieMediaItem), |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
|
|
|
|
source.RightToSeq().Should().BeEquivalentTo(movieMediaItem); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(movieMediaItem.Path, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
[TestFixture] |
|
|
|
public void ExistingMovieFile_WithoutNfo_WithNewPoster( |
|
|
|
public class NewEpisodeTests |
|
|
|
[Values("", "test (2021)-")] |
|
|
|
|
|
|
|
string basePosterName, |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
private readonly TestMediaScanner _scanner = new(); |
|
|
|
var movieMediaItem = new MediaItem |
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithoutNfo_WithoutPoster() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
var episodeFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv"; |
|
|
|
Path = "/movies/test (2021)/test (2021).mkv" |
|
|
|
string[] fileNames = { episodeFileName }; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
MediaType.TvShow, |
|
|
|
string[] fileNames = { movieMediaItem.Path, posterFileName }; |
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
result.Count.Should().Be(1); |
|
|
|
Seq.create(movieMediaItem), |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
fileNames.ToSeq()); |
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(episodeFileName); |
|
|
|
result.Count.Should().Be(1); |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Statistics), |
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.FallbackMetadata), |
|
|
|
source.RightToSeq().Should().BeEquivalentTo(movieMediaItem); |
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Collections)); |
|
|
|
itemScanningPlans.Should() |
|
|
|
} |
|
|
|
.BeEquivalentTo(new ItemScanningPlan(posterFileName, ScanningAction.Poster)); |
|
|
|
|
|
|
|
} |
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNfo_WithoutPoster() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var episodeFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv"; |
|
|
|
|
|
|
|
var nfoFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.nfo"; |
|
|
|
|
|
|
|
string[] fileNames = { episodeFileName, nfoFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.TvShow, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(episodeFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithoutNfo_WithPoster( |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var episodeFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv"; |
|
|
|
|
|
|
|
var posterFileName = $"/tv/test (2021)/poster.{posterExtension}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] fileNames = { episodeFileName, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.TvShow, |
|
|
|
|
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(episodeFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.FallbackMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNfo_WithPoster( |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var episodeFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv"; |
|
|
|
|
|
|
|
var nfoFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.nfo"; |
|
|
|
|
|
|
|
var posterFileName = $"/tv/test (2021)/poster.{posterExtension}"; |
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
string[] fileNames = { episodeFileName, nfoFileName, posterFileName }; |
|
|
|
public void ExistingMovieFile_WithNewNfo_WithNewPoster( |
|
|
|
|
|
|
|
[Values("test (2021).nfo", "movie.nfo")] |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
string nfoFile, |
|
|
|
MediaType.TvShow, |
|
|
|
[Values("", "test (2021)-")] |
|
|
|
Seq<MediaItem>.Empty, |
|
|
|
string basePosterName, |
|
|
|
fileNames.ToSeq()); |
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsLeft.Should().BeTrue(); |
|
|
|
|
|
|
|
source.LeftToSeq().Should().BeEquivalentTo(episodeFileName); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Statistics), |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeFileName, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestFixture] |
|
|
|
|
|
|
|
public class ExistingEpisodeTests |
|
|
|
{ |
|
|
|
{ |
|
|
|
// new movie file without nfo and without poster should have statistics and fallback metadata
|
|
|
|
private readonly TestMediaScanner _scanner = new(); |
|
|
|
var movieMediaItem = new MediaItem |
|
|
|
|
|
|
|
|
|
|
|
// TODO: mtime should affect this
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNewNfo_WithoutPoster() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var episodeMediaItem = new MediaItem |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
|
|
|
|
Path = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nfoFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.nfo"; |
|
|
|
|
|
|
|
string[] fileNames = { episodeMediaItem.Path, nfoFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.TvShow, |
|
|
|
|
|
|
|
Seq.create(episodeMediaItem), |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
|
|
|
|
source.RightToSeq().Should().BeEquivalentTo(episodeMediaItem); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeMediaItem.Path, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithoutNfo_WithNewPoster( |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
var episodeMediaItem = new MediaItem |
|
|
|
Path = "/movies/test (2021)/test (2021).mkv" |
|
|
|
{ |
|
|
|
}; |
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
|
|
|
|
Path = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv" |
|
|
|
var nfoFileName = $"/movies/test (2021)/{nfoFile}"; |
|
|
|
}; |
|
|
|
var posterFileName = $"/movies/test (2021)/{basePosterName}poster.{posterExtension}"; |
|
|
|
|
|
|
|
string[] fileNames = { movieMediaItem.Path, nfoFileName, posterFileName }; |
|
|
|
var posterFileName = $"/tv/test (2021)/poster.{posterExtension}"; |
|
|
|
|
|
|
|
string[] fileNames = { episodeMediaItem.Path, posterFileName }; |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.Movie, |
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
Seq.create(movieMediaItem), |
|
|
|
MediaType.TvShow, |
|
|
|
fileNames.ToSeq()); |
|
|
|
Seq.create(episodeMediaItem), |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
result.Count.Should().Be(1); |
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
source.RightToSeq().Should().BeEquivalentTo(movieMediaItem); |
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
source.RightToSeq().Should().BeEquivalentTo(episodeMediaItem); |
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
itemScanningPlans.Should() |
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
.BeEquivalentTo(new ItemScanningPlan(posterFileName, ScanningAction.Poster)); |
|
|
|
new ItemScanningPlan(movieMediaItem.Path, ScanningAction.Collections)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void WithNewNfo_WithNewPoster( |
|
|
|
|
|
|
|
[Values("jpg", "jpeg", "png", "gif", "tbn")] |
|
|
|
|
|
|
|
string posterExtension) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var episodeMediaItem = new MediaItem |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Metadata = new MediaMetadata { Source = MetadataSource.Fallback }, |
|
|
|
|
|
|
|
Path = "/tv/test (2021)/season 01/test (2021) - s01e03.mkv" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nfoFileName = "/tv/test (2021)/season 01/test (2021) - s01e03.nfo"; |
|
|
|
|
|
|
|
var posterFileName = $"/tv/test (2021)/poster.{posterExtension}"; |
|
|
|
|
|
|
|
string[] fileNames = { episodeMediaItem.Path, nfoFileName, posterFileName }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Seq<LocalMediaItemScanningPlan> result = _scanner.DetermineActions( |
|
|
|
|
|
|
|
MediaType.TvShow, |
|
|
|
|
|
|
|
Seq.create(episodeMediaItem), |
|
|
|
|
|
|
|
fileNames.ToSeq()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Count.Should().Be(1); |
|
|
|
|
|
|
|
(Either<string, MediaItem> source, List<ItemScanningPlan> itemScanningPlans) = result.Head(); |
|
|
|
|
|
|
|
source.IsRight.Should().BeTrue(); |
|
|
|
|
|
|
|
source.RightToSeq().Should().BeEquivalentTo(episodeMediaItem); |
|
|
|
|
|
|
|
itemScanningPlans.Should().BeEquivalentTo( |
|
|
|
|
|
|
|
new ItemScanningPlan(nfoFileName, ScanningAction.SidecarMetadata), |
|
|
|
|
|
|
|
new ItemScanningPlan(posterFileName, ScanningAction.Poster), |
|
|
|
|
|
|
|
new ItemScanningPlan(episodeMediaItem.Path, ScanningAction.Collections)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|