ReleaseInfo.GetBytes: fix parsing of commas and dashes

This commit is contained in:
Garfield69 2021-09-07 07:52:16 +12:00
parent 5193ebb401
commit f2c760ce8c
11 changed files with 6 additions and 46 deletions

View File

@ -79,9 +79,6 @@ search:
args: "02/01/2006 15:04:05 -07:00"
grabs:
selector: td:contains("[Completed:") > span.torrentInfoData
filters:
- name: replace
args: ["---", "0"]
seeders:
selector: td:contains("Seeders") > span.torrentInfoData
leechers:

View File

@ -86,19 +86,10 @@ search:
selector: td:nth-child(5)
seeders:
selector: td:nth-child(6)
filters:
- name: replace
args: ["-", "0"]
leechers:
selector: td:nth-child(7)
filters:
- name: replace
args: ["-", "0"]
grabs:
selector: td:nth-child(8)
filters:
- name: replace
args: ["-", "0"]
downloadvolumefactor:
text: 0
uploadvolumefactor:

View File

@ -100,9 +100,8 @@ search:
args: " ago"
seeders:
selector: td:nth-child(6)
filters:
- name: replace
args: ["-", "0"]
leechers:
text: 0
downloadvolumefactor:
text: 0
uploadvolumefactor:

View File

@ -172,9 +172,6 @@ search:
attribute: href
grabs:
selector: div.selection_unter_ae
filters:
- name: replace
args: [" x", ""]
size:
selector: div.selection_unter_ad
seeders:

View File

@ -89,21 +89,10 @@ search:
- name: timeago
size:
selector: td:nth-child(5)
filters:
- name: replace
args: ["-", "0 B"]
seeders:
selector: td:nth-child(6)
filters:
- name: replace
args: [",", ""]
- name: replace
args: ["-", "0"]
leechers:
selector: td:nth-child(7)
filters:
- name: replace
args: [",", ""]
downloadvolumefactor:
text: 0
uploadvolumefactor:

View File

@ -92,9 +92,6 @@ search:
selector: td:nth-of-type(6)
grabs:
selector: td:nth-of-type(7)
filters:
- name: replace
args: ["---", "0"]
downloadvolumefactor:
text: 0
uploadvolumefactor:

View File

@ -377,9 +377,6 @@ search:
grabs:
selector: td:nth-child(2) > table > tbody > tr:nth-child(5) > td
remove: strong
filters:
- name: replace
args: ["---", "0"]
cat:
selector: a[href^="index.php?page=torrents&category="]
attribute: href

View File

@ -184,9 +184,6 @@ search:
selector: td:nth-child(9)
grabs:
selector: td:nth-child(10)
filters:
- name: replace
args: ["---", "0"]
downloadvolumefactor:
text: 1
uploadvolumefactor:

View File

@ -103,9 +103,6 @@ search:
selector: td:nth-child(10)
grabs:
selector: td:nth-child(11)
filters:
- name: replace
args: ["---", "0"]
downloadvolumefactor:
text: 1
uploadvolumefactor:

View File

@ -155,9 +155,6 @@ search:
selector: td:nth-child(7)
grabs:
selector: td:nth-child(8)
filters:
- name: replace
args: ["---", "0"]
date:
selector: td:nth-child(5)
filters:

View File

@ -76,10 +76,12 @@ namespace Jackett.Common.Models
public virtual object Clone() => new ReleaseInfo(this);
// ex: " 3.5 gb "
// ex: " 3.5 gb " -> "3758096384" , "3,5GB" -> "3758096384" , "296,98 MB" -> "311406100.48" , "1.018,29 MB" -> "1067754455.04"
// ex: "1.018.29mb" -> "1067754455.04" , "-" -> "0" , "---" -> "0"
public static long GetBytes(string str)
{
var valStr = new string(str.Where(c => char.IsDigit(c) || c == '.').ToArray());
var valStr = new string(str.Where(c => char.IsDigit(c) || c == '.' || c == ',').ToArray());
valStr = (valStr.Length == 0) ? "0" : valStr.Replace(",", ".");
if (valStr.Count(c => c == '.') > 1)
{
var lastOcc = valStr.LastIndexOf('.');