From b68c2dd0b1d77cb552502421478e26f8382c6710 Mon Sep 17 00:00:00 2001 From: Brett Sanderson Date: Tue, 22 Sep 2020 17:07:27 -0400 Subject: [PATCH] update regex --- LBGDBMetadata/Extensions/StringExtensions.cs | 6 ++++-- LBGDBMetadata/LbgdbMetadataProvider.cs | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/LBGDBMetadata/Extensions/StringExtensions.cs b/LBGDBMetadata/Extensions/StringExtensions.cs index 1a185a0..9bf3696 100644 --- a/LBGDBMetadata/Extensions/StringExtensions.cs +++ b/LBGDBMetadata/Extensions/StringExtensions.cs @@ -4,6 +4,9 @@ namespace LBGDBMetadata.Extensions { public static class StringExtensions { + + private static readonly Regex SanitizeRegex = new Regex(@"((^the\s+)|([^A-Za-z\s]+\s*the(?![A-Za-z])))|((^an\s+)|([^A-Za-z\s]+\s*an(?![A-Za-z])))|((^a\s+)|([^A-Za-z\s]+\s*a(?![A-Za-z])))|[^A-Za-z0-9]", RegexOptions.IgnoreCase | RegexOptions.Compiled); + public static string Sanitize(this string text) { /* @@ -15,8 +18,7 @@ public static string Sanitize(this string text) text = Regex.Replace(text, @"(^|\s+){1}VII($|\s+){1}", "7", RegexOptions.IgnoreCase); text = Regex.Replace(text, @"(^|\s+){1}VIII($|\s+){1}", "8", RegexOptions.IgnoreCase); */ - - return Regex.Replace(text, @"(((^|\s+){1}|(,\s+){1})the($|\s+){1})|(((^|\s+){1}|(,\s+){1})an($|\s+){1})|(((^|\s+){1}|(,\s+){1})a($|\s+){1})|[^A-Za-z0-9]", "", RegexOptions.IgnoreCase).ToLower(); + return SanitizeRegex.Replace(text, "").ToLower(); } public static string ConvertRomans(this string text) diff --git a/LBGDBMetadata/LbgdbMetadataProvider.cs b/LBGDBMetadata/LbgdbMetadataProvider.cs index 3562ab8..c7e7c8d 100644 --- a/LBGDBMetadata/LbgdbMetadataProvider.cs +++ b/LBGDBMetadata/LbgdbMetadataProvider.cs @@ -2,11 +2,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text.RegularExpressions; using LBGDBMetadata.Extensions; using LBGDBMetadata.LaunchBox; using LBGDBMetadata.LaunchBox.Metadata; -using Microsoft.EntityFrameworkCore; using Playnite.SDK.Metadata; using Playnite.SDK.Models; using Playnite.SDK.Plugins; @@ -21,7 +19,7 @@ public class LbgdbMetadataProvider : OnDemandMetadataProvider { private readonly MetadataRequestOptions _options; private readonly LbgdbMetadataPlugin _plugin; - private LaunchBox.Metadata.Game _game; + private Game _game; private Dictionary _regionPriority = new Dictionary(); public LbgdbMetadataProvider(MetadataRequestOptions options, LbgdbMetadataPlugin plugin) @@ -347,6 +345,11 @@ public override List GetLinks() return base.GetLinks(); } + public override List GetFeatures() + { + return base.GetFeatures(); + } + public override List AvailableFields { get