88import java .util .regex .Matcher ;
99import java .util .regex .Pattern ;
1010
11+ import org .apache .logging .log4j .LogManager ;
12+ import org .apache .logging .log4j .Logger ;
1113import org .jsoup .nodes .Document ;
1214import org .jsoup .nodes .Element ;
1315import org .jsoup .select .Elements ;
1416
1517import com .rarchives .ripme .ripper .AbstractHTMLRipper ;
16- import com .rarchives .ripme .utils .Http ;
1718
1819public class NudeGalsRipper extends AbstractHTMLRipper {
1920
21+ private static final Logger logger = LogManager .getLogger (NudeGalsRipper .class );
22+
23+ private static final Pattern ALBUM_PATTERN = Pattern .compile ("^.*nude-gals\\ .com/photoshoot\\ .php\\ ?photoshoot_id=(\\ d+)$" );
24+ private static final Pattern VIDEO_PATTERN = Pattern .compile ("^.*nude-gals\\ .com/video\\ .php\\ ?video_id=(\\ d+)$" );
25+
2026 public NudeGalsRipper (URL url ) throws IOException {
2127 super (url );
2228 }
@@ -36,10 +42,18 @@ public String getGID(URL url) throws MalformedURLException {
3642 Pattern p ;
3743 Matcher m ;
3844
39- p = Pattern .compile ("^.*nude-gals\\ .com/photoshoot\\ .php\\ ?photoshoot_id=(\\ d+)$" );
45+ p = ALBUM_PATTERN ;
46+ m = p .matcher (url .toExternalForm ());
47+ if (m .matches ()) {
48+ logger .info ("Found nude-gals photo album page" );
49+ return "album_" + m .group (1 );
50+ }
51+
52+ p = VIDEO_PATTERN ;
4053 m = p .matcher (url .toExternalForm ());
4154 if (m .matches ()) {
42- return m .group (1 );
55+ logger .info ("Found nude-gals video page" );
56+ return "video_" + m .group (1 );
4357 }
4458
4559 throw new MalformedURLException (
@@ -50,17 +64,38 @@ public String getGID(URL url) throws MalformedURLException {
5064
5165 @ Override
5266 public List <String > getURLsFromPage (Document doc ) {
53- List <String > imageURLs = new ArrayList <>();
54-
55- Elements thumbs = doc .select ("img.thumbnail" );
56- for (Element thumb : thumbs ) {
57- String link = thumb .attr ("src" ).replaceAll ("thumbs/th_" , "" );
58- String imgSrc = "http://nude-gals.com/" + link ;
59- imgSrc = imgSrc .replaceAll (" " , "%20" );
60- imageURLs .add (imgSrc );
67+ List <String > urlsToDownload = new ArrayList <>();
68+
69+ Pattern p ;
70+ Matcher m ;
71+
72+ p = ALBUM_PATTERN ;
73+ m = p .matcher (url .toExternalForm ());
74+ if (m .matches ()) {
75+ logger .info ("Ripping nude-gals photo album" );
76+ Elements thumbs = doc .select ("img.thumbnail" );
77+ for (Element thumb : thumbs ) {
78+ String link = thumb .attr ("src" ).strip ().replaceAll ("thumbs/th_" , "" );
79+ String imgSrc = "http://nude-gals.com/" + link ;
80+ imgSrc = imgSrc .replaceAll (" " , "%20" );
81+ urlsToDownload .add (imgSrc );
82+ }
83+ }
84+
85+ p = VIDEO_PATTERN ;
86+ m = p .matcher (url .toExternalForm ());
87+ if (m .matches ()) {
88+ logger .info ("Ripping nude-gals video" );
89+ Elements thumbs = doc .select ("video source" );
90+ for (Element thumb : thumbs ) {
91+ String link = thumb .attr ("src" ).strip ();
92+ String videoSrc = "http://nude-gals.com/" + link ;
93+ videoSrc = videoSrc .replaceAll (" " , "%20" );
94+ urlsToDownload .add (videoSrc );
95+ }
6196 }
6297
63- return imageURLs ;
98+ return urlsToDownload ;
6499 }
65100
66101 @ Override
0 commit comments