Clean up some more
This commit is contained in:
parent
ec0ef2a2c5
commit
abf03f7d3a
|
@ -2,33 +2,24 @@
|
|||
#pragma warning disable SA1600
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using Emby.Naming.Common;
|
||||
|
||||
namespace Emby.Naming.Video
|
||||
{
|
||||
/// <summary>
|
||||
/// <see href="http://kodi.wiki/view/Advancedsettings.xml#video" />.
|
||||
/// </summary>
|
||||
public class CleanDateTimeParser
|
||||
public static class CleanDateTimeParser
|
||||
{
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
public CleanDateTimeParser(NamingOptions options)
|
||||
public static CleanDateTimeResult Clean(string name, IReadOnlyList<Regex> cleanDateTimeRegexes)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public CleanDateTimeResult Clean(string name)
|
||||
{
|
||||
var regexes = _options.CleanDateTimeRegexes;
|
||||
var len = regexes.Length;
|
||||
|
||||
CleanDateTimeResult result = new CleanDateTimeResult(name);
|
||||
var len = cleanDateTimeRegexes.Count;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (TryClean(name, regexes[i], ref result))
|
||||
if (TryClean(name, cleanDateTimeRegexes[i], ref result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace Emby.Naming.Video
|
|||
|
||||
public CleanDateTimeResult CleanDateTime(string name)
|
||||
{
|
||||
return new CleanDateTimeParser(_options).Clean(name);
|
||||
return CleanDateTimeParser.Clean(name, _options.CleanDateTimeRegexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ using MediaBrowser.Controller.Sorting;
|
|||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.Net;
|
||||
|
@ -54,6 +53,9 @@ namespace Emby.Server.Implementations.Library
|
|||
/// </summary>
|
||||
public class LibraryManager : ILibraryManager
|
||||
{
|
||||
private NamingOptions _namingOptions;
|
||||
private string[] _videoFileExtensions;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the postscan tasks.
|
||||
/// </summary>
|
||||
|
@ -2508,21 +2510,11 @@ namespace Emby.Server.Implementations.Library
|
|||
}
|
||||
|
||||
public NamingOptions GetNamingOptions()
|
||||
{
|
||||
return GetNamingOptionsInternal();
|
||||
}
|
||||
|
||||
private NamingOptions _namingOptions;
|
||||
private string[] _videoFileExtensions;
|
||||
|
||||
private NamingOptions GetNamingOptionsInternal()
|
||||
{
|
||||
if (_namingOptions == null)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
_namingOptions = options;
|
||||
_videoFileExtensions = _namingOptions.VideoFileExtensions.ToArray();
|
||||
_namingOptions = new NamingOptions();
|
||||
_videoFileExtensions = _namingOptions.VideoFileExtensions;
|
||||
}
|
||||
|
||||
return _namingOptions;
|
||||
|
@ -2533,11 +2525,10 @@ namespace Emby.Server.Implementations.Library
|
|||
var resolver = new VideoResolver(GetNamingOptions());
|
||||
|
||||
var result = resolver.CleanDateTime(name);
|
||||
var cleanName = resolver.CleanString(result.Name);
|
||||
|
||||
return new ItemLookupInfo
|
||||
{
|
||||
Name = cleanName.Name,
|
||||
Name = resolver.TryCleanString(result.Name, out var newName) ? newName.ToString() : result.Name,
|
||||
Year = result.Year
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user