mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-01-17 12:48:24 +01:00
parent
8a545fe180
commit
686b376ba7
@ -8,15 +8,21 @@ 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 org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
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.AbstractHTMLRipper;
|
import com.rarchives.ripme.ripper.AbstractHTMLRipper;
|
||||||
import com.rarchives.ripme.utils.Http;
|
|
||||||
|
|
||||||
public class NudeGalsRipper extends AbstractHTMLRipper {
|
public class NudeGalsRipper extends AbstractHTMLRipper {
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger(NudeGalsRipper.class);
|
||||||
|
|
||||||
|
private static final Pattern ALBUM_PATTERN = Pattern.compile("^.*nude-gals\\.com/photoshoot\\.php\\?photoshoot_id=(\\d+)$");
|
||||||
|
private static final Pattern VIDEO_PATTERN = Pattern.compile("^.*nude-gals\\.com/video\\.php\\?video_id=(\\d+)$");
|
||||||
|
|
||||||
public NudeGalsRipper(URL url) throws IOException {
|
public NudeGalsRipper(URL url) throws IOException {
|
||||||
super(url);
|
super(url);
|
||||||
}
|
}
|
||||||
@ -36,10 +42,18 @@ public class NudeGalsRipper extends AbstractHTMLRipper {
|
|||||||
Pattern p;
|
Pattern p;
|
||||||
Matcher m;
|
Matcher m;
|
||||||
|
|
||||||
p = Pattern.compile("^.*nude-gals\\.com/photoshoot\\.php\\?photoshoot_id=(\\d+)$");
|
p = ALBUM_PATTERN;
|
||||||
m = p.matcher(url.toExternalForm());
|
m = p.matcher(url.toExternalForm());
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return m.group(1);
|
logger.info("Found nude-gals photo album page");
|
||||||
|
return "album_" + m.group(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = VIDEO_PATTERN;
|
||||||
|
m = p.matcher(url.toExternalForm());
|
||||||
|
if (m.matches()) {
|
||||||
|
logger.info("Found nude-gals video page");
|
||||||
|
return "video_" + m.group(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new MalformedURLException(
|
throw new MalformedURLException(
|
||||||
@ -50,17 +64,38 @@ public class NudeGalsRipper extends AbstractHTMLRipper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> imageURLs = new ArrayList<>();
|
List<String> urlsToDownload = new ArrayList<>();
|
||||||
|
|
||||||
Elements thumbs = doc.select("img.thumbnail");
|
Pattern p;
|
||||||
for (Element thumb : thumbs) {
|
Matcher m;
|
||||||
String link = thumb.attr("src").replaceAll("thumbs/th_", "");
|
|
||||||
String imgSrc = "http://nude-gals.com/" + link;
|
p = ALBUM_PATTERN;
|
||||||
imgSrc = imgSrc.replaceAll(" ", "%20");
|
m = p.matcher(url.toExternalForm());
|
||||||
imageURLs.add(imgSrc);
|
if (m.matches()) {
|
||||||
|
logger.info("Ripping nude-gals photo album");
|
||||||
|
Elements thumbs = doc.select("img.thumbnail");
|
||||||
|
for (Element thumb : thumbs) {
|
||||||
|
String link = thumb.attr("src").strip().replaceAll("thumbs/th_", "");
|
||||||
|
String imgSrc = "http://nude-gals.com/" + link;
|
||||||
|
imgSrc = imgSrc.replaceAll(" ", "%20");
|
||||||
|
urlsToDownload.add(imgSrc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageURLs;
|
p = VIDEO_PATTERN;
|
||||||
|
m = p.matcher(url.toExternalForm());
|
||||||
|
if (m.matches()) {
|
||||||
|
logger.info("Ripping nude-gals video");
|
||||||
|
Elements thumbs = doc.select("video source");
|
||||||
|
for (Element thumb : thumbs) {
|
||||||
|
String link = thumb.attr("src").strip();
|
||||||
|
String videoSrc = "http://nude-gals.com/" + link;
|
||||||
|
videoSrc = videoSrc.replaceAll(" ", "%20");
|
||||||
|
urlsToDownload.add(videoSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return urlsToDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,15 +9,30 @@ import org.junit.jupiter.api.Assertions;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class NudeGalsRipperTest extends RippersTest {
|
public class NudeGalsRipperTest extends RippersTest {
|
||||||
|
private static String ALBUM_TEST_URL = "https://nude-gals.com/photoshoot.php?photoshoot_id=5541";
|
||||||
|
private static String VIDEO_TEST_URL = "https://nude-gals.com/video.php?video_id=1277";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRip() throws IOException, URISyntaxException {
|
public void testAlbumRip() throws IOException, URISyntaxException {
|
||||||
NudeGalsRipper ripper = new NudeGalsRipper(new URI("https://nude-gals.com/photoshoot.php?photoshoot_id=5541").toURL());
|
NudeGalsRipper ripper = new NudeGalsRipper(new URI(ALBUM_TEST_URL).toURL());
|
||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetGID() throws IOException, URISyntaxException {
|
public void testVideoRip() throws IOException, URISyntaxException {
|
||||||
NudeGalsRipper ripper = new NudeGalsRipper(new URI("https://nude-gals.com/photoshoot.php?photoshoot_id=5541").toURL());
|
NudeGalsRipper ripper = new NudeGalsRipper(new URI(VIDEO_TEST_URL).toURL());
|
||||||
Assertions.assertEquals("5541", ripper.getGID( new URI("https://nude-gals.com/photoshoot.php?photoshoot_id=5541").toURL()));
|
testRipper(ripper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAlbumGID() throws IOException, URISyntaxException {
|
||||||
|
NudeGalsRipper ripper = new NudeGalsRipper(new URI(ALBUM_TEST_URL).toURL());
|
||||||
|
Assertions.assertEquals("album_5541", ripper.getGID( new URI(ALBUM_TEST_URL).toURL()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetVideoGID() throws IOException, URISyntaxException {
|
||||||
|
NudeGalsRipper ripper = new NudeGalsRipper(new URI(VIDEO_TEST_URL).toURL());
|
||||||
|
Assertions.assertEquals("video_1277", ripper.getGID(new URI(VIDEO_TEST_URL).toURL()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user