Prevent empty or formatted strings from being parsed as a number.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 28 Jan 2015 05:28:17 +0000 (06:28 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 28 Jan 2015 05:28:17 +0000 (06:28 +0100)
src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java

index 57be6f0..2b071c0 100644 (file)
@@ -46,12 +46,19 @@ public class TorrentzEuFilter extends TorrentSiteFilter {
 
        @Override
        protected int extractSeedCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("dd span.u").text());
+               return extractNumber(dataRow.select("dd span.u").text());
        }
 
        @Override
        protected int extractLeechCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("dd span.d").text());
+               return extractNumber(dataRow.select("dd span.d").text());
+       }
+
+       private int extractNumber(String text) {
+               if ((text == null) || text.isEmpty()) {
+                       return 0;
+               }
+               return Integer.valueOf(text.replace(",", ""));
        }
 
 }