mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-16 10:54:09 +02:00
Fix XvideosRipper: update URL pattern to match current URL scheme. (#2054)
* Fix XvideosRipper: update URL pattern to match current URL scheme. Also, extract patterns to be compiled once in static members to avoid repeating the match patterns and make the code read a little more clearly. Improve album name for the video case.
This commit is contained in:
@@ -9,18 +9,19 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.AbstractSingleFileRipper;
|
import com.rarchives.ripme.ripper.AbstractSingleFileRipper;
|
||||||
|
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
import com.rarchives.ripme.utils.Http;
|
|
||||||
|
|
||||||
public class XvideosRipper extends AbstractSingleFileRipper {
|
public class XvideosRipper extends AbstractSingleFileRipper {
|
||||||
|
|
||||||
private static final String HOST = "xvideos";
|
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 {
|
public XvideosRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
}
|
}
|
||||||
@@ -37,12 +38,12 @@ public class XvideosRipper extends AbstractSingleFileRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRip(URL url) {
|
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());
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return true;
|
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());
|
m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return true;
|
return true;
|
||||||
@@ -52,15 +53,15 @@ public class XvideosRipper extends AbstractSingleFileRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGID(URL url) throws MalformedURLException {
|
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());
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return m.group(1);
|
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());
|
m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return m.group(1);
|
return m.group(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new MalformedURLException(
|
throw new MalformedURLException(
|
||||||
@@ -72,7 +73,7 @@ public class XvideosRipper extends AbstractSingleFileRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> results = new ArrayList<>();
|
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());
|
Matcher m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
Elements scripts = doc.select("script");
|
Elements scripts = doc.select("script");
|
||||||
@@ -106,12 +107,21 @@ public class XvideosRipper extends AbstractSingleFileRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlbumTitle(URL url) throws MalformedURLException, URISyntaxException {
|
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_-]+)$");
|
Pattern p;
|
||||||
Matcher m = p.matcher(url.toExternalForm());
|
Matcher m;
|
||||||
|
|
||||||
|
p = videoPattern;
|
||||||
|
m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return getHost() + "_" + m.group(1) + "_" + m.group(3) + "_" + m.group(2);
|
return getHost() + "_" + m.group(1) + "_" + m.group(2);
|
||||||
} else {
|
|
||||||
return super.getAlbumTitle(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,9 +9,29 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
public class XvideosRipperTest extends RippersTest {
|
public class XvideosRipperTest extends RippersTest {
|
||||||
@Test
|
@Test
|
||||||
public void testXhamsterAlbum1() throws IOException, URISyntaxException {
|
public void testXvideosVideo1() throws IOException, URISyntaxException {
|
||||||
XvideosRipper ripper = new XvideosRipper(new URI("https://www.xvideos.com/video23515878/dee_s_pool_toys").toURL());
|
// 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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user