2 * Rhynodge - KickAssTorrentsFilter.java - Copyright © 2013 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.filters;
20 import net.pterodactylus.rhynodge.Filter;
21 import net.pterodactylus.rhynodge.queries.HttpQuery;
22 import net.pterodactylus.rhynodge.states.HtmlState;
23 import net.pterodactylus.rhynodge.states.TorrentState;
25 import org.jsoup.nodes.Document;
26 import org.jsoup.nodes.Element;
27 import org.jsoup.select.Elements;
30 * {@link Filter} implementation that parses a {@link TorrentState} from an
31 * {@link HtmlState} which was generated by a {@link HttpQuery} to
32 * {@code kickasstorrents.ph}.
34 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
36 public class KickAssTorrentsFilter extends TorrentSiteFilter {
39 // TORRENTSITEFILTER METHODS
46 protected Elements getDataRows(Document document) {
47 return document.select("table.data").select("tr:gt(0)");
54 protected String extractName(Element dataRow) {
55 return dataRow.select("div.torrentname a.normalgrey").text();
62 protected String extractSize(Element dataRow) {
63 return dataRow.select("td:eq(1)").text();
70 protected String extractMagnetUri(Element dataRow) {
71 return dataRow.select("a.imagnet").attr("href");
78 protected String extractDownloadUri(Element dataRow) {
79 return dataRow.select("a.idownload:not(.partner1Button)").attr("href");
86 protected int extractFileCount(Element dataRow) {
87 return Integer.valueOf(dataRow.select("td:eq(2)").text());
94 protected int extractSeedCount(Element dataRow) {
95 return Integer.valueOf(dataRow.select("td:eq(4)").text());
102 protected int extractLeechCount(Element dataRow) {
103 return Integer.valueOf(dataRow.select("td:eq(5)").text());