1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-19 12:11:40 +02:00

Merge pull request #1801 from cyian-1756/porncomixinfo.net

Added porncomixinfo.net ripper and test
This commit is contained in:
cyian-1756
2020-11-26 00:52:06 +00:00
committed by GitHub
2 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
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.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
import com.rarchives.ripme.utils.Http;
public class PorncomixinfoRipper extends AbstractHTMLRipper {
public PorncomixinfoRipper(URL url) throws IOException {
super(url);
}
@Override
public String getHost() {
return "porncomixinfo";
}
@Override
public String getDomain() {
return "porncomixinfo.net";
}
@Override
public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("https://porncomixinfo.net/chapter/([a-zA-Z1-9_-]*)/([a-zA-Z1-9_-]*)/?$");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
}
throw new MalformedURLException("Expected porncomixinfo URL format: " +
"porncomixinfo.net/chapter/CHAP/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 Document getNextPage(Document doc) throws IOException {
// Find next page
String nextUrl = "";
// We use comic-nav-next to the find the next page
Element elem = doc.select("a.next_page").first();
if (elem == null) {
throw new IOException("No more pages");
}
String nextPage = elem.attr("href");
// Some times this returns a empty string
// This for stops that
if (nextPage.equals("")) {
return null;
}
else {
return Http.url(nextPage).get();
}
}
@Override
public List<String> getURLsFromPage(Document doc) {
List<String> result = new ArrayList<>();
for (Element el : doc.select("img.wp-manga-chapter-img")) { {
String imageSource = el.attr("src");
result.add(imageSource);
}
}
return result;
}
@Override
public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index));
}
}

View File

@@ -0,0 +1,15 @@
package com.rarchives.ripme.tst.ripper.rippers;
import java.io.IOException;
import java.net.URL;
import com.rarchives.ripme.ripper.rippers.PorncomixinfoRipper;
import org.junit.Test;
public class PorncomixinfoRipperTest extends RippersTest {
@Test
public void testRip() throws IOException {
PorncomixinfoRipper ripper = new PorncomixinfoRipper(new URL("https://porncomixinfo.net/chapter/alx-come-to-naught-down-in-flames-up-in-smoke-tracy-scops/alx-come-to-naught-down-in-flames-up-in-smoke-tracy-scops/"));
testRipper(ripper);
}
}