Fixed parsing of NzbClub releases below 1GB

This commit is contained in:
Mark McDowall 2013-07-16 23:58:50 -07:00
parent 0c12183b93
commit 6a9ca9295f
1 changed files with 11 additions and 5 deletions

View File

@ -133,7 +133,7 @@ namespace NzbDrone.Core.Indexers
return header; return header;
} }
private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?<unit>GB|MB|GiB|MiB)", private static readonly Regex ReportSizeRegex = new Regex(@"(?<value>\d+\.\d{1,2}|\d+)\W?(?<unit>GB|MB|GiB|MiB)",
RegexOptions.IgnoreCase | RegexOptions.Compiled); RegexOptions.IgnoreCase | RegexOptions.Compiled);
@ -148,11 +148,17 @@ namespace NzbDrone.Core.Indexers
var unit = match[0].Groups["unit"].Value; var unit = match[0].Groups["unit"].Value;
if (unit.Equals("MB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("MiB", StringComparison.InvariantCultureIgnoreCase)) if (unit.Equals("MB", StringComparison.InvariantCultureIgnoreCase) ||
return Convert.ToInt64(value * 1048576L); unit.Equals("MiB", StringComparison.InvariantCultureIgnoreCase))
{
return Convert.ToInt32(value).Megabytes();
}
if (unit.Equals("GB", StringComparison.InvariantCultureIgnoreCase) || unit.Equals("GiB", StringComparison.InvariantCultureIgnoreCase)) if (unit.Equals("GB", StringComparison.InvariantCultureIgnoreCase) ||
return Convert.ToInt64(value * 1073741824L); unit.Equals("GiB", StringComparison.InvariantCultureIgnoreCase))
{
return Convert.ToInt32(value).Gigabytes();
}
} }
return 0; return 0;
} }