diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/MyhentaigalleryRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/MyhentaigalleryRipper.java new file mode 100644 index 00000000..0eb0427a --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/MyhentaigalleryRipper.java @@ -0,0 +1,68 @@ +package com.rarchives.ripme.ripper.rippers; + +import com.rarchives.ripme.ripper.AbstractHTMLRipper; +import com.rarchives.ripme.utils.Http; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; + +public class MyhentaigalleryRipper extends AbstractHTMLRipper { + private static boolean isTag; + + public MyhentaigalleryRipper(URL url) throws IOException { + super(url); + } + + @Override + public String getHost() { + return "myhentaigallery"; + } + + @Override + public String getDomain() { + return "myhentaigallery.com"; + } + + @Override + public String getGID(URL url) throws MalformedURLException { + Pattern p = Pattern.compile("https://myhentaigallery.com/gallery/thumbnails/([0-9]+)/?$"); + Matcher m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return m.group(1); + } + + throw new MalformedURLException("Expected myhentaicomics.com URL format: " + + "myhentaigallery.com/gallery/thumbnails/ID - got " + url + " instead"); + } + + @Override + public Document getFirstPage() throws IOException { + // "url" is an instance field of the superclass + return Http.url(url).get(); + } + + @Override + public List getURLsFromPage(Document doc) { + List result = new ArrayList<>(); + for (Element el : doc.select(".comic-thumb > img")) { + String imageSource = el.attr("src"); + // We replace thumbs with resizes so we can the full sized images + imageSource = imageSource.replace("thumbnail", "original"); + result.add("https://" + getDomain() + imageSource); + } + return result; + } + + @Override + public void downloadURL(URL url, int index) { + addURLToDownload(url, getPrefix(index)); + } + + +} \ No newline at end of file diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java new file mode 100644 index 00000000..6cde566a --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/MyhentaigalleryRipperTest.java @@ -0,0 +1,14 @@ +package com.rarchives.ripme.tst.ripper.rippers; + +import java.io.IOException; +import java.net.URL; + +import com.rarchives.ripme.ripper.rippers.MyhentaigalleryRipper; + +public class MyhentaigalleryRipperTest extends RippersTest { + + public void testMyhentaigalleryAlbum() throws IOException { + MyhentaigalleryRipper ripper = new MyhentaigalleryRipper(new URL("https://myhentaigallery.com/gallery/thumbnails/9201")); + testRipper(ripper); + } +} \ No newline at end of file