Merge pull request #891 from cyian-1756/myhentaigalleryRipper

Myhentaigallery ripper
This commit is contained in:
cyian-1756 2018-09-17 00:06:36 -04:00 committed by GitHub
commit 6a92c251c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 0 deletions

View File

@ -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<String> getURLsFromPage(Document doc) {
List<String> 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));
}
}

View File

@ -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);
}
}