diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index 246dc0561..540083004 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -10,6 +10,8 @@ namespace NzbDrone.Common.Extensions public static class StringExtensions { private static readonly Regex CamelCaseRegex = new Regex("(? int.Parse(NormalizeNumber(str), NumberStyles.Any, CultureInfo.InvariantCulture); + + public static string NormalizeSpace(this string s) => s.Trim(); + + public static string NormalizeMultiSpaces(this string s) => new Regex(@"\s+").Replace(NormalizeSpace(s), " "); + + public static string NormalizeNumber(this string s) => NormalizeSpace(s).Replace("-", "0").Replace(",", ""); } } diff --git a/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs b/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs index e6c88de10..4ddff0969 100644 --- a/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs +++ b/src/NzbDrone.Core/IndexerSearch/NewznabResults.cs @@ -94,7 +94,12 @@ namespace NzbDrone.Core.IndexerSearch GetNabElement("files", r.Files, protocol), GetNabElement("grabs", r.Grabs, protocol), GetNabElement("peers", t.Peers, protocol), - GetNabElement("infohash", RemoveInvalidXMLChars(r.Guid), protocol))))); + GetNabElement("infohash", RemoveInvalidXMLChars(r.Guid), protocol), + GetNabElement("magneturl", t.MagnetUrl, protocol), + GetNabElement("minimumratio", t.MinimumRatio, protocol), + GetNabElement("minimumseedtime", t.MinimumSeedTime, protocol), + GetNabElement("downloadvolumefactor", t.DownloadVolumeFactor, protocol), + GetNabElement("uploadvolumefactor", t.UploadVolumeFactor, protocol))))); return xdoc.Declaration + Environment.NewLine + xdoc; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs b/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs index df0f21c71..0946f9701 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs @@ -226,6 +226,9 @@ namespace NzbDrone.Core.Indexers.Definitions var descriptions = new List(); var tags = new List(); + + release.MinimumRatio = 1.1; + release.MinimumSeedTime = 432000; // 120 hours release.Title = row.name; release.Category = _categories.MapTrackerCatToNewznab(row.category.ToString()); release.Size = row.size; @@ -238,6 +241,17 @@ namespace NzbDrone.Core.Indexers.Definitions release.Guid = new Uri(_baseUrl + "torrent/" + row.id.ToString() + "/").ToString(); release.DownloadUrl = _baseUrl + "api/v1/torrents/download/" + row.id.ToString(); + if (row.frileech == 1) + { + release.DownloadVolumeFactor = 0; + } + else + { + release.DownloadVolumeFactor = 1; + } + + release.UploadVolumeFactor = 1; + if (row.imdbid2 != null && row.imdbid2.ToString().StartsWith("tt")) { if (int.TryParse((string)row.imdbid2, out int imdbNumber)) diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs index d6bd53ad4..b5e5df050 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs @@ -292,6 +292,10 @@ namespace NzbDrone.Core.Indexers.Definitions imdbId = int.Parse(imdb.Substring(2)); } + // freeleech #6579 #6624 #7367 + string dlMultiplier = row.download_multiplier.ToString(); + var dlVolumeFactor = dlMultiplier.IsNullOrWhiteSpace() ? 1 : dlMultiplier.CoerceInt(); + var release = new TorrentInfo { Title = title, @@ -304,7 +308,11 @@ namespace NzbDrone.Core.Indexers.Definitions Grabs = grabs, Seeders = seeders, Peers = seeders + leechers, - ImdbId = imdbId + ImdbId = imdbId, + UploadVolumeFactor = 1, + DownloadVolumeFactor = dlVolumeFactor, + MinimumRatio = 1, + MinimumSeedTime = 864000 // 10 days for registered users, less for upgraded users }; torrentInfos.Add(release); diff --git a/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs b/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs index 7594334b0..a48d7913e 100644 --- a/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/TorrentInfo.cs @@ -10,6 +10,10 @@ namespace NzbDrone.Core.Parser.Model public int? Seeders { get; set; } public int? Peers { get; set; } public bool Freeleech { get; set; } + public double? MinimumRatio { get; set; } + public long? MinimumSeedTime { get; set; } + public double? DownloadVolumeFactor { get; set; } + public double? UploadVolumeFactor { get; set; } public static int? GetSeeders(ReleaseInfo release) {