1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-25 14:51:11 +02:00

Merge pull request #1440 from mrfrankcastle96/master

Fixed xhamster ripper not downloading after 30 images
This commit is contained in:
cyian-1756
2019-10-23 17:53:01 -05:00
committed by GitHub
2 changed files with 51 additions and 13 deletions

View File

@@ -140,8 +140,11 @@ public class XhamsterRipper extends AbstractHTMLRipper {
@Override @Override
public Document getNextPage(Document doc) throws IOException { public Document getNextPage(Document doc) throws IOException {
if (doc.select("a[data-page=next]").first() != null) { if (doc.select("a[data-page=next]").first() != null) {
if (doc.select("a[data-page=next]").first().attr("href").startsWith("http")) { String nextPageUrl = doc.select("a[data-page=next]").first().attr("href");
return Http.url(doc.select("a[data-page=next]").first().attr("href")).get(); if (nextPageUrl.startsWith("http")) {
nextPageUrl = nextPageUrl.replaceAll("https?://\\w?\\w?\\.?xhamster\\.", "https://m.xhamster.");
nextPageUrl = nextPageUrl.replaceAll("https?://xhamster2\\.", "https://m.xhamster2.");
return Http.url(nextPageUrl).get();
} }
} }
throw new IOException("No more pages"); throw new IOException("No more pages");
@@ -153,7 +156,7 @@ public class XhamsterRipper extends AbstractHTMLRipper {
LOGGER.debug("Checking for urls"); LOGGER.debug("Checking for urls");
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
if (!isVideoUrl(url)) { if (!isVideoUrl(url)) {
for (Element page : doc.select("div.items > div.item-container > a.item")) { for (Element page : doc.select("div.picture_view > div.pictures_block > div.items > div.item-container > a.item")) {
// Make sure we don't waste time running the loop if the ripper has been stopped // Make sure we don't waste time running the loop if the ripper has been stopped
if (isStopped()) { if (isStopped()) {
break; break;

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,18 +76,29 @@ 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<>();
Elements scripts = doc.select("script"); Pattern p = Pattern.compile("^https?://[wm.]*xvideos\\.com/video([0-9]+).*$");
for (Element e : scripts) { Matcher m = p.matcher(url.toExternalForm());
if (e.html().contains("html5player.setVideoUrlHigh")) { if (m.matches()) {
LOGGER.info("Found the right script"); Elements scripts = doc.select("script");
String[] lines = e.html().split("\n"); for (Element e : scripts) {
for (String line: lines) { if (e.html().contains("html5player.setVideoUrlHigh")) {
if (line.contains("html5player.setVideoUrlHigh")) { LOGGER.info("Found the right script");
String videoURL = line.replaceAll("\t", "").replaceAll("html5player.setVideoUrlHigh\\(", "").replaceAll("\'", "").replaceAll("\\);", ""); String[] lines = e.html().split("\n");
results.add(videoURL); for (String line : lines) {
if (line.contains("html5player.setVideoUrlHigh")) {
String videoURL = line.replaceAll("\t", "").replaceAll("html5player.setVideoUrlHigh\\(", "").replaceAll("\'", "").replaceAll("\\);", "");
results.add(videoURL);
}
} }
} }
} }
} 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);
}
}
} }