Added resolving of alternative files and extras for audibooks.

This commit is contained in:
Stepan
2020-11-03 16:24:04 +01:00
parent 7b6363b09a
commit c060ed1a18
6 changed files with 126 additions and 33 deletions

View File

@@ -26,14 +26,16 @@ namespace Jellyfin.Naming.Tests.AudioBook
"Batman/Chapter 2.mp3",
"Batman/Chapter 3.mp3",
"Ready Player One (2020)/Ready Player One.mp3",
"Ready Player One (2020)/extra.mp3",
"Badman/audiobook.mp3",
"Badman/extra.mp3",
"Superman (2020)/book.mp3",
"Superman (2020)/extra.mp3"
"Superman (2020)/Part 1.mp3",
"Superman (2020)/extra.mp3",
"Ready Player One (2020)/audiobook.mp3",
"Ready Player One (2020)/extra.mp3",
".mp3"
};
var resolver = GetResolver();
@@ -44,7 +46,9 @@ namespace Jellyfin.Naming.Tests.AudioBook
FullName = i
})).ToList();
Assert.Equal(4, result[0].Files.Count);
Assert.Equal(5, result.Count);
Assert.Equal(2, result[0].Files.Count);
Assert.Single(result[0].Extras);
Assert.Equal("Harry Potter and the Deathly Hallows", result[0].Name);
@@ -52,13 +56,17 @@ namespace Jellyfin.Naming.Tests.AudioBook
Assert.Empty(result[1].Extras);
Assert.Equal("Batman", result[1].Name);
Assert.Equal(2, result[2].Files.Count);
Assert.Single(result[2].Files);
Assert.Single(result[2].Extras);
Assert.Equal("Badman", result[2].Name);
Assert.Equal(2, result[3].Files.Count);
Assert.Single(result[3].Files);
Assert.Single(result[3].Extras);
Assert.Equal("Superman", result[3].Name);
Assert.Single(result[4].Files);
Assert.Single(result[4].Extras);
Assert.Equal("Ready Player One", result[4].Name);
}
[Fact]
@@ -69,12 +77,9 @@ namespace Jellyfin.Naming.Tests.AudioBook
"Harry Potter and the Deathly Hallows/Chapter 1.ogg",
"Harry Potter and the Deathly Hallows/Chapter 1.mp3",
"Aqua-man/book.mp3",
"Deadpool.mp3",
"Deadpool [HQ].mp3",
"Superman/book.mp3",
"Superman/audiobook.mp3",
"Superman/Superman.mp3",
"Superman/Superman [HQ].mp3",
@@ -92,27 +97,24 @@ namespace Jellyfin.Naming.Tests.AudioBook
FullName = i
})).ToList();
Assert.Equal(6, result[0].Files.Count);
Assert.Equal(5, result.Count);
// HP - Same name so we don't care which file is alternative
Assert.Single(result[0].AlternateVersions);
// Aqua-man
Assert.Empty(result[1].AlternateVersions);
// DP
Assert.Empty(result[2].AlternateVersions);
Assert.Empty(result[1].AlternateVersions);
// DP HQ (directory missing so we do not group deadpools together)
Assert.Empty(result[3].AlternateVersions);
Assert.Empty(result[2].AlternateVersions);
// Superman
// Priority:
// 1. Name
// 2. audiobook
// 3. book
// 4. Names with modifiers
Assert.Equal(3, result[4].AlternateVersions.Count);
Assert.Equal("Superman/audiobook.mp3", result[4].AlternateVersions[0].Path);
Assert.Equal("Superman/book.mp3", result[4].AlternateVersions[1].Path);
Assert.Equal("Superman/Superman [HQ].mp3", result[4].AlternateVersions[2].Path);
// 3. Names with modifiers
Assert.Equal(2, result[3].AlternateVersions.Count);
var paths = result[3].AlternateVersions.Select(x => x.Path).ToList();
Assert.Contains("Superman/audiobook.mp3", paths);
Assert.Contains("Superman/Superman [HQ].mp3", paths);
// Batman
Assert.Single(result[5].AlternateVersions);
Assert.Single(result[4].AlternateVersions);
}
[Fact]