From 810ef556b1e0f42d2783da5ba5dc441a68089fe9 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Wed, 29 Mar 2017 04:08:15 -0400 Subject: [PATCH] added basic support for Jagodibuja.com --- .../ripper/rippers/JagodibujaRipper.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/main/java/com/rarchives/ripme/ripper/rippers/JagodibujaRipper.java diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/JagodibujaRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/JagodibujaRipper.java new file mode 100644 index 00000000..20ad48d1 --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/JagodibujaRipper.java @@ -0,0 +1,83 @@ +package com.rarchives.ripme.ripper.rippers; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +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 JagodibujaRipper extends AbstractHTMLRipper { + + public JagodibujaRipper(URL url) throws IOException { + super(url); + } + @Override + public String getHost() { + return "jagodibuja"; + } + + @Override + public String getDomain() { + return "jagodibuja.com"; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("^https?://www.jagodibuja.com/webcomic-living-with-hipstergirl-and-gamergirl-english/([a-zA-Z0-9_\\-]*)/?"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return "living-with-hipstergirl-and-gamergirl"; + } + throw new MalformedURLException("Expected jagodibuja.com gallery formats hwww.jagodibuja.com/webcomic-living-with-hipstergirl-and-gamergirl-english/COMIC/ got " + url + " instead"); + } + + @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; + elem = doc.select("div.entry-attachment > div.attachment > a").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(); + Element elem = doc.select("span.full-size-link > a").first(); + result.add(elem.attr("href")); + return result; + } + + @Override + public void downloadURL(URL url, int index) { + sleep(500); + addURLToDownload(url, getPrefix(index)); + } + + + }