diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/XvideosRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/XvideosRipper.java index 6f591d18b..5c89b6c3f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/XvideosRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/XvideosRipper.java @@ -9,18 +9,19 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; - import com.rarchives.ripme.ripper.AbstractSingleFileRipper; + import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -import com.rarchives.ripme.utils.Http; - public class XvideosRipper extends AbstractSingleFileRipper { private static final String HOST = "xvideos"; + private static final Pattern videoPattern = Pattern.compile("^https?://[wm.]*xvideos\\.com/video\\.([^/]*)(.*)$"); + private static final Pattern albumPattern = Pattern.compile("^https?://[wm.]*xvideos\\.com/(profiles|amateurs)/([a-zA-Z0-9_-]+)/photos/(\\d+)/([a-zA-Z0-9_-]+)$"); + public XvideosRipper(URL url) throws IOException { super(url); } @@ -37,12 +38,12 @@ public String getDomain() { @Override public boolean canRip(URL url) { - Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/video[0-9]+.*$"); + Pattern p = videoPattern; Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return true; } - p = Pattern.compile("^https?://[wm.]*xvideos\\.com/profiles/[a-zA-Z0-9_-]+/photos/\\d+/[a-zA-Z0-9_-]+$"); + p = albumPattern; m = p.matcher(url.toExternalForm()); if (m.matches()) { return true; @@ -52,15 +53,15 @@ public boolean canRip(URL url) { @Override public String getGID(URL url) throws MalformedURLException { - Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/video([0-9]+).*$"); + Pattern p = videoPattern; Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { return m.group(1); } - p = Pattern.compile("^https?://[wm.]*xvideos\\.com/profiles/[a-zA-Z0-9_-]+/photos/(\\d+)/[a-zA-Z0-9_-]+$"); + p = albumPattern; m = p.matcher(url.toExternalForm()); if (m.matches()) { - return m.group(1); + return m.group(3); } throw new MalformedURLException( @@ -72,7 +73,7 @@ public String getGID(URL url) throws MalformedURLException { @Override public List getURLsFromPage(Document doc) { List results = new ArrayList<>(); - Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/video([0-9]+).*$"); + Pattern p = videoPattern; Matcher m = p.matcher(url.toExternalForm()); if (m.matches()) { Elements scripts = doc.select("script"); @@ -106,12 +107,21 @@ public void downloadURL(URL url, int index) { @Override public String getAlbumTitle(URL url) throws MalformedURLException, URISyntaxException { - Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/profiles/([a-zA-Z0-9_-]+)/photos/(\\d+)/([a-zA-Z0-9_-]+)$"); - Matcher m = p.matcher(url.toExternalForm()); + Pattern p; + Matcher m; + + p = videoPattern; + m = p.matcher(url.toExternalForm()); if (m.matches()) { - return getHost() + "_" + m.group(1) + "_" + m.group(3) + "_" + m.group(2); - } else { - return super.getAlbumTitle(url); + return getHost() + "_" + m.group(1) + "_" + m.group(2); } + + p = albumPattern; + m = p.matcher(url.toExternalForm()); + if (m.matches()) { + return getHost() + "_" + m.group(1) + "_" + m.group(2) + "_" + m.group(4) + "_" + m.group(3); + } + + return super.getAlbumTitle(url); } -} \ No newline at end of file +} diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java index cde9d1119..63d383175 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/XvideosRipperTest.java @@ -9,9 +9,29 @@ public class XvideosRipperTest extends RippersTest { @Test - public void testXhamsterAlbum1() throws IOException, URISyntaxException { - XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/video23515878/dee_s_pool_toys").toURL()); + public void testXvideosVideo1() throws IOException, URISyntaxException { + // This format is obsolete + // XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/video23515878/dee_s_pool_toys").toURL()); + // The website now redirects that video to this page + XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/video.hppdiepcbfe/dee_s_pool_toys").toURL()); testRipper(ripper); } + @Test + public void testXvideosVideo2() throws IOException, URISyntaxException { + XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/video.ufkmptkc4ae/big_tit_step_sis_made_me_cum_inside_her").toURL()); + testRipper(ripper); + } + + @Test + public void testXvideosAmateursAlbum() throws IOException, URISyntaxException { + XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/amateurs/nikibeee/photos/2476083/lanikki").toURL()); + testRipper(ripper); + } + + @Test + public void testXvideosProfilesAlbum() throws IOException, URISyntaxException { + XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/profiles/dmthate/photos/8259625/sexy").toURL()); + testRipper(ripper); + } }