Merge pull request #975 from cyian-1756/xhamsterVideo
Fixed xhamster video ripping
This commit is contained in:
commit
0b0f8c8bff
@ -43,6 +43,9 @@ public class XhamsterRipper extends AbstractHTMLRipper {
|
||||
URLToReturn = URLToReturn.replaceAll("\\w\\w.xhamster.com", "xhamster.com");
|
||||
URL san_url = new URL(URLToReturn.replaceAll("xhamster.com", "m.xhamster.com"));
|
||||
LOGGER.info("sanitized URL is " + san_url.toExternalForm());
|
||||
if (isVideoUrl(url)) {
|
||||
return url;
|
||||
}
|
||||
return san_url;
|
||||
}
|
||||
|
||||
@ -58,6 +61,12 @@ public class XhamsterRipper extends AbstractHTMLRipper {
|
||||
if (m.matches()) {
|
||||
return "user_" + m.group(1);
|
||||
}
|
||||
p = Pattern.compile("^https?://.*xhamster\\.com/(movies|videos)/(.*)$");
|
||||
m = p.matcher(url.toExternalForm());
|
||||
if (m.matches()) {
|
||||
return m.group(2);
|
||||
}
|
||||
|
||||
throw new MalformedURLException(
|
||||
"Expected xhamster.com gallery formats: "
|
||||
+ "xhamster.com/photos/gallery/xxxxx-#####"
|
||||
@ -108,9 +117,20 @@ public class XhamsterRipper extends AbstractHTMLRipper {
|
||||
if (m.matches()) {
|
||||
return true;
|
||||
}
|
||||
p = Pattern.compile("^https?://.*xhamster\\.com/(movies|videos)/.*$");
|
||||
m = p.matcher(url.toExternalForm());
|
||||
if (m.matches()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isVideoUrl(URL url) {
|
||||
Pattern p = Pattern.compile("^https?://.*xhamster\\.com/(movies|videos)/.*$");
|
||||
Matcher m = p.matcher(url.toExternalForm());
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document getNextPage(Document doc) throws IOException {
|
||||
if (doc.select("a[data-page=next]").first() != null) {
|
||||
@ -125,6 +145,7 @@ public class XhamsterRipper extends AbstractHTMLRipper {
|
||||
@Override
|
||||
public List<String> getURLsFromPage(Document doc) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (!isVideoUrl(url)) {
|
||||
for (Element thumb : doc.select("div.picture_view > div.pictures_block > div.items > div.item-container > a > div.thumb_container > div.img > img")) {
|
||||
String image = thumb.attr("src");
|
||||
// replace thumbnail urls with the urls to the full sized images
|
||||
@ -139,6 +160,9 @@ public class XhamsterRipper extends AbstractHTMLRipper {
|
||||
image = image.replaceAll("https", "http");
|
||||
result.add(image);
|
||||
}
|
||||
} else {
|
||||
result.add(doc.select("div.player-container > a").attr("href"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,11 @@ public class XhamsterRipperTest extends RippersTest {
|
||||
testRipper(ripper);
|
||||
}
|
||||
|
||||
public void testXhamsterVideo() throws IOException {
|
||||
XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.com/videos/brazzers-busty-big-booty-milf-lisa-ann-fucks-her-masseur-1492828"));
|
||||
testRipper(ripper);
|
||||
}
|
||||
|
||||
public void testBrazilianXhamster() throws IOException {
|
||||
XhamsterRipper ripper = new XhamsterRipper(new URL("https://pt.xhamster.com/photos/gallery/silvana-7105696"));
|
||||
testRipper(ripper);
|
||||
|
Loading…
Reference in New Issue
Block a user