Skip to content

Commit

Permalink
Add Nude-Gals video support (#2085)
Browse files Browse the repository at this point in the history
* Add Nude-Gals video support
  • Loading branch information
metaprime authored Jan 16, 2025
1 parent 8a545fe commit 686b376
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
import java.util.regex.Matcher;
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.Element;
import org.jsoup.select.Elements;

import com.rarchives.ripme.ripper.AbstractHTMLRipper;
import com.rarchives.ripme.utils.Http;

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 {
super(url);
}
Expand All @@ -36,10 +42,18 @@ public String getGID(URL url) throws MalformedURLException {
Pattern p;
Matcher m;

p = Pattern.compile("^.*nude-gals\\.com/photoshoot\\.php\\?photoshoot_id=(\\d+)$");
p = ALBUM_PATTERN;
m = p.matcher(url.toExternalForm());
if (m.matches()) {
logger.info("Found nude-gals photo album page");
return "album_" + m.group(1);
}

p = VIDEO_PATTERN;
m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
logger.info("Found nude-gals video page");
return "video_" + m.group(1);
}

throw new MalformedURLException(
Expand All @@ -50,17 +64,38 @@ public String getGID(URL url) throws MalformedURLException {

@Override
public List<String> getURLsFromPage(Document doc) {
List<String> imageURLs = new ArrayList<>();

Elements thumbs = doc.select("img.thumbnail");
for (Element thumb : thumbs) {
String link = thumb.attr("src").replaceAll("thumbs/th_", "");
String imgSrc = "http://nude-gals.com/" + link;
imgSrc = imgSrc.replaceAll(" ", "%20");
imageURLs.add(imgSrc);
List<String> urlsToDownload = new ArrayList<>();

Pattern p;
Matcher m;

p = ALBUM_PATTERN;
m = p.matcher(url.toExternalForm());
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);
}
}

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 imageURLs;
return urlsToDownload;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,30 @@
import org.junit.jupiter.api.Test;

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
public void testAlbumRip() throws IOException, URISyntaxException {
NudeGalsRipper ripper = new NudeGalsRipper(new URI(ALBUM_TEST_URL).toURL());
testRipper(ripper);
}

@Test
public void testRip() throws IOException, URISyntaxException {
NudeGalsRipper ripper = new NudeGalsRipper(new URI("https://nude-gals.com/photoshoot.php?photoshoot_id=5541").toURL());
public void testVideoRip() throws IOException, URISyntaxException {
NudeGalsRipper ripper = new NudeGalsRipper(new URI(VIDEO_TEST_URL).toURL());
testRipper(ripper);
}

@Test
public void testGetGID() throws IOException, URISyntaxException {
NudeGalsRipper ripper = new NudeGalsRipper(new URI("https://nude-gals.com/photoshoot.php?photoshoot_id=5541").toURL());
Assertions.assertEquals("5541", ripper.getGID( new URI("https://nude-gals.com/photoshoot.php?photoshoot_id=5541").toURL()));
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()));
}
}

0 comments on commit 686b376

Please sign in to comment.