mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge pull request #5461 from cvium/fix_multiversion
(cherry picked from commit d967267ceff0d786047c60c294c31cc0770a2742) Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
parent
be5f511fc7
commit
c171bac71a
@ -222,20 +222,22 @@ namespace Emby.Naming.Video
|
|||||||
|
|
||||||
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (CleanStringParser.TryClean(testFilename, _options.CleanStringRegexes, out var cleanName))
|
// Remove the folder name before cleaning as we don't care about cleaning that part
|
||||||
{
|
|
||||||
testFilename = cleanName.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folderName.Length <= testFilename.Length)
|
if (folderName.Length <= testFilename.Length)
|
||||||
{
|
{
|
||||||
testFilename = testFilename.Substring(folderName.Length).Trim();
|
testFilename = testFilename.Substring(folderName.Length).Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CleanStringParser.TryClean(testFilename, _options.CleanStringRegexes, out var cleanName))
|
||||||
|
{
|
||||||
|
testFilename = cleanName.Trim().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The CleanStringParser should have removed common keywords etc.
|
||||||
return string.IsNullOrEmpty(testFilename)
|
return string.IsNullOrEmpty(testFilename)
|
||||||
|| testFilename[0].Equals('-')
|
|| testFilename[0] == '-'
|
||||||
|| testFilename[0].Equals('_')
|
|| testFilename[0] == '_'
|
||||||
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
|
|| Regex.IsMatch(testFilename, @"^\[([^]]*)\]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -406,6 +406,44 @@ namespace Jellyfin.Naming.Tests.Video
|
|||||||
Assert.Single(result[0].AlternateVersions);
|
Assert.Single(result[0].AlternateVersions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Resolve_GivenFolderNameWithBracketsAndHyphens_GroupsBasedOnFolderName()
|
||||||
|
{
|
||||||
|
var files = new[]
|
||||||
|
{
|
||||||
|
@"/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 1.mkv",
|
||||||
|
@"/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 2.mkv"
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||||
|
{
|
||||||
|
IsDirectory = false,
|
||||||
|
FullName = i
|
||||||
|
}).ToList()).ToList();
|
||||||
|
|
||||||
|
Assert.Single(result);
|
||||||
|
Assert.Empty(result[0].Extras);
|
||||||
|
Assert.Single(result[0].AlternateVersions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Resolve_GivenUnclosedBrackets_DoesNotGroup()
|
||||||
|
{
|
||||||
|
var files = new[]
|
||||||
|
{
|
||||||
|
@"/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 1].mkv",
|
||||||
|
@"/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 2.mkv"
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||||
|
{
|
||||||
|
IsDirectory = false,
|
||||||
|
FullName = i
|
||||||
|
}).ToList()).ToList();
|
||||||
|
|
||||||
|
Assert.Equal(2, result.Count);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestEmptyList()
|
public void TestEmptyList()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user