Fix 8muses. Closes #244
This commit is contained in:
parent
5d31eb4f1a
commit
d4c54b0f71
@ -107,18 +107,30 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Page contains images
|
// Page contains images
|
||||||
for (Element thumb : page.select("img")) {
|
for (Element thumb : page.select("div.item .holder img")) {
|
||||||
|
if (super.isStopped()) break;
|
||||||
// Find thumbnail image source
|
// Find thumbnail image source
|
||||||
String image = null;
|
String image = null;
|
||||||
if (thumb.hasAttr("data-cfsrc")) {
|
if (thumb.hasAttr("data-cfsrc")) {
|
||||||
image = thumb.attr("data-cfsrc");
|
image = thumb.attr("data-cfsrc");
|
||||||
}
|
}
|
||||||
else if (thumb.hasAttr("src")) {
|
|
||||||
image = thumb.attr("src");
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
logger.warn("Thumb does not have data-cfsrc or src: " + thumb);
|
String parentHref = thumb.parent().attr("href");
|
||||||
continue;
|
if (parentHref.equals("")) continue;
|
||||||
|
if (parentHref.startsWith("/")) {
|
||||||
|
parentHref = "https://www.8muses.com" + parentHref;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
logger.info("Retrieving full-size image location from " + parentHref);
|
||||||
|
Thread.sleep(1000);
|
||||||
|
image = getFullSizeImage(parentHref);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("Failed to get full-size image from " + parentHref);
|
||||||
|
continue;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("Interrupted while getting full-size image from " + parentHref);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!image.contains("8muses.com")) {
|
if (!image.contains("8muses.com")) {
|
||||||
// Not hosted on 8mues.
|
// Not hosted on 8mues.
|
||||||
@ -135,11 +147,17 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
}
|
}
|
||||||
image = image.replaceAll(" ", "%20");
|
image = image.replaceAll(" ", "%20");
|
||||||
imageURLs.add(image);
|
imageURLs.add(image);
|
||||||
|
if (isThisATest()) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return imageURLs;
|
return imageURLs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFullSizeImage(String imageUrl) throws IOException {
|
||||||
|
Document doc = new Http(imageUrl).get();
|
||||||
|
return doc.select("#image").first().attr("src");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadURL(URL url, int index) {
|
public void downloadURL(URL url, int index) {
|
||||||
addURLToDownload(url, getPrefix(index), "", this.url.toExternalForm(), cookies);
|
addURLToDownload(url, getPrefix(index), "", this.url.toExternalForm(), cookies);
|
||||||
|
@ -60,6 +60,8 @@ public class BasicRippersTest extends RippersTest {
|
|||||||
public void testEightmusesAlbum() throws IOException {
|
public void testEightmusesAlbum() throws IOException {
|
||||||
EightmusesRipper ripper = new EightmusesRipper(new URL("http://www.8muses.com/index/category/jab-hotassneighbor7"));
|
EightmusesRipper ripper = new EightmusesRipper(new URL("http://www.8muses.com/index/category/jab-hotassneighbor7"));
|
||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
|
ripper = new EightmusesRipper(new URL("https://www.8muses.com/album/jab-comics/a-model-life"));
|
||||||
|
testRipper(ripper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVineboxAlbum() throws IOException {
|
public void testVineboxAlbum() throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user