2 * rhynodge - TorrentzEuEpisodeWatcher.java - Copyright © 2014 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.rhynodge.watchers;
20 import static net.pterodactylus.rhynodge.filters.BlacklistFilter.createDefaultBlacklistFilter;
22 import java.io.UnsupportedEncodingException;
23 import java.net.URLEncoder;
24 import java.util.List;
26 import net.pterodactylus.rhynodge.Filter;
27 import net.pterodactylus.rhynodge.Query;
28 import net.pterodactylus.rhynodge.Trigger;
29 import net.pterodactylus.rhynodge.filters.EpisodeFilter;
30 import net.pterodactylus.rhynodge.filters.HtmlFilter;
31 import net.pterodactylus.rhynodge.filters.SizeBlacklistFilter;
32 import net.pterodactylus.rhynodge.filters.torrents.TorrentzEuFilter;
33 import net.pterodactylus.rhynodge.queries.HttpQuery;
34 import net.pterodactylus.rhynodge.triggers.NewEpisodeTrigger;
36 import com.google.common.collect.ImmutableList;
39 * {@link net.pterodactylus.rhynodge.Watcher} implementation that watches
40 * {@code torrentz.eu} for new files.
42 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
44 public class TorrentzEuWatcher extends DefaultWatcher {
47 * Creates a new {@code torrentz.eu} episode watcher.
50 * The terms to search for
52 public TorrentzEuWatcher(String searchTerms) {
53 super(createHttpQuery(searchTerms), createFilters(), createTrigger());
61 * Creates the query of the watcher.
64 * The search terms of the query
65 * @return The query of the watcher
67 private static Query createHttpQuery(String searchTerms) {
69 return new HttpQuery("http://torrentz.eu/searchA?q=" + URLEncoder.encode(searchTerms, "UTF-8"));
70 } catch (UnsupportedEncodingException uee1) {
71 /* will not happen. */
77 * Creates the filters of the watcher.
79 * @return The filters of the watcher
81 private static List<Filter> createFilters() {
82 return ImmutableList.of(new HtmlFilter(), new TorrentzEuFilter(), createDefaultBlacklistFilter(), new SizeBlacklistFilter());
86 * Creates the trigger of the watcher.
88 * @return The trigger of the watcher
90 private static Trigger createTrigger() {
91 return new NewEpisodeTrigger();