1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-06 13:56:34 +02:00

Added xvideos ripper album downloading

This commit is contained in:
Frank Castle
2019-09-29 16:27:06 +05:30
parent d26b73cdec
commit 65ff5274fa

View File

@@ -43,7 +43,15 @@ public class XvideosRipper extends AbstractSingleFileRipper {
public boolean canRip(URL url) { public boolean canRip(URL url) {
Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/video[0-9]+.*$"); Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/video[0-9]+.*$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
return m.matches(); if (m.matches()) {
return true;
}
p = Pattern.compile("^https?://[wm.]*xvideos\\.com/profiles/[a-zA-Z0-9_-]+/photos/\\d+/[a-zA-Z0-9_-]+$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
return true;
}
return false;
} }
@Override @Override
@@ -53,6 +61,11 @@ public class XvideosRipper extends AbstractSingleFileRipper {
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_-]+$");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
}
throw new MalformedURLException( throw new MalformedURLException(
"Expected xvideo format:" "Expected xvideo format:"
@@ -63,6 +76,9 @@ 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]+).*$");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
Elements scripts = doc.select("script"); Elements scripts = doc.select("script");
for (Element e : scripts) { for (Element e : scripts) {
if (e.html().contains("html5player.setVideoUrlHigh")) { if (e.html().contains("html5player.setVideoUrlHigh")) {
@@ -76,6 +92,14 @@ public class XvideosRipper extends AbstractSingleFileRipper {
} }
} }
} }
} else {
for (Element e : doc.select("div.thumb > a")) {
results.add(e.attr("href"));
if (isThisATest()) {
break;
}
}
}
return results; return results;
} }
@@ -83,4 +107,15 @@ public class XvideosRipper extends AbstractSingleFileRipper {
public void downloadURL(URL url, int index) { public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index)); addURLToDownload(url, getPrefix(index));
} }
@Override
public String getAlbumTitle(URL url) throws MalformedURLException {
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());
if (m.matches()) {
return getHost() + "_" + m.group(1) + "_" + m.group(3) + "_" + m.group(2);
} else {
return super.getAlbumTitle(url);
}
}
} }