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.torrents;
20 import java.util.regex.Pattern;
22 import net.pterodactylus.rhynodge.filters.TorrentSiteFilter;
24 import org.jsoup.nodes.Document;
25 import org.jsoup.nodes.Element;
26 import org.jsoup.select.Elements;
29 * {@link net.pterodactylus.rhynodge.filters.TorrentSiteFilter} implementation that can parse
30 * {@code thepiratebay.se} result pages.
32 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
34 public class PirateBayFilter extends TorrentSiteFilter {
40 protected Elements getDataRows(Document document) {
41 return document.select("table#searchResult tbody tr:has(.vertTh)");
48 protected String extractName(Element dataRow) {
49 return dataRow.select(".detName a").text();
56 protected String extractSize(Element dataRow) {
57 return dataRow.select(".detDesc").text().split(Pattern.quote(","))[1].split(Pattern.quote("Size"))[1].trim().replace('\u00a0', ' ');
64 protected String extractMagnetUri(Element dataRow) {
65 return dataRow.select("a[href^=magnet:]").attr("href");
72 protected String extractDownloadUri(Element dataRow) {
73 return dataRow.select("a[href^=//torrents.]").attr("href");
80 protected int extractFileCount(Element dataRow) {
88 protected int extractSeedCount(Element dataRow) {
89 return Integer.valueOf(dataRow.select("td:eq(2)").text());
96 protected int extractLeechCount(Element dataRow) {
97 return Integer.valueOf(dataRow.select("td:eq(3)").text());