Treat empty download URI as null.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 10 Jan 2013 06:09:26 +0000 (07:09 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 10 Jan 2013 06:09:26 +0000 (07:09 +0100)
src/main/java/net/pterodactylus/reactor/filters/TorrentSiteFilter.java

index 968d671..94e030f 100644 (file)
@@ -65,12 +65,16 @@ public abstract class TorrentSiteFilter implements Filter {
                        String name = extractName(dataRow);
                        String size = extractSize(dataRow);
                        String magnetUri = extractMagnetUri(dataRow);
-                       String downloadUri;
+                       String downloadUri = extractDownloadUri(dataRow);
                        int fileCount = extractFileCount(dataRow);
                        int seedCount = extractSeedCount(dataRow);
                        int leechCount = extractLeechCount(dataRow);
                        try {
-                               downloadUri = new URI(((HtmlState) state).uri()).resolve(URLEncoder.encode(extractDownloadUri(dataRow), "UTF-8").replace("%2F", "/")).toString();
+                               if ((downloadUri != null) && (downloadUri.length() > 0)) {
+                                       downloadUri = new URI(((HtmlState) state).uri()).resolve(URLEncoder.encode(downloadUri, "UTF-8").replace("%2F", "/")).toString();
+                               } else {
+                                       downloadUri = null;
+                               }
                                TorrentFile torrentFile = new TorrentFile(name, size, magnetUri, downloadUri, fileCount, seedCount, leechCount);
                                torrentState.addTorrentFile(torrentFile);
                        } catch (URISyntaxException use1) {