Ruleporn.com Ripper; Unit test in progress. Closes digitalnoise/ripme#2
This commit is contained in:
parent
3f5920b780
commit
02664e07d5
@ -0,0 +1,59 @@
|
|||||||
|
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 com.rarchives.ripme.ripper.AbstractSingleFileRipper;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.utils.Http;
|
||||||
|
|
||||||
|
public class RulePornRipper extends AbstractSingleFileRipper {
|
||||||
|
|
||||||
|
public RulePornRipper(URL url) throws IOException {
|
||||||
|
super(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHost() {
|
||||||
|
return "ruleporn";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDomain() {
|
||||||
|
return "ruleporn.com";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGID(URL url) throws MalformedURLException {
|
||||||
|
Pattern p = Pattern.compile("^https://.*ruleporn\\.com/(.*)/$");
|
||||||
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
|
if (m.matches()) {
|
||||||
|
return m.group(1);
|
||||||
|
}
|
||||||
|
throw new MalformedURLException(
|
||||||
|
"Expected ruleporn.com URL format: " + "ruleporn.com/NAME - got " + url + " instead");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document getFirstPage() throws IOException {
|
||||||
|
return Http.url(url).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
result.add(doc.select("source[type=video/mp4]").attr("src"));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadURL(URL url, int index) {
|
||||||
|
addURLToDownload(url, getPrefix(index));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.rarchives.ripme.tst.ripper.rippers;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.rippers.Tubex6Ripper;
|
||||||
|
|
||||||
|
public class RulePornRipperTest extends RippersTest {
|
||||||
|
public void testRip() throws IOException {
|
||||||
|
Tubex6Ripper ripper = new Tubex6Ripper(new URL("https://ruleporn.com/are-you-going-to-fill-my-lil-pussy-up/"));
|
||||||
|
testRipper(ripper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetGID() throws IOException {
|
||||||
|
URL url = new URL("https://ruleporn.com/are-you-going-to-fill-my-lil-pussy-up/");
|
||||||
|
Tubex6Ripper ripper = new Tubex6Ripper(url);
|
||||||
|
assertEquals("are-you-going-to-fill-my-lil-pussy-up", ripper.getGID(url));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user