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" args: "02/01/2006 15:04:05 -07:00"
grabs: grabs:
selector: td:contains("[Completed:") > span.torrentInfoData selector: td:contains("[Completed:") > span.torrentInfoData
filters:
- name: replace
args: ["---", "0"]
seeders: seeders:
selector: td:contains("Seeders") > span.torrentInfoData selector: td:contains("Seeders") > span.torrentInfoData
leechers: leechers:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -76,10 +76,12 @@ namespace Jackett.Common.Models
public virtual object Clone() => new ReleaseInfo(this); 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) 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) if (valStr.Count(c => c == '.') > 1)
{ {
var lastOcc = valStr.LastIndexOf('.'); var lastOcc = valStr.LastIndexOf('.');