mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-29 11:58:27 +01:00
100% branch coverage for Jellyfin.Naming
This commit is contained in:
@@ -15,13 +15,13 @@ namespace Emby.Naming.AudioBook
|
||||
/// <param name="files">List of files composing the actual audiobook.</param>
|
||||
/// <param name="extras">List of extra files.</param>
|
||||
/// <param name="alternateVersions">Alternative version of files.</param>
|
||||
public AudioBookInfo(string name, int? year, List<AudioBookFileInfo>? files, List<AudioBookFileInfo>? extras, List<AudioBookFileInfo>? alternateVersions)
|
||||
public AudioBookInfo(string name, int? year, List<AudioBookFileInfo> files, List<AudioBookFileInfo> extras, List<AudioBookFileInfo> alternateVersions)
|
||||
{
|
||||
Name = name;
|
||||
Year = year;
|
||||
Files = files ?? new List<AudioBookFileInfo>();
|
||||
Extras = extras ?? new List<AudioBookFileInfo>();
|
||||
AlternateVersions = alternateVersions ?? new List<AudioBookFileInfo>();
|
||||
Files = files;
|
||||
Extras = extras;
|
||||
AlternateVersions = alternateVersions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -185,8 +185,8 @@ namespace Emby.Naming.Video
|
||||
if (!string.IsNullOrEmpty(folderName)
|
||||
&& folderName.Length > 1
|
||||
&& videos.All(i => i.Files.Count == 1
|
||||
&& IsEligibleForMultiVersion(folderName, i.Files[0].Path))
|
||||
&& HaveSameYear(videos))
|
||||
&& IsEligibleForMultiVersion(folderName, i.Files[0].Path))
|
||||
&& HaveSameYear(videos))
|
||||
{
|
||||
var ordered = videos.OrderBy(i => i.Name).ToList();
|
||||
|
||||
@@ -216,10 +216,9 @@ namespace Emby.Naming.Video
|
||||
return videos.Select(i => i.Year ?? -1).Distinct().Count() < 2;
|
||||
}
|
||||
|
||||
private bool IsEligibleForMultiVersion(string folderName, string? testFilename)
|
||||
private bool IsEligibleForMultiVersion(string folderName, string testFilePath)
|
||||
{
|
||||
testFilename = Path.GetFileNameWithoutExtension(testFilename) ?? string.Empty;
|
||||
|
||||
string testFilename = Path.GetFileNameWithoutExtension(testFilePath);
|
||||
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (CleanStringParser.TryClean(testFilename, _options.CleanStringRegexes, out var cleanName))
|
||||
@@ -233,8 +232,8 @@ namespace Emby.Naming.Video
|
||||
}
|
||||
|
||||
return string.IsNullOrEmpty(testFilename)
|
||||
|| testFilename[0].Equals('-')
|
||||
|| testFilename[0].Equals('_')
|
||||
|| testFilename[0] == '-'
|
||||
|| testFilename[0] == '_'
|
||||
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Emby.Naming.Video
|
||||
/// <returns>True if is video file.</returns>
|
||||
public bool IsVideoFile(string path)
|
||||
{
|
||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||
var extension = Path.GetExtension(path);
|
||||
return _options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Emby.Naming.Video
|
||||
/// <returns>True if is video file stub.</returns>
|
||||
public bool IsStubFile(string path)
|
||||
{
|
||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||
var extension = Path.GetExtension(path);
|
||||
return _options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user