Merge pull request #457 from cyian-1756/xvideos

Fixed xvideos ripper
This commit is contained in:
cyian-1756 2018-03-10 12:14:05 -05:00 committed by GitHub
commit 39049d1d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,19 +57,21 @@ public class XvideosRipper extends VideoRipper {
public void rip() throws IOException { public void rip() throws IOException {
logger.info(" Retrieving " + this.url); logger.info(" Retrieving " + this.url);
Document doc = Http.url(this.url).get(); Document doc = Http.url(this.url).get();
Elements embeds = doc.select("embed"); Elements scripts = doc.select("script");
if (embeds.size() == 0) { for (Element e : scripts) {
throw new IOException("Could not find Embed code at " + url); if (e.html().contains("html5player.setVideoUrlHigh")) {
} logger.info("Found the right script");
Element embed = embeds.get(0); String[] lines = e.html().split("\n");
String vars = embed.attr("flashvars"); for (String line: lines) {
for (String var : vars.split("&")) { if (line.contains("html5player.setVideoUrlHigh")) {
if (var.startsWith("flv_url=")) { String videoURL = line.replaceAll("\t", "").replaceAll("html5player.setVideoUrlHigh\\(", "").replaceAll("\'", "").replaceAll("\\);", "");
String vidUrl = var.substring("flv_url=".length()); addURLToDownload(new URL(videoURL), HOST + "_" + getGID(this.url));
vidUrl = URLDecoder.decode(vidUrl, "UTF-8"); waitForThreads();
addURLToDownload(new URL(vidUrl), HOST + "_" + getGID(this.url)); return;
}
}
} }
} }
waitForThreads(); throw new IOException("Unable to find video url at " + this.url.toExternalForm());
} }
} }