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()) {
|
if (m.matches()) {
|
||||||
return m.group(1);
|
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: " +
|
throw new MalformedURLException("Expected pichunter URL format: " +
|
||||||
"pichunter.com/(tags|models|sites)/Name/ - got " + url + " instead");
|
"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
|
@Override
|
||||||
public Document getFirstPage() throws IOException {
|
public Document getFirstPage() throws IOException {
|
||||||
// "url" is an instance field of the superclass
|
// "url" is an instance field of the superclass
|
||||||
@ -73,9 +88,15 @@ public class PichunterRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
|
if (!isPhotoSet(url)) {
|
||||||
for (Element el : doc.select("div.thumbtable > a.thumb > img")) {
|
for (Element el : doc.select("div.thumbtable > a.thumb > img")) {
|
||||||
result.add(el.attr("src").replaceAll("_i", "_o"));
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +196,13 @@ public class BasicRippersTest extends RippersTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testPichunterRip() throws IOException {
|
public void testPichunterRip() throws IOException {
|
||||||
|
// A non-photoset
|
||||||
AbstractRipper ripper = new PichunterRipper(new URL("https://www.pichunter.com/models/Madison_Ivy"));
|
AbstractRipper ripper = new PichunterRipper(new URL("https://www.pichunter.com/models/Madison_Ivy"));
|
||||||
testRipper(ripper);
|
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 {
|
public void testMotherlessAlbumRip() throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user