New Indexer: TorrentDay

This commit is contained in:
Qstick
2021-02-17 21:35:04 -05:00
parent 3bfa1b1e68
commit 546bec3717
13 changed files with 329 additions and 45 deletions

View File

@@ -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));
}
}
}