mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-29 21:39:34 +02:00
New Indexer: TorrentDay
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -10,8 +11,6 @@ namespace NzbDrone.Common.Extensions
|
||||
public static class StringExtensions
|
||||
{
|
||||
private static readonly Regex CamelCaseRegex = new Regex("(?<!^)[A-Z]", RegexOptions.Compiled);
|
||||
private static readonly Regex InvalidXmlChars = new Regex(@"(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\uFEFF\uFFFE\uFFFF]", RegexOptions.Compiled);
|
||||
private static readonly Regex ImdbId = new Regex(@"^(?:tt)?(\d{1,8})$", RegexOptions.Compiled);
|
||||
|
||||
public static string NullSafe(this string target)
|
||||
{
|
||||
@@ -174,12 +173,26 @@ namespace NzbDrone.Common.Extensions
|
||||
return source.Contains(value, StringComparer.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public static int CoerceInt(this string str) => int.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture);
|
||||
public static string UrlEncode(this string searchString, Encoding encoding)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string NormalizeSpace(this string s) => s.Trim();
|
||||
var bytes = encoding.GetBytes(searchString);
|
||||
return encoding.GetString(WebUtility.UrlEncodeToBytes(bytes, 0, bytes.Length));
|
||||
}
|
||||
|
||||
public static string NormalizeMultiSpaces(this string s) => new Regex(@"\s+").Replace(NormalizeSpace(s), " ");
|
||||
public static string UrlDecode(this string searchString, Encoding encoding)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string NormalizeNumber(this string s) => NormalizeSpace(s).Replace("-", "0").Replace(",", "");
|
||||
var inputBytes = encoding.GetBytes(searchString);
|
||||
return encoding.GetString(WebUtility.UrlDecodeToBytes(inputBytes, 0, inputBytes.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user