Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix XvideosRipper: update URL pattern to match current URL scheme. #2054

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions src/main/java/com/rarchives/ripme/ripper/rippers/XvideosRipper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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(
Expand All @@ -72,7 +73,7 @@ public String getGID(URL url) throws MalformedURLException {
@Override
public List<String> getURLsFromPage(Document doc) {
List<String> 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");
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading