Merge pull request #761 from cyian-1756/videoRipperPorts
Xvideo ripper now uses AbstractHTMLRipper
This commit is contained in:
commit
c0a34fe7a1
@ -1,31 +1,47 @@
|
|||||||
package com.rarchives.ripme.ripper.rippers.video;
|
package com.rarchives.ripme.ripper.rippers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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.AbstractHTMLRipper;
|
||||||
|
import com.rarchives.ripme.utils.Utils;
|
||||||
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.ripper.VideoRipper;
|
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
|
|
||||||
public class XvideosRipper extends VideoRipper {
|
public class XvideosRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
private static final String HOST = "xvideos";
|
private static final String HOST = "xvideos";
|
||||||
|
|
||||||
|
private int bytesTotal = 1;
|
||||||
|
private int bytesCompleted = 1;
|
||||||
|
|
||||||
public XvideosRipper(URL url) throws IOException {
|
public XvideosRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document getFirstPage() throws IOException {
|
||||||
|
return Http.url(this.url).get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return HOST;
|
return HOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDomain() {
|
||||||
|
return HOST + ".com";
|
||||||
|
}
|
||||||
|
|
||||||
@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 = Pattern.compile("^https?://[wm.]*xvideos\\.com/video[0-9]+.*$");
|
||||||
@ -33,11 +49,6 @@ public class XvideosRipper extends VideoRipper {
|
|||||||
return m.matches();
|
return m.matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 = Pattern.compile("^https?://[wm.]*xvideos\\.com/video([0-9]+).*$");
|
||||||
@ -53,9 +64,8 @@ public class XvideosRipper extends VideoRipper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
LOGGER.info(" Retrieving " + this.url);
|
List<String> results = new ArrayList<>();
|
||||||
Document doc = Http.url(this.url).get();
|
|
||||||
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")) {
|
||||||
@ -64,13 +74,39 @@ public class XvideosRipper extends VideoRipper {
|
|||||||
for (String line: lines) {
|
for (String line: lines) {
|
||||||
if (line.contains("html5player.setVideoUrlHigh")) {
|
if (line.contains("html5player.setVideoUrlHigh")) {
|
||||||
String videoURL = line.replaceAll("\t", "").replaceAll("html5player.setVideoUrlHigh\\(", "").replaceAll("\'", "").replaceAll("\\);", "");
|
String videoURL = line.replaceAll("\t", "").replaceAll("html5player.setVideoUrlHigh\\(", "").replaceAll("\'", "").replaceAll("\\);", "");
|
||||||
addURLToDownload(new URL(videoURL), HOST + "_" + getGID(this.url));
|
results.add(videoURL);
|
||||||
waitForThreads();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IOException("Unable to find video url at " + this.url.toExternalForm());
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadURL(URL url, int index) {
|
||||||
|
addURLToDownload(url, getPrefix(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStatusText() {
|
||||||
|
return Utils.getByteStatusText(getCompletionPercentage(), bytesCompleted, bytesTotal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCompletionPercentage() {
|
||||||
|
return (int) (100 * (bytesCompleted / (float) bytesTotal));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBytesTotal(int bytes) {
|
||||||
|
this.bytesTotal = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBytesCompleted(int bytes) {
|
||||||
|
this.bytesCompleted = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useByteProgessBar() {return true;}
|
||||||
}
|
}
|
@ -7,9 +7,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.rarchives.ripme.ripper.VideoRipper;
|
import com.rarchives.ripme.ripper.VideoRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.video.PornhubRipper;
|
import com.rarchives.ripme.ripper.rippers.video.PornhubRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.video.TwitchVideoRipper;
|
|
||||||
import com.rarchives.ripme.ripper.rippers.video.XhamsterRipper;
|
import com.rarchives.ripme.ripper.rippers.video.XhamsterRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.video.XvideosRipper;
|
import com.rarchives.ripme.ripper.rippers.XvideosRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.video.YoupornRipper;
|
import com.rarchives.ripme.ripper.rippers.video.YoupornRipper;
|
||||||
import com.rarchives.ripme.ripper.rippers.video.YuvutuRipper;
|
import com.rarchives.ripme.ripper.rippers.video.YuvutuRipper;
|
||||||
|
|
||||||
@ -57,17 +56,7 @@ public class VideoRippersTest extends RippersTest {
|
|||||||
videoTestHelper(ripper);
|
videoTestHelper(ripper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testXvideosRipper() throws IOException {
|
|
||||||
List<URL> contentURLs = new ArrayList<>();
|
|
||||||
contentURLs.add(new URL("https://www.xvideos.com/video19719109/ziggy_star_ultra_hard_anal_pounding"));
|
|
||||||
contentURLs.add(new URL("https://www.xvideos.com/video23515878/dee_s_pool_toys"));
|
|
||||||
for (URL url : contentURLs) {
|
|
||||||
XvideosRipper ripper = new XvideosRipper(url);
|
|
||||||
videoTestHelper(ripper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testPornhubRipper() throws IOException {
|
public void testPornhubRipper() throws IOException {
|
||||||
List<URL> contentURLs = new ArrayList<>();
|
List<URL> contentURLs = new ArrayList<>();
|
||||||
contentURLs.add(new URL("https://www.pornhub.com/view_video.php?viewkey=ph5a329fa707269"));
|
contentURLs.add(new URL("https://www.pornhub.com/view_video.php?viewkey=ph5a329fa707269"));
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.rarchives.ripme.tst.ripper.rippers;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.rarchives.ripme.ripper.rippers.XvideosRipper;
|
||||||
|
import com.rarchives.ripme.tst.ripper.rippers.RippersTest;
|
||||||
|
|
||||||
|
public class XvideosRipperTest extends RippersTest {
|
||||||
|
|
||||||
|
public void testXhamsterAlbum1() throws IOException {
|
||||||
|
XvideosRipper ripper = new XvideosRipper(new URL("https://www.xvideos.com/video23515878/dee_s_pool_toys"));
|
||||||
|
testRipper(ripper);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user