Pichunter galleries support (#209)

* Added support for pichunter galleries

* Added unit test for pichunter galleries
This commit is contained in:
cyian-1756 2017-11-17 05:37:47 -05:00 committed by metaprime
parent fad35d1afb
commit d268bb2cee
2 changed files with 28 additions and 2 deletions

View File

@ -47,10 +47,25 @@ public class PichunterRipper extends AbstractHTMLRipper {
if (m.matches()) {
return m.group(1);
}
p = Pattern.compile("https?://www.pichunter.com/gallery/\\d+/([a-zA-Z0-9_-]+)/?");
m = p.matcher(url.toExternalForm());
if (m.matches()) {
return m.group(1);
}
throw new MalformedURLException("Expected pichunter URL format: " +
"pichunter.com/(tags|models|sites)/Name/ - got " + url + " instead");
}
private boolean isPhotoSet(URL url) {
Pattern p = Pattern.compile("https?://www.pichunter.com/gallery/\\d+/([a-zA-Z0-9_-]+)/?");
Matcher m = p.matcher(url.toExternalForm());
if (m.matches()) {
return true;
}
return false;
}
@Override
public Document getFirstPage() throws IOException {
// "url" is an instance field of the superclass
@ -73,9 +88,15 @@ public class PichunterRipper extends AbstractHTMLRipper {
@Override
public List<String> getURLsFromPage(Document doc) {
List<String> result = new ArrayList<>();
if (!isPhotoSet(url)) {
for (Element el : doc.select("div.thumbtable > a.thumb > img")) {
result.add(el.attr("src").replaceAll("_i", "_o"));
}
} else {
for (Element el : doc.select("div.flex-images > figure > a.item > img")) {
result.add(el.attr("src").replaceAll("_i", "_o"));
}
}
return result;
}

View File

@ -196,8 +196,13 @@ public class BasicRippersTest extends RippersTest {
}
public void testPichunterRip() throws IOException {
// A non-photoset
AbstractRipper ripper = new PichunterRipper(new URL("https://www.pichunter.com/models/Madison_Ivy"));
testRipper(ripper);
// a photo set
ripper = new PichunterRipper(new URL("http://www.pichunter.com/gallery/3270642/Its_not_only_those_who"));
testRipper(ripper);
}
public void testMotherlessAlbumRip() throws IOException {