123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- using System.Linq;
- using Emby.Naming.Common;
- using Emby.Naming.Video;
- using MediaBrowser.Model.IO;
- using Xunit;
- namespace Jellyfin.Naming.Tests.Video
- {
- public class VideoListResolverTests
- {
- private readonly NamingOptions _namingOptions = new NamingOptions();
- // FIXME
- // [Fact]
- private void TestStackAndExtras()
- {
- // No stacking here because there is no part/disc/etc
- var files = new[]
- {
- "Harry Potter and the Deathly Hallows-trailer.mkv",
- "Harry Potter and the Deathly Hallows.trailer.mkv",
- "Harry Potter and the Deathly Hallows part1.mkv",
- "Harry Potter and the Deathly Hallows part2.mkv",
- "Harry Potter and the Deathly Hallows part3.mkv",
- "Harry Potter and the Deathly Hallows part4.mkv",
- "Batman-deleted.mkv",
- "Batman-sample.mkv",
- "Batman-trailer.mkv",
- "Batman part1.mkv",
- "Batman part2.mkv",
- "Batman part3.mkv",
- "Avengers.mkv",
- "Avengers-trailer.mkv",
- // Despite having a keyword in the name that will return an ExtraType, there's no original video to match it to
- // So this is just a standalone video
- "trailer.mkv",
- // Same as above
- "WillyWonka-trailer.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Equal(5, result.Count);
- Assert.Equal(3, result[1].Files.Count);
- Assert.Equal(3, result[1].Extras.Count);
- Assert.Equal("Batman", result[1].Name);
- Assert.Equal(4, result[2].Files.Count);
- Assert.Equal(2, result[2].Extras.Count);
- Assert.Equal("Harry Potter and the Deathly Hallows", result[2].Name);
- }
- [Fact]
- public void TestWithMetadata()
- {
- var files = new[]
- {
- "300.mkv",
- "300.nfo"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestWithExtra()
- {
- var files = new[]
- {
- "300.mkv",
- "300 trailer.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestVariationWithFolderName()
- {
- var files = new[]
- {
- "X-Men Days of Future Past - 1080p.mkv",
- "X-Men Days of Future Past-trailer.mp4"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestTrailer2()
- {
- var files = new[]
- {
- "X-Men Days of Future Past - 1080p.mkv",
- "X-Men Days of Future Past-trailer.mp4",
- "X-Men Days of Future Past-trailer2.mp4"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestDifferentNames()
- {
- var files = new[]
- {
- "Looper (2012)-trailer.mkv",
- "Looper.2012.bluray.720p.x264.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestSeparateFiles()
- {
- // These should be considered separate, unrelated videos
- var files = new[]
- {
- "My video 1.mkv",
- "My video 2.mkv",
- "My video 3.mkv",
- "My video 4.mkv",
- "My video 5.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Equal(5, result.Count);
- }
- [Fact]
- public void TestMultiDisc()
- {
- var files = new[]
- {
- @"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 1",
- @"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 2"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = true,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestPoundSign()
- {
- // These should be considered separate, unrelated videos
- var files = new[]
- {
- @"My movie #1.mp4",
- @"My movie #2.mp4"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = true,
- FullName = i
- }).ToList()).ToList();
- Assert.Equal(2, result.Count);
- }
- [Fact]
- public void TestStackedWithTrailer()
- {
- var files = new[]
- {
- @"No (2012) part1.mp4",
- @"No (2012) part2.mp4",
- @"No (2012) part1-trailer.mp4"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestStackedWithTrailer2()
- {
- var files = new[]
- {
- @"No (2012) part1.mp4",
- @"No (2012) part2.mp4",
- @"No (2012)-trailer.mp4"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestExtrasByFolderName()
- {
- var files = new[]
- {
- @"/Movies/Top Gun (1984)/movie.mp4",
- @"/Movies/Top Gun (1984)/Top Gun (1984)-trailer.mp4",
- @"/Movies/Top Gun (1984)/Top Gun (1984)-trailer2.mp4",
- @"trailer.mp4"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestDoubleTags()
- {
- var files = new[]
- {
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd1.avi",
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd2.avi",
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd1.avi",
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd2.avi"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Equal(2, result.Count);
- }
- [Fact]
- public void TestArgumentOutOfRangeException()
- {
- var files = new[]
- {
- @"/nas-markrobbo78/Videos/INDEX HTPC/Movies/Watched/3 - ACTION/Argo (2012)/movie.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestColony()
- {
- var files = new[]
- {
- @"The Colony.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestFourSisters()
- {
- var files = new[]
- {
- @"Four Sisters and a Wedding - A.avi",
- @"Four Sisters and a Wedding - B.avi"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestMovieTrailer()
- {
- var files = new[]
- {
- @"/Server/Despicable Me/Despicable Me (2010).mkv",
- @"/Server/Despicable Me/movie-trailer.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- [Fact]
- public void TestTrailerFalsePositives()
- {
- var files = new[]
- {
- @"/Server/Despicable Me/Skyscraper (2018) - Big Game Spot.mkv",
- @"/Server/Despicable Me/Skyscraper (2018) - Trailer.mkv",
- @"/Server/Despicable Me/Baywatch (2017) - Big Game Spot.mkv",
- @"/Server/Despicable Me/Baywatch (2017) - Trailer.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Equal(4, result.Count);
- }
- [Fact]
- public void TestSubfolders()
- {
- var files = new[]
- {
- @"/Movies/Despicable Me/Despicable Me.mkv",
- @"/Movies/Despicable Me/trailers/trailer.mkv"
- };
- var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
- {
- IsDirectory = false,
- FullName = i
- }).ToList()).ToList();
- Assert.Single(result);
- }
- private VideoListResolver GetResolver()
- {
- return new VideoListResolver(_namingOptions);
- }
- }
- }
|