From 92405fb9f89876b142505bef3d5d795e46fae342 Mon Sep 17 00:00:00 2001 From: MetaPrime Date: Tue, 9 May 2017 15:53:13 -0700 Subject: [PATCH] WordpressComicRipper: fix indentation --- .../ripper/rippers/WordpressComicRipper.java | 236 +++++++++--------- 1 file changed, 116 insertions(+), 120 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/WordpressComicRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/WordpressComicRipper.java index 15ed3671..515d227f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/WordpressComicRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/WordpressComicRipper.java @@ -11,155 +11,151 @@ import java.util.regex.Pattern; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; import com.rarchives.ripme.ripper.AbstractHTMLRipper; import com.rarchives.ripme.utils.Http; public class WordpressComicRipper extends AbstractHTMLRipper { - public WordpressComicRipper(URL url) throws IOException { - super(url); + super(url); } public static List explicit_domains = Arrays.asList("www.totempole666.com", - "buttsmithy.com", "themonsterunderthebed.net", "prismblush.com"); - @Override - public String getHost() { - String host = url.toExternalForm().split("/")[2]; - return host; - } + "buttsmithy.com", "themonsterunderthebed.net", "prismblush.com"); - @Override - public String getDomain() { - String host = url.toExternalForm().split("/")[2]; - return host; - } + @Override + public String getHost() { + String host = url.toExternalForm().split("/")[2]; + return host; + } - @Override - public boolean canRip(URL url) { - String url_name = url.toExternalForm(); - if (explicit_domains.contains(url_name.split("/")[2]) == true) { - Pattern totempole666Pat = Pattern.compile("https?://www\\.totempole666.com/comic/([a-zA-Z0-9_-]*)/?$"); - Matcher totempole666Mat = totempole666Pat.matcher(url.toExternalForm()); - if (totempole666Mat.matches()) { - return true; - } + @Override + public String getDomain() { + String host = url.toExternalForm().split("/")[2]; + return host; + } - Pattern buttsmithyPat = Pattern.compile("https?://buttsmithy.com/archives/comic/([a-zA-Z0-9_-]*)/?$"); - Matcher buttsmithyMat = buttsmithyPat.matcher(url.toExternalForm()); - if (buttsmithyMat.matches()) { - return true; - } - - Pattern theMonsterUnderTheBedPat = Pattern.compile("https?://themonsterunderthebed.net/\\?comic=([a-zA-Z0-9_-]*)/?$"); - Matcher theMonsterUnderTheBedMat = theMonsterUnderTheBedPat.matcher(url.toExternalForm()); - if (theMonsterUnderTheBedMat.matches()) { - return true; - } - - Pattern prismblushPat = Pattern.compile("https?://prismblush.com/comic/([a-zA-Z0-9_-]*)/?$"); - Matcher prismblushMat = prismblushPat.matcher(url.toExternalForm()); - if (prismblushMat.matches()) { - return true; - } - - } - return false; - } - - @Override - public String getAlbumTitle(URL url) throws MalformedURLException { - Pattern totempole666Pat = Pattern.compile("(?:https?://)?(?:www\\.)?totempole666.com\\/comic/([a-zA-Z0-9_-]*)/?$"); + @Override + public boolean canRip(URL url) { + String url_name = url.toExternalForm(); + if (explicit_domains.contains(url_name.split("/")[2]) == true) { + Pattern totempole666Pat = Pattern.compile("https?://www\\.totempole666.com/comic/([a-zA-Z0-9_-]*)/?$"); Matcher totempole666Mat = totempole666Pat.matcher(url.toExternalForm()); if (totempole666Mat.matches()) { - return "totempole666.com" + "_" + "The_cummoner"; + return true; } Pattern buttsmithyPat = Pattern.compile("https?://buttsmithy.com/archives/comic/([a-zA-Z0-9_-]*)/?$"); Matcher buttsmithyMat = buttsmithyPat.matcher(url.toExternalForm()); if (buttsmithyMat.matches()) { - return "buttsmithy.com" + "_" + "Alfie"; + return true; } - Pattern theMonsterUnderTheBedPat = Pattern.compile("https?://themonsterunderthebed.net/?comic=([a-zA-Z0-9_-]*)/?$"); + Pattern theMonsterUnderTheBedPat = Pattern.compile("https?://themonsterunderthebed.net/\\?comic=([a-zA-Z0-9_-]*)/?$"); Matcher theMonsterUnderTheBedMat = theMonsterUnderTheBedPat.matcher(url.toExternalForm()); if (theMonsterUnderTheBedMat.matches()) { - return "themonsterunderthebed.net_TheMonsterUnderTheBed"; + return true; } Pattern prismblushPat = Pattern.compile("https?://prismblush.com/comic/([a-zA-Z0-9_-]*)/?$"); Matcher prismblushMat = prismblushPat.matcher(url.toExternalForm()); if (prismblushMat.matches()) { - return "prismblush.com_" + prismblushMat.group(1).replaceAll("-pg-\\d+", ""); + return true; } - - return super.getAlbumTitle(url); } - - @Override - public String getGID(URL url) throws MalformedURLException { - String url_name = url.toExternalForm(); - // We shouldn't need to return any GID - if (explicit_domains.contains(url_name.split("/")[2]) == true) { - return ""; - } - throw new MalformedURLException("You should never see this error message"); - } - - @Override - public Document getFirstPage() throws IOException { - // "url" is an instance field of the superclass - return Http.url(url).get(); - } - - @Override - public Document getNextPage(Document doc) throws IOException { - // Find next page - String nextPage = ""; - Element elem = null; - if (explicit_domains.contains("www.totempole666.com") == true - || explicit_domains.contains("buttsmithy.com") == true - || explicit_domains.contains("themonsterunderthebed.net") - || explicit_domains.contains("prismblush.com")) { - elem = doc.select("a.comic-nav-next").first(); - if (elem == null) { - throw new IOException("No more pages"); - } - nextPage = elem.attr("href"); - } - if (nextPage == "") { - throw new IOException("No more pages"); - } - else { - return Http.url(nextPage).get(); - } - } - - @Override - public List getURLsFromPage(Document doc) { - List result = new ArrayList(); - if (explicit_domains.contains("www.totempole666.com") == true - || explicit_domains.contains("buttsmithy.com") == true - || explicit_domains.contains("themonsterunderthebed.net") - || explicit_domains.contains("prismblush.com")) { - Element elem = doc.select("div.comic-table > div#comic > a > img").first(); - // If doc is the last page in the comic then elem.attr("src") returns null - // because there is no link to the next page - if (elem == null) { - logger.debug("Got last page in totempole666 comic"); - elem = doc.select("div.comic-table > div#comic > img").first(); - } - result.add(elem.attr("src")); - } - return result; - } - - @Override - public void downloadURL(URL url, int index) { - addURLToDownload(url, getPrefix(index)); - } - - + return false; } + + @Override + public String getAlbumTitle(URL url) throws MalformedURLException { + Pattern totempole666Pat = Pattern.compile("(?:https?://)?(?:www\\.)?totempole666.com\\/comic/([a-zA-Z0-9_-]*)/?$"); + Matcher totempole666Mat = totempole666Pat.matcher(url.toExternalForm()); + if (totempole666Mat.matches()) { + return "totempole666.com" + "_" + "The_cummoner"; + } + + Pattern buttsmithyPat = Pattern.compile("https?://buttsmithy.com/archives/comic/([a-zA-Z0-9_-]*)/?$"); + Matcher buttsmithyMat = buttsmithyPat.matcher(url.toExternalForm()); + if (buttsmithyMat.matches()) { + return "buttsmithy.com" + "_" + "Alfie"; + } + + Pattern theMonsterUnderTheBedPat = Pattern.compile("https?://themonsterunderthebed.net/?comic=([a-zA-Z0-9_-]*)/?$"); + Matcher theMonsterUnderTheBedMat = theMonsterUnderTheBedPat.matcher(url.toExternalForm()); + if (theMonsterUnderTheBedMat.matches()) { + return "themonsterunderthebed.net_TheMonsterUnderTheBed"; + } + + Pattern prismblushPat = Pattern.compile("https?://prismblush.com/comic/([a-zA-Z0-9_-]*)/?$"); + Matcher prismblushMat = prismblushPat.matcher(url.toExternalForm()); + if (prismblushMat.matches()) { + return "prismblush.com_" + prismblushMat.group(1).replaceAll("-pg-\\d+", ""); + } + + return super.getAlbumTitle(url); + } + + @Override + public String getGID(URL url) throws MalformedURLException { + String url_name = url.toExternalForm(); + // We shouldn't need to return any GID + if (explicit_domains.contains(url_name.split("/")[2]) == true) { + return ""; + } + throw new MalformedURLException("You should never see this error message"); + } + + @Override + public Document getFirstPage() throws IOException { + // "url" is an instance field of the superclass + return Http.url(url).get(); + } + + @Override + public Document getNextPage(Document doc) throws IOException { + // Find next page + String nextPage = ""; + Element elem = null; + if (explicit_domains.contains("www.totempole666.com") == true + || explicit_domains.contains("buttsmithy.com") == true + || explicit_domains.contains("themonsterunderthebed.net") + || explicit_domains.contains("prismblush.com")) { + elem = doc.select("a.comic-nav-next").first(); + if (elem == null) { + throw new IOException("No more pages"); + } + nextPage = elem.attr("href"); + } + + if (nextPage == "") { + throw new IOException("No more pages"); + } else { + return Http.url(nextPage).get(); + } + } + + @Override + public List getURLsFromPage(Document doc) { + List result = new ArrayList(); + if (explicit_domains.contains("www.totempole666.com") == true + || explicit_domains.contains("buttsmithy.com") == true + || explicit_domains.contains("themonsterunderthebed.net") + || explicit_domains.contains("prismblush.com")) { + Element elem = doc.select("div.comic-table > div#comic > a > img").first(); + // If doc is the last page in the comic then elem.attr("src") returns null + // because there is no link to the next page + if (elem == null) { + logger.debug("Got last page in totempole666 comic"); + elem = doc.select("div.comic-table > div#comic > img").first(); + } + result.add(elem.attr("src")); + } + return result; + } + + @Override + public void downloadURL(URL url, int index) { + addURLToDownload(url, getPrefix(index)); + } +}