1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-22 21:43:06 +02:00

Merge pull request #1807 from soloturn/for-upstream

fix xhamster testGetNextPage
This commit is contained in:
cyian-1756
2021-04-26 05:24:27 +00:00
committed by GitHub
7 changed files with 24 additions and 22 deletions

View File

@@ -48,8 +48,7 @@ public class XhamsterRipper extends AbstractHTMLRipper {
return url; return url;
} }
String URLToReturn = url.toExternalForm(); String URLToReturn = url.toExternalForm();
URLToReturn = URLToReturn.replaceAll("https?://\\w?\\w?\\.?xhamster\\.", "https://m.xhamster."); URLToReturn = URLToReturn.replaceAll("https?://\\w?\\w?\\.?xhamster([^<]*)\\.", "https://m.xhamster$1.");
URLToReturn = URLToReturn.replaceAll("https?://xhamster2\\.", "https://m.xhamster2.");
URL san_url = new URL(URLToReturn); URL san_url = new URL(URLToReturn);
LOGGER.info("sanitized URL is " + san_url.toExternalForm()); LOGGER.info("sanitized URL is " + san_url.toExternalForm());
return san_url; return san_url;
@@ -57,20 +56,20 @@ public class XhamsterRipper extends AbstractHTMLRipper {
@Override @Override
public String getGID(URL url) throws MalformedURLException { public String getGID(URL url) throws MalformedURLException {
Pattern p = Pattern.compile("^https?://[\\w\\w.]*xhamster2?\\.com/photos/gallery/.*?(\\d+)$"); Pattern p = Pattern.compile("^https?://([\\w\\w]*\\.)?xhamster([^<]*)\\.(com|one|desi)/photos/gallery/.*?(\\d+)$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return m.group(1); return m.group(4);
} }
p = Pattern.compile("^https?://[\\w\\w.]*xhamster2?\\.com/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); p = Pattern.compile("^https?://[\\w\\w.]*xhamster([^<]*)\\.(com|one|desi)/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return "user_" + m.group(1); return "user_" + m.group(1);
} }
p = Pattern.compile("^https?://.*xhamster2?\\.com/(movies|videos)/(.*)$"); p = Pattern.compile("^https?://.*xhamster([^<]*)\\.(com|one|desi)/(movies|videos)/(.*$)");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return m.group(2); return m.group(4);
} }
throw new MalformedURLException( throw new MalformedURLException(
@@ -97,7 +96,7 @@ public class XhamsterRipper extends AbstractHTMLRipper {
@Override @Override
public boolean pageContainsAlbums(URL url) { public boolean pageContainsAlbums(URL url) {
Pattern p = Pattern.compile("^https?://[\\w\\w.]*xhamster\\.com/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); Pattern p = Pattern.compile("^https?://[\\w\\w.]*xhamster([^<]*)\\.(com|one|desi)/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
LOGGER.info("Checking if page has albums"); LOGGER.info("Checking if page has albums");
LOGGER.info(m.matches()); LOGGER.info(m.matches());
@@ -113,17 +112,17 @@ public class XhamsterRipper extends AbstractHTMLRipper {
@Override @Override
public boolean canRip(URL url) { public boolean canRip(URL url) {
Pattern p = Pattern.compile("^https?://([\\w\\w]*\\.)?xhamster2?\\.(com|one|desi)/photos/gallery/.*?(\\d+)$"); Pattern p = Pattern.compile("^https?://([\\w\\w]*\\.)?xhamster([^<]*)\\.(com|one|desi)/photos/gallery/.*?(\\d+)$");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return true; return true;
} }
p = Pattern.compile("^https?://[\\w\\w.]*xhamster2?\\.(com|one|desi)/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?"); p = Pattern.compile("^https?://[\\w\\w.]*xhamster([^<]*)\\.(com|one|desi)/users/([a-zA-Z0-9_-]+)/(photos|videos)(/\\d+)?");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return true; return true;
} }
p = Pattern.compile("^https?://.*xhamster2?\\.(com|one|desi)/(movies|videos)/.*$"); p = Pattern.compile("^https?://.*xhamster([^<]*)\\.(com|one|desi)/(movies|videos)/(.*$)");
m = p.matcher(url.toExternalForm()); m = p.matcher(url.toExternalForm());
if (m.matches()) { if (m.matches()) {
return true; return true;
@@ -132,18 +131,17 @@ public class XhamsterRipper extends AbstractHTMLRipper {
} }
private boolean isVideoUrl(URL url) { private boolean isVideoUrl(URL url) {
Pattern p = Pattern.compile("^https?://.*xhamster2?\\.(com|one|desi)/(movies|videos)/.*$"); Pattern p = Pattern.compile("^https?://.*xhamster([^<]*)\\.(com|one|desi)/(movies|videos)/(.*$)");
Matcher m = p.matcher(url.toExternalForm()); Matcher m = p.matcher(url.toExternalForm());
return m.matches(); return m.matches();
} }
@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[rel=next]").first() != null) {
String nextPageUrl = doc.select("a[data-page=next]").first().attr("href"); String nextPageUrl = doc.select("a[rel=next]").first().attr("href");
if (nextPageUrl.startsWith("http")) { if (nextPageUrl.startsWith("http")) {
nextPageUrl = nextPageUrl.replaceAll("https?://\\w?\\w?\\.?xhamster\\.", "https://m.xhamster."); nextPageUrl = nextPageUrl.replaceAll("https?://\\w?\\w?\\.?xhamster([^<]*)\\.", "https://m.xhamster$1.");
nextPageUrl = nextPageUrl.replaceAll("https?://xhamster2\\.", "https://m.xhamster2.");
return Http.url(nextPageUrl).get(); return Http.url(nextPageUrl).get();
} }
} }
@@ -165,8 +163,7 @@ public class XhamsterRipper extends AbstractHTMLRipper {
try { try {
// This works around some redirect fuckery xhamster likes to do where visiting m.xhamster.com sends to // This works around some redirect fuckery xhamster likes to do where visiting m.xhamster.com sends to
// the page chamster.com but displays the mobile site from m.xhamster.com // the page chamster.com but displays the mobile site from m.xhamster.com
pageWithImageUrl = pageWithImageUrl.replaceAll("://xhamster\\.", "://m.xhamster."); pageWithImageUrl = pageWithImageUrl.replaceAll("://xhamster([^<]*)\\.", "://m.xhamster$1.");
pageWithImageUrl = pageWithImageUrl.replaceAll("://xhamster2\\.", "://m.xhamster.");
String image = Http.url(new URL(pageWithImageUrl)).get().select("a > img#photoCurr").attr("src"); String image = Http.url(new URL(pageWithImageUrl)).get().select("a > img#photoCurr").attr("src");
downloadFile(image); downloadFile(image);
} catch (IOException e) { } catch (IOException e) {

View File

@@ -30,6 +30,7 @@ public class ImagefapRipperTest extends RippersTest {
} }
} }
@Test @Test
@Tag("flaky")
public void testImagefapGetAlbumTitle() throws IOException { public void testImagefapGetAlbumTitle() throws IOException {
URL url = new URL("https://www.imagefap.com/gallery.php?gid=7789753"); URL url = new URL("https://www.imagefap.com/gallery.php?gid=7789753");
ImagefapRipper ripper = new ImagefapRipper(url); ImagefapRipper ripper = new ImagefapRipper(url);

View File

@@ -29,7 +29,7 @@ public class PornhubRipperTest extends RippersTest {
@Test @Test
public void testGetNextPage() throws IOException { public void testGetNextPage() throws IOException {
String baseURL = "https://www.pornhub.com/album/43902391"; String baseURL = "https://www.pornhub.com/album/30687901";
PornhubRipper ripper = new PornhubRipper(new URL(baseURL)); PornhubRipper ripper = new PornhubRipper(new URL(baseURL));
Document page = Http.url(baseURL).get(); Document page = Http.url(baseURL).get();
int numPagesRemaining = 1; int numPagesRemaining = 1;

View File

@@ -61,6 +61,7 @@ public class RedditRipperTest extends RippersTest {
} }
@Test @Test
@Tag("flaky")
public void testRedditGallery() throws IOException{ public void testRedditGallery() throws IOException{
RedditRipper ripper = new RedditRipper( RedditRipper ripper = new RedditRipper(
new URL("https://www.reddit.com/gallery/hrrh23")); new URL("https://www.reddit.com/gallery/hrrh23"));

View File

@@ -46,6 +46,7 @@ public class RedgifsRipperTest extends RippersTest {
* @throws IOException * @throws IOException
*/ */
@Test @Test
@Disabled("test or ripper broken")
public void testRedgifsSearch() throws IOException { public void testRedgifsSearch() throws IOException {
RedgifsRipper ripper = new RedgifsRipper(new URL("https://redgifs.com/gifs/browse/little-caprice")); RedgifsRipper ripper = new RedgifsRipper(new URL("https://redgifs.com/gifs/browse/little-caprice"));
Document doc = ripper.getFirstPage(); Document doc = ripper.getFirstPage();

View File

@@ -35,7 +35,7 @@ public class XhamsterRipperTest extends RippersTest {
@Test @Test
@Tag("flaky") @Tag("flaky")
public void testXhamsterAlbumDesiDomain() throws IOException { public void testXhamsterAlbumDesiDomain() throws IOException {
XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster.desi/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664")); XhamsterRipper ripper = new XhamsterRipper(new URL("https://xhamster5.desi/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664"));
testRipper(ripper); testRipper(ripper);
} }
@Test @Test
@@ -49,9 +49,9 @@ public class XhamsterRipperTest extends RippersTest {
XhamsterRipper ripper = new XhamsterRipper(new URL("https://pt.xhamster.com/photos/gallery/silvana-7105696")); XhamsterRipper ripper = new XhamsterRipper(new URL("https://pt.xhamster.com/photos/gallery/silvana-7105696"));
testRipper(ripper); testRipper(ripper);
} }
@Test
public void testGetGID() throws IOException { public void testGetGID() throws IOException {
URL url = new URL("https://xhamster.com/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664"); URL url = new URL("https://xhamster5.desi/photos/gallery/japanese-dolls-4-asahi-mizuno-7254664");
XhamsterRipper ripper = new XhamsterRipper(url); XhamsterRipper ripper = new XhamsterRipper(url);
Assertions.assertEquals("7254664", ripper.getGID(url)); Assertions.assertEquals("7254664", ripper.getGID(url));
} }

View File

@@ -1,6 +1,7 @@
package com.rarchives.ripme.tst.ripper.rippers; package com.rarchives.ripme.tst.ripper.rippers;
import com.rarchives.ripme.ripper.rippers.YoupornRipper; import com.rarchives.ripme.ripper.rippers.YoupornRipper;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
@@ -10,6 +11,7 @@ import java.util.List;
public class YoupornRipperTest extends RippersTest { public class YoupornRipperTest extends RippersTest {
@Test @Test
@Tag("flaky")
public void testYoupornRipper() throws IOException { public void testYoupornRipper() throws IOException {
List<URL> contentURLs = new ArrayList<>(); List<URL> contentURLs = new ArrayList<>();
contentURLs.add(new URL("http://www.youporn.com/watch/7669155/mrs-li-amateur-69-orgasm/?from=categ")); contentURLs.add(new URL("http://www.youporn.com/watch/7669155/mrs-li-amateur-69-orgasm/?from=categ"));