Pichunter galleries support (#209)
* Added support for pichunter galleries * Added unit test for pichunter galleries
This commit is contained in:
parent
fad35d1afb
commit
d268bb2cee
@ -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,8 +88,14 @@ public class PichunterRipper extends AbstractHTMLRipper {
|
||||
@Override
|
||||
public List<String> getURLsFromPage(Document doc) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Element el : doc.select("div.thumbtable > a.thumb > img")) {
|
||||
result.add(el.attr("src").replaceAll("_i", "_o"));
|
||||
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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user