Ripper and Unit test for Tubex6.com. Closes digitalnoise/ripme#1

This commit is contained in:
digitalnoise 2018-09-15 21:45:25 -05:00
parent e24d8f6853
commit 3f5920b780
2 changed files with 78 additions and 0 deletions

View File

@ -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 Tubex6Ripper extends AbstractSingleFileRipper {
public Tubex6Ripper(URL url) throws IOException {
super(url);
}
@Override
public String getHost() {
return "tubex6";
}
@Override
public String getDomain() {
return "tubex6.com";
}
@Override
public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^http://.*tubex6\\.com/(.*)/$");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
}
throw new MalformedURLException("Expected tubex6.com URL format: " +
"tubex6.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));
}
}

View File

@ -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 Tubex6RipperTest extends RippersTest {
public void testRip() throws IOException {
Tubex6Ripper ripper = new Tubex6Ripper(new URL("http://www.tubex6.com/my-sister-sleeps-naked-1/"));
testRipper(ripper);
}
public void testGetGID() throws IOException {
URL url = new URL("http://www.tubex6.com/my-sister-sleeps-naked-1/");
Tubex6Ripper ripper = new Tubex6Ripper(url);
assertEquals("my-sister-sleeps-naked-1", ripper.getGID(url));
}
}