use ToLowerInvariant with RegexOptions.IgnoreCase

This commit is contained in:
Frank Skare
2021-02-23 12:58:49 +01:00
parent ffb2b89541
commit c79cef12e3
3 changed files with 34 additions and 13 deletions
+31 -7
View File
@@ -947,29 +947,42 @@ Module MiscExtensions
<Extension()>
Function ToSeparatedString(list As IEnumerable(Of x265Control.QualityItem)) As String
If list Is Nothing OrElse Not list.Any() Then Return ""
If list Is Nothing OrElse Not list.Any() Then
Return ""
End If
Return String.Join("_", s.X265QualityDefinitions.OrderBy(Function(x) x.Value).Select(Function(x) $"{x.Value:0.#}{If(String.IsNullOrWhiteSpace(x.Text), "", $"""{x.Text.Trim()}""")}"))
End Function
<Extension()>
Function ToX264QualityItems(input As String) As IEnumerable(Of x264Control.QualityItem)
Dim result = New List(Of x264Control.QualityItem)
If String.IsNullOrWhiteSpace(input) Then Return result
If String.IsNullOrWhiteSpace(input) Then
Return result
End If
Dim pattern = "(\d{1,2}([\.,]\d{1,3})?)(""([^""]*)"")?"
Dim matches = Regex.Matches(input, pattern, RegexOptions.IgnoreCase)
If matches.Count = 0 Then Return result
If matches.Count = 0 Then
Return result
End If
Dim qualityConfig = If(TypeOf p.VideoEncoder Is x264Enc, DirectCast(p.VideoEncoder, x264Enc).Params.Quant.Config, {0, 69, 0, 1})
For Each match As Match In matches
If Not match.Success Then Continue For
If Not match.Success Then
Continue For
End If
Dim value = 0.0
Dim text = ""
If Double.TryParse(Regex.Replace(match.Groups(1).Value, "\.|,", NumberFormatInfo.CurrentInfo.NumberDecimalSeparator), value) Then
Dim powed = Math.Pow(10, qualityConfig(3))
value = CInt(Math.Floor(value * powed)) / powed
If value >= qualityConfig(0) AndAlso value <= qualityConfig(1) AndAlso Not result.Where(Function(x) x.Value = value).Any() Then
text = If(match.Groups.Count > 4, match.Groups(4).Value.Trim(), text)
result.Add(New x264Control.QualityItem(value, text, ""))
@@ -982,28 +995,39 @@ Module MiscExtensions
<Extension()>
Function ToX265QualityItems(input As String) As IEnumerable(Of x265Control.QualityItem)
Dim result = New List(Of x265Control.QualityItem)
If String.IsNullOrWhiteSpace(input) Then Return result
If String.IsNullOrWhiteSpace(input) Then
Return result
End If
Dim pattern = "(\d{1,2}([\.,]\d{1,3})?)(""([^""]*)"")?"
Dim matches = Regex.Matches(input, pattern, RegexOptions.IgnoreCase)
If matches.Count = 0 Then Return result
If matches.Count = 0 Then
Return result
End If
Dim qualityConfig = If(TypeOf p.VideoEncoder Is x265Enc, DirectCast(p.VideoEncoder, x265Enc).Params.Quant.Config, {0, 51, 0, 1})
For Each match As Match In matches
If Not match.Success Then Continue For
If Not match.Success Then
Continue For
End If
Dim value = 0.0
Dim text = ""
If Double.TryParse(Regex.Replace(match.Groups(1).Value, "\.|,", NumberFormatInfo.CurrentInfo.NumberDecimalSeparator), value) Then
Dim powed = Math.Pow(10, qualityConfig(3))
value = CInt(Math.Floor(value * powed)) / powed
If value >= qualityConfig(0) AndAlso value <= qualityConfig(1) AndAlso Not result.Where(Function(x) x.Value = value).Any() Then
text = If(match.Groups.Count > 4, match.Groups(4).Value.Trim(), text)
result.Add(New x265Control.QualityItem(value, text, ""))
End If
End If
Next
Return result
End Function
End Module
+2 -5
View File
@@ -2656,17 +2656,14 @@ Public Class PluginPackage
Return False
End If
If p.Script.IsAviSynth AndAlso
Not package.AvsFilterNames.NothingOrEmpty Then
If p.Script.IsAviSynth AndAlso Not package.AvsFilterNames.NothingOrEmpty Then
Dim scriptLower = p.Script.GetScript().ToLowerInvariant
For Each filterName In package.AvsFilterNames
If scriptLower.Contains(filterName.ToLowerInvariant + "(") Then Return True
If scriptLower.Contains("import") Then
Dim match = Regex.Match(scriptLower, "\bimport\s*\(\s*""\s*(.+\.avsi*)\s*""\s*\)",
RegexOptions.IgnoreCase)
Dim match = Regex.Match(scriptLower, "\bimport\s*\(\s*""\s*(.+\.avsi*)\s*""\s*\)", RegexOptions.IgnoreCase)
If match.Success AndAlso File.Exists(match.Groups(1).Value) Then
If match.Groups(1).Value.ReadAllText.ToLowerInvariant.Contains(
+1 -1
View File
@@ -561,7 +561,7 @@ clipname.set_output()
End Function
Shared Function GetAVSLoadCodeFromImports(code As String) As String
code = code.ToLower
code = code.ToLowerInvariant
Dim ret = ""
For Each line In code.SplitLinesNoEmpty