diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/Tubex6Ripper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/Tubex6Ripper.java new file mode 100644 index 00000000..1d7e8e3f --- /dev/null +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/Tubex6Ripper.java @@ -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 getURLsFromPage(Document doc) { + List 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)); + } +} \ No newline at end of file diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Tubex6RipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Tubex6RipperTest.java new file mode 100644 index 00000000..83ff88a1 --- /dev/null +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/Tubex6RipperTest.java @@ -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)); + } +} \ No newline at end of file