2 * Rhynodge - PirateBayFilter.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 java.util.regex.Pattern;
22 import org.jsoup.nodes.Document;
23 import org.jsoup.nodes.Element;
24 import org.jsoup.select.Elements;
27 * {@link TorrentSiteFilter} implementation that can parse
28 * {@code thepiratebay.se} result pages.
30 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
32 public class PirateBayFilter extends TorrentSiteFilter {
38 protected Elements getDataRows(Document document) {
39 return document.select("table#searchResult tbody tr:has(.vertTh)");
46 protected String extractName(Element dataRow) {
47 return dataRow.select(".detName a").text();
54 protected String extractSize(Element dataRow) {
55 return dataRow.select(".detDesc").text().split(Pattern.quote(","))[1].split(Pattern.quote("Size"))[1];
62 protected String extractMagnetUri(Element dataRow) {
63 return dataRow.select("a[href^=magnet:]").attr("href");
70 protected String extractDownloadUri(Element dataRow) {
71 return dataRow.select("a[href^=//torrents.]").attr("href");
78 protected int extractFileCount(Element dataRow) {
86 protected int extractSeedCount(Element dataRow) {
87 return Integer.valueOf(dataRow.select("td:eq(2)").text());
94 protected int extractLeechCount(Element dataRow) {
95 return Integer.valueOf(dataRow.select("td:eq(3)").text());