Move torrent-related filters to their own package.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 24 Feb 2013 14:30:31 +0000 (15:30 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 24 Feb 2013 14:30:31 +0000 (15:30 +0100)
src/main/java/net/pterodactylus/rhynodge/filters/KickAssTorrentsFilter.java [deleted file]
src/main/java/net/pterodactylus/rhynodge/filters/PirateBayFilter.java [deleted file]
src/main/java/net/pterodactylus/rhynodge/filters/torrents/KickAssTorrentsFilter.java [new file with mode: 0644]
src/main/java/net/pterodactylus/rhynodge/filters/torrents/PirateBayFilter.java [new file with mode: 0644]
src/main/java/net/pterodactylus/rhynodge/watchers/KickAssTorrentsEpisodeWatcher.java
src/main/java/net/pterodactylus/rhynodge/watchers/KickAssTorrentsWatcher.java
src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayEpisodeWatcher.java
src/main/java/net/pterodactylus/rhynodge/watchers/PirateBayWatcher.java
src/main/resources/chains/kickasstorrents-example.json
src/main/resources/chains/thepiratebay-example.json

diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/KickAssTorrentsFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/KickAssTorrentsFilter.java
deleted file mode 100644 (file)
index c368bf3..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Rhynodge - KickAssTorrentsFilter.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.rhynodge.filters;
-
-import net.pterodactylus.rhynodge.Filter;
-import net.pterodactylus.rhynodge.queries.HttpQuery;
-import net.pterodactylus.rhynodge.states.HtmlState;
-import net.pterodactylus.rhynodge.states.TorrentState;
-
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-/**
- * {@link Filter} implementation that parses a {@link TorrentState} from an
- * {@link HtmlState} which was generated by a {@link HttpQuery} to
- * {@code kickasstorrents.ph}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class KickAssTorrentsFilter extends TorrentSiteFilter {
-
-       //
-       // TORRENTSITEFILTER METHODS
-       //
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected Elements getDataRows(Document document) {
-               return document.select("table.data").select("tr:gt(0)");
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractName(Element dataRow) {
-               return dataRow.select("div.torrentname a.normalgrey").text();
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractSize(Element dataRow) {
-               return dataRow.select("td:eq(1)").text();
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractMagnetUri(Element dataRow) {
-               return dataRow.select("a.imagnet").attr("href");
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractDownloadUri(Element dataRow) {
-               return dataRow.select("a.idownload:not(.partner1Button)").attr("href");
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected int extractFileCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("td:eq(2)").text());
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected int extractSeedCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("td:eq(4)").text());
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected int extractLeechCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("td:eq(5)").text());
-       }
-
-}
diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/PirateBayFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/PirateBayFilter.java
deleted file mode 100644 (file)
index a935261..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Rhynodge - PirateBayFilter.java - Copyright © 2013 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.rhynodge.filters;
-
-import java.util.regex.Pattern;
-
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-/**
- * {@link TorrentSiteFilter} implementation that can parse
- * {@code thepiratebay.se} result pages.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class PirateBayFilter extends TorrentSiteFilter {
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected Elements getDataRows(Document document) {
-               return document.select("table#searchResult tbody tr:has(.vertTh)");
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractName(Element dataRow) {
-               return dataRow.select(".detName a").text();
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractSize(Element dataRow) {
-               return dataRow.select(".detDesc").text().split(Pattern.quote(","))[1].split(Pattern.quote("Size"))[1];
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractMagnetUri(Element dataRow) {
-               return dataRow.select("a[href^=magnet:]").attr("href");
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected String extractDownloadUri(Element dataRow) {
-               return dataRow.select("a[href^=//torrents.]").attr("href");
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected int extractFileCount(Element dataRow) {
-               return 0;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected int extractSeedCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("td:eq(2)").text());
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected int extractLeechCount(Element dataRow) {
-               return Integer.valueOf(dataRow.select("td:eq(3)").text());
-       }
-
-}
diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/torrents/KickAssTorrentsFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/torrents/KickAssTorrentsFilter.java
new file mode 100644 (file)
index 0000000..dd47bbf
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Rhynodge - KickAssTorrentsFilter.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.rhynodge.filters.torrents;
+
+import net.pterodactylus.rhynodge.Filter;
+import net.pterodactylus.rhynodge.filters.TorrentSiteFilter;
+import net.pterodactylus.rhynodge.queries.HttpQuery;
+import net.pterodactylus.rhynodge.states.HtmlState;
+import net.pterodactylus.rhynodge.states.TorrentState;
+
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+/**
+ * {@link Filter} implementation that parses a {@link TorrentState} from an
+ * {@link HtmlState} which was generated by a {@link HttpQuery} to
+ * {@code kickasstorrents.ph}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class KickAssTorrentsFilter extends TorrentSiteFilter {
+
+       //
+       // TORRENTSITEFILTER METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected Elements getDataRows(Document document) {
+               return document.select("table.data").select("tr:gt(0)");
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractName(Element dataRow) {
+               return dataRow.select("div.torrentname a.normalgrey").text();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractSize(Element dataRow) {
+               return dataRow.select("td:eq(1)").text();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractMagnetUri(Element dataRow) {
+               return dataRow.select("a.imagnet").attr("href");
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractDownloadUri(Element dataRow) {
+               return dataRow.select("a.idownload:not(.partner1Button)").attr("href");
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected int extractFileCount(Element dataRow) {
+               return Integer.valueOf(dataRow.select("td:eq(2)").text());
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected int extractSeedCount(Element dataRow) {
+               return Integer.valueOf(dataRow.select("td:eq(4)").text());
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected int extractLeechCount(Element dataRow) {
+               return Integer.valueOf(dataRow.select("td:eq(5)").text());
+       }
+
+}
diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/torrents/PirateBayFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/torrents/PirateBayFilter.java
new file mode 100644 (file)
index 0000000..06b1a9c
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Rhynodge - PirateBayFilter.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.rhynodge.filters.torrents;
+
+import java.util.regex.Pattern;
+
+import net.pterodactylus.rhynodge.filters.TorrentSiteFilter;
+
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+/**
+ * {@link net.pterodactylus.rhynodge.filters.TorrentSiteFilter} implementation that can parse
+ * {@code thepiratebay.se} result pages.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class PirateBayFilter extends TorrentSiteFilter {
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected Elements getDataRows(Document document) {
+               return document.select("table#searchResult tbody tr:has(.vertTh)");
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractName(Element dataRow) {
+               return dataRow.select(".detName a").text();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractSize(Element dataRow) {
+               return dataRow.select(".detDesc").text().split(Pattern.quote(","))[1].split(Pattern.quote("Size"))[1];
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractMagnetUri(Element dataRow) {
+               return dataRow.select("a[href^=magnet:]").attr("href");
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected String extractDownloadUri(Element dataRow) {
+               return dataRow.select("a[href^=//torrents.]").attr("href");
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected int extractFileCount(Element dataRow) {
+               return 0;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected int extractSeedCount(Element dataRow) {
+               return Integer.valueOf(dataRow.select("td:eq(2)").text());
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected int extractLeechCount(Element dataRow) {
+               return Integer.valueOf(dataRow.select("td:eq(3)").text());
+       }
+
+}
index fc65209..e8a8574 100644 (file)
@@ -27,7 +27,7 @@ import net.pterodactylus.rhynodge.Trigger;
 import net.pterodactylus.rhynodge.Watcher;
 import net.pterodactylus.rhynodge.filters.EpisodeFilter;
 import net.pterodactylus.rhynodge.filters.HtmlFilter;
-import net.pterodactylus.rhynodge.filters.KickAssTorrentsFilter;
+import net.pterodactylus.rhynodge.filters.torrents.KickAssTorrentsFilter;
 import net.pterodactylus.rhynodge.queries.HttpQuery;
 import net.pterodactylus.rhynodge.triggers.NewEpisodeTrigger;
 
index 9c68cdb..631bd2e 100644 (file)
@@ -26,7 +26,7 @@ import net.pterodactylus.rhynodge.Query;
 import net.pterodactylus.rhynodge.Trigger;
 import net.pterodactylus.rhynodge.Watcher;
 import net.pterodactylus.rhynodge.filters.HtmlFilter;
-import net.pterodactylus.rhynodge.filters.KickAssTorrentsFilter;
+import net.pterodactylus.rhynodge.filters.torrents.KickAssTorrentsFilter;
 import net.pterodactylus.rhynodge.queries.HttpQuery;
 import net.pterodactylus.rhynodge.triggers.NewTorrentTrigger;
 
index 753a4ad..30bd376 100644 (file)
@@ -26,7 +26,7 @@ import net.pterodactylus.rhynodge.Query;
 import net.pterodactylus.rhynodge.Trigger;
 import net.pterodactylus.rhynodge.filters.EpisodeFilter;
 import net.pterodactylus.rhynodge.filters.HtmlFilter;
-import net.pterodactylus.rhynodge.filters.PirateBayFilter;
+import net.pterodactylus.rhynodge.filters.torrents.PirateBayFilter;
 import net.pterodactylus.rhynodge.queries.HttpQuery;
 import net.pterodactylus.rhynodge.triggers.NewEpisodeTrigger;
 
index ef6f743..9a77393 100644 (file)
@@ -25,7 +25,7 @@ import net.pterodactylus.rhynodge.Filter;
 import net.pterodactylus.rhynodge.Query;
 import net.pterodactylus.rhynodge.Trigger;
 import net.pterodactylus.rhynodge.filters.HtmlFilter;
-import net.pterodactylus.rhynodge.filters.PirateBayFilter;
+import net.pterodactylus.rhynodge.filters.torrents.PirateBayFilter;
 import net.pterodactylus.rhynodge.queries.HttpQuery;
 import net.pterodactylus.rhynodge.triggers.NewTorrentTrigger;
 
index 2962ea2..32bc1a2 100644 (file)
@@ -18,7 +18,7 @@
                        "class": "HtmlFilter"
                },
                {
-                       "class": "KickAssTorrentsFilter"
+                       "class": "torrents.KickAssTorrentsFilter"
                },
                {
                        "class": "EpisodeFilter"
index ad79213..09e07e1 100644 (file)
@@ -18,7 +18,7 @@
                        "class": "HtmlFilter"
                },
                {
-                       "class": "PirateBayFilter"
+                       "class": "torrents.PirateBayFilter"
                }
        ],