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.torrents;
20 import net.pterodactylus.rhynodge.Filter;
21 import net.pterodactylus.rhynodge.filters.TorrentSiteFilter;
22 import net.pterodactylus.rhynodge.queries.HttpQuery;
23 import net.pterodactylus.rhynodge.states.HtmlState;
24 import net.pterodactylus.rhynodge.states.TorrentState;
26 import org.jsoup.nodes.Document;
27 import org.jsoup.nodes.Element;
28 import org.jsoup.select.Elements;
31 * {@link Filter} implementation that parses a {@link TorrentState} from an
32 * {@link HtmlState} which was generated by a {@link HttpQuery} to
33 * {@code kickasstorrents.ph}.
35 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
37 public class KickAssTorrentsFilter extends TorrentSiteFilter {
40 // TORRENTSITEFILTER METHODS
47 protected Elements getDataRows(Document document) {
48 return document.select("table.data").select("tr:gt(0)");
55 protected String extractName(Element dataRow) {
56 return dataRow.select("div.torrentname a.normalgrey").text();
63 protected String extractSize(Element dataRow) {
64 return dataRow.select("td:eq(1)").text();
71 protected String extractMagnetUri(Element dataRow) {
72 return dataRow.select("a.imagnet").attr("href");
79 protected String extractDownloadUri(Element dataRow) {
80 return dataRow.select("a.idownload:not(.partner1Button)").attr("href");
87 protected int extractFileCount(Element dataRow) {
88 return Integer.valueOf(dataRow.select("td:eq(2)").text());
95 protected int extractSeedCount(Element dataRow) {
96 return Integer.valueOf(dataRow.select("td:eq(4)").text());
103 protected int extractLeechCount(Element dataRow) {
104 return Integer.valueOf(dataRow.select("td:eq(5)").text());