mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-18 13:40:45 +01:00
Merge pull request #2105 from Bond-009/namingtests
Add back all old emby tests
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Emby.Naming.Video;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Naming.Common
|
||||
{
|
||||
@@ -176,7 +177,7 @@ namespace Emby.Naming.Common
|
||||
|
||||
CleanDateTimes = new[]
|
||||
{
|
||||
@"(.+[^ _\,\.\(\)\[\]\-])[ _\.\(\)\[\]\-]+(19[0-9][0-9]|20[0-1][0-9])([ _\,\.\(\)\[\]\-][^0-9]|$)"
|
||||
@"(.+[^_\,\.\(\)\[\]\-])[_\.\(\)\[\]\-](19[0-9][0-9]|20[0-1][0-9])([ _\,\.\(\)\[\]\-][^0-9]|).*(19[0-9][0-9]|20[0-1][0-9])*"
|
||||
};
|
||||
|
||||
CleanStrings = new[]
|
||||
@@ -423,126 +424,126 @@ namespace Emby.Naming.Common
|
||||
{
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "trailer",
|
||||
ExtraType = ExtraType.Trailer,
|
||||
RuleType = ExtraRuleType.Filename,
|
||||
Token = "trailer",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "trailer",
|
||||
ExtraType = ExtraType.Trailer,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-trailer",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "trailer",
|
||||
ExtraType = ExtraType.Trailer,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = ".trailer",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "trailer",
|
||||
ExtraType = ExtraType.Trailer,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "_trailer",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "trailer",
|
||||
ExtraType = ExtraType.Trailer,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = " trailer",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "sample",
|
||||
ExtraType = ExtraType.Sample,
|
||||
RuleType = ExtraRuleType.Filename,
|
||||
Token = "sample",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "sample",
|
||||
ExtraType = ExtraType.Sample,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-sample",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "sample",
|
||||
ExtraType = ExtraType.Sample,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = ".sample",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "sample",
|
||||
ExtraType = ExtraType.Sample,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "_sample",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "sample",
|
||||
ExtraType = ExtraType.Sample,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = " sample",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "themesong",
|
||||
ExtraType = ExtraType.ThemeSong,
|
||||
RuleType = ExtraRuleType.Filename,
|
||||
Token = "theme",
|
||||
MediaType = MediaType.Audio
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "scene",
|
||||
ExtraType = ExtraType.Scene,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-scene",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "clip",
|
||||
ExtraType = ExtraType.Clip,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-clip",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "interview",
|
||||
ExtraType = ExtraType.Interview,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-interview",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "behindthescenes",
|
||||
ExtraType = ExtraType.BehindTheScenes,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-behindthescenes",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "deletedscene",
|
||||
ExtraType = ExtraType.DeletedScene,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-deleted",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "featurette",
|
||||
ExtraType = ExtraType.Clip,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-featurette",
|
||||
MediaType = MediaType.Video
|
||||
},
|
||||
new ExtraRule
|
||||
{
|
||||
ExtraType = "short",
|
||||
ExtraType = ExtraType.Clip,
|
||||
RuleType = ExtraRuleType.Suffix,
|
||||
Token = "-short",
|
||||
MediaType = MediaType.Video
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// http://kodi.wiki/view/Advancedsettings.xml#video
|
||||
/// <see href="http://kodi.wiki/view/Advancedsettings.xml#video" />.
|
||||
/// </summary>
|
||||
public class CleanStringParser
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
return _options.VideoExtraRules
|
||||
.Select(i => GetExtraInfo(path, i))
|
||||
.FirstOrDefault(i => !string.IsNullOrEmpty(i.ExtraType)) ?? new ExtraResult();
|
||||
.FirstOrDefault(i => i.ExtraType != null) ?? new ExtraResult();
|
||||
}
|
||||
|
||||
private ExtraResult GetExtraInfo(string path, ExtraRule rule)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma warning disable CS1591
|
||||
#pragma warning disable SA1600
|
||||
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
public class ExtraResult
|
||||
@@ -9,7 +11,7 @@ namespace Emby.Naming.Video
|
||||
/// Gets or sets the type of the extra.
|
||||
/// </summary>
|
||||
/// <value>The type of the extra.</value>
|
||||
public string ExtraType { get; set; }
|
||||
public ExtraType? ExtraType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rule.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma warning disable CS1591
|
||||
#pragma warning disable SA1600
|
||||
|
||||
using Emby.Naming.Common;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaType = Emby.Naming.Common.MediaType;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
@@ -17,7 +18,7 @@ namespace Emby.Naming.Video
|
||||
/// Gets or sets the type of the extra.
|
||||
/// </summary>
|
||||
/// <value>The type of the extra.</value>
|
||||
public string ExtraType { get; set; }
|
||||
public ExtraType ExtraType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the rule.
|
||||
|
||||
@@ -14,14 +14,14 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
return default(StubResult);
|
||||
return default;
|
||||
}
|
||||
|
||||
var extension = Path.GetExtension(path);
|
||||
|
||||
if (!options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return default(StubResult);
|
||||
return default;
|
||||
}
|
||||
|
||||
var result = new StubResult()
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
@@ -30,10 +32,10 @@ namespace Emby.Naming.Video
|
||||
public int? Year { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the extra, e.g. trailer, theme song, behing the scenes, etc.
|
||||
/// Gets or sets the type of the extra, e.g. trailer, theme song, behind the scenes, etc.
|
||||
/// </summary>
|
||||
/// <value>The type of the extra.</value>
|
||||
public string ExtraType { get; set; }
|
||||
public ExtraType? ExtraType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the extra rule.
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Emby.Naming.Common;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
@@ -32,7 +33,7 @@ namespace Emby.Naming.Video
|
||||
// Filter out all extras, otherwise they could cause stacks to not be resolved
|
||||
// See the unit test TestStackedWithTrailer
|
||||
var nonExtras = videoInfos
|
||||
.Where(i => string.IsNullOrEmpty(i.ExtraType))
|
||||
.Where(i => i.ExtraType == null)
|
||||
.Select(i => new FileSystemMetadata
|
||||
{
|
||||
FullName = i.Path,
|
||||
@@ -79,7 +80,7 @@ namespace Emby.Naming.Video
|
||||
}
|
||||
|
||||
var standaloneMedia = remainingFiles
|
||||
.Where(i => string.IsNullOrEmpty(i.ExtraType))
|
||||
.Where(i => i.ExtraType == null)
|
||||
.ToList();
|
||||
|
||||
foreach (var media in standaloneMedia)
|
||||
@@ -148,7 +149,7 @@ namespace Emby.Naming.Video
|
||||
if (list.Count == 1)
|
||||
{
|
||||
var trailers = remainingFiles
|
||||
.Where(i => string.Equals(i.ExtraType, "trailer", StringComparison.OrdinalIgnoreCase))
|
||||
.Where(i => i.ExtraType == ExtraType.Trailer)
|
||||
.ToList();
|
||||
|
||||
list[0].Extras.AddRange(trailers);
|
||||
@@ -229,7 +230,7 @@ namespace Emby.Naming.Video
|
||||
}
|
||||
|
||||
return remainingFiles
|
||||
.Where(i => !string.IsNullOrEmpty(i.ExtraType))
|
||||
.Where(i => i.ExtraType == null)
|
||||
.Where(i => baseNames.Any(b => i.FileNameWithoutExtension.StartsWith(b, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Emby.Naming.Video
|
||||
{
|
||||
var cleanDateTimeResult = CleanDateTime(name);
|
||||
|
||||
if (string.IsNullOrEmpty(extraResult.ExtraType))
|
||||
if (extraResult.ExtraType == null)
|
||||
{
|
||||
name = CleanString(cleanDateTimeResult.Name).Name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user