X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Frhynodge%2Fwatchers%2FPirateBayEpisodeWatcher.java;h=9ef3d795f58408b4dd23f56485397aeefc565a99;hb=b1c7de25c9ce6b9ced6a659539bb2dab68c09866;hp=6f8507c212da4dc2506df2e67db9d58b0406c02f;hpb=3cfff3956d11b1654133ce632248ee574a9fd6a0;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 6f8507c..9ef3d79 100644 --- a/src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java +++ b/src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java @@ -48,24 +48,25 @@ 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.org/search/" + URLEncoder.encode(searchTerms, "UTF-8") + "/0/3/0"); + return new HttpQuery("http://thepiratebay.org/search/" + URLEncoder.encode(searchTerms, "UTF-8") + "/0/3/0", proxyHost, proxyPort); } catch (UnsupportedEncodingException uee1) { /* will not happen. */ return null;