X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Frhynodge%2Fwatchers%2FPirateBayEpisodeWatcher.java;h=4fec73013cb0b5f675d59279c626902e2699d653;hb=bbd347904c5013824617462c8f55cc8c0469bfec;hp=304d6f5da5c364027402cc1d9da35c32405006af;hpb=48da379d3e08c7eb76550598f3b4dd9e637060d7;p=rhynodge.git diff --git a/src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java b/src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java index 304d6f5..4fec730 100644 --- a/src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java +++ b/src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java @@ -29,7 +29,9 @@ import net.pterodactylus.rhynodge.Trigger; import net.pterodactylus.rhynodge.Watcher; import net.pterodactylus.rhynodge.filters.EpisodeFilter; import net.pterodactylus.rhynodge.filters.HtmlFilter; +import net.pterodactylus.rhynodge.filters.SizeBlacklistFilter; import net.pterodactylus.rhynodge.filters.torrents.PirateBayFilter; +import net.pterodactylus.rhynodge.queries.FallbackQuery; import net.pterodactylus.rhynodge.queries.HttpQuery; import net.pterodactylus.rhynodge.triggers.NewEpisodeTrigger; @@ -48,24 +50,28 @@ public class PirateBayEpisodeWatcher extends DefaultWatcher { * @param searchTerms * The terms to search for */ - public PirateBayEpisodeWatcher(String searchTerms) { - super(createHttpQuery(searchTerms), createFilters(), createTrigger()); + public PirateBayEpisodeWatcher(String searchTerms, String proxy) { + super(createHttpQuery(searchTerms, extractProxyHost(proxy), extractProxyPort(proxy)), createFilters(), createTrigger()); + } + + private static String extractProxyHost(String proxy) { + return proxy.split(":")[0]; + } + + private static int extractProxyPort(String proxy) { + return Integer.valueOf(proxy.split(":")[1]); } // // STATIC METHODS // - /** - * Creates the query of the watcher. - * - * @param searchTerms - * The search terms of the query - * @return The query of the watcher - */ - private static Query createHttpQuery(String searchTerms) { + private static Query createHttpQuery(String searchTerms, String proxyHost, int proxyPort) { try { - return new HttpQuery("http://thepiratebay.vg/search/" + URLEncoder.encode(searchTerms, "UTF-8") + "/0/3/0"); + HttpQuery hiddenServiceQuery = new HttpQuery("http://uj3wazyk5u4hnvtk.onion/search/" + URLEncoder.encode(searchTerms, "UTF-8") + "/0/3/0", proxyHost, proxyPort); + HttpQuery torQuery = new HttpQuery("http://thepiratebay.org/search/" + URLEncoder.encode(searchTerms, "UTF-8") + "/0/3/0", proxyHost, proxyPort); + HttpQuery plainInternetQuery = new HttpQuery("http://thepiratebay.org/search/" + URLEncoder.encode(searchTerms, "UTF-8") + "/0/3/0"); + return new FallbackQuery(hiddenServiceQuery, torQuery, plainInternetQuery); } catch (UnsupportedEncodingException uee1) { /* will not happen. */ return null; @@ -78,7 +84,7 @@ public class PirateBayEpisodeWatcher extends DefaultWatcher { * @return The filters of the watcher */ private static List createFilters() { - return ImmutableList.of(new HtmlFilter(), new PirateBayFilter(), createDefaultBlacklistFilter(), new EpisodeFilter()); + return ImmutableList.of(new HtmlFilter(), new PirateBayFilter(), createDefaultBlacklistFilter(), new SizeBlacklistFilter(), new EpisodeFilter()); } /**