Add Volume Factor Props to Release Info

pull/8/head
Qstick 4 years ago
parent ee9330a7e2
commit 3bfa1b1e68

@ -10,6 +10,8 @@ namespace NzbDrone.Common.Extensions
public static class StringExtensions public static class StringExtensions
{ {
private static readonly Regex CamelCaseRegex = new Regex("(?<!^)[A-Z]", RegexOptions.Compiled); 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) public static string NullSafe(this string target)
{ {
@ -171,5 +173,13 @@ namespace NzbDrone.Common.Extensions
{ {
return source.Contains(value, StringComparer.InvariantCultureIgnoreCase); return source.Contains(value, StringComparer.InvariantCultureIgnoreCase);
} }
public static int CoerceInt(this string str) => 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(",", "");
} }
} }

@ -94,7 +94,12 @@ namespace NzbDrone.Core.IndexerSearch
GetNabElement("files", r.Files, protocol), GetNabElement("files", r.Files, protocol),
GetNabElement("grabs", r.Grabs, protocol), GetNabElement("grabs", r.Grabs, protocol),
GetNabElement("peers", t.Peers, 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; return xdoc.Declaration + Environment.NewLine + xdoc;
} }

@ -226,6 +226,9 @@ namespace NzbDrone.Core.Indexers.Definitions
var descriptions = new List<string>(); var descriptions = new List<string>();
var tags = new List<string>(); var tags = new List<string>();
release.MinimumRatio = 1.1;
release.MinimumSeedTime = 432000; // 120 hours
release.Title = row.name; release.Title = row.name;
release.Category = _categories.MapTrackerCatToNewznab(row.category.ToString()); release.Category = _categories.MapTrackerCatToNewznab(row.category.ToString());
release.Size = row.size; release.Size = row.size;
@ -238,6 +241,17 @@ namespace NzbDrone.Core.Indexers.Definitions
release.Guid = new Uri(_baseUrl + "torrent/" + row.id.ToString() + "/").ToString(); release.Guid = new Uri(_baseUrl + "torrent/" + row.id.ToString() + "/").ToString();
release.DownloadUrl = _baseUrl + "api/v1/torrents/download/" + row.id.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 (row.imdbid2 != null && row.imdbid2.ToString().StartsWith("tt"))
{ {
if (int.TryParse((string)row.imdbid2, out int imdbNumber)) if (int.TryParse((string)row.imdbid2, out int imdbNumber))

@ -292,6 +292,10 @@ namespace NzbDrone.Core.Indexers.Definitions
imdbId = int.Parse(imdb.Substring(2)); 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 var release = new TorrentInfo
{ {
Title = title, Title = title,
@ -304,7 +308,11 @@ namespace NzbDrone.Core.Indexers.Definitions
Grabs = grabs, Grabs = grabs,
Seeders = seeders, Seeders = seeders,
Peers = seeders + leechers, 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); torrentInfos.Add(release);

@ -10,6 +10,10 @@ namespace NzbDrone.Core.Parser.Model
public int? Seeders { get; set; } public int? Seeders { get; set; }
public int? Peers { get; set; } public int? Peers { get; set; }
public bool Freeleech { 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) public static int? GetSeeders(ReleaseInfo release)
{ {

Loading…
Cancel
Save