Fix 8muses. Closes #244

This commit is contained in:
4pr0n 2015-09-17 02:33:06 -07:00
parent 5d31eb4f1a
commit d4c54b0f71
2 changed files with 26 additions and 6 deletions

View File

@ -107,18 +107,30 @@ public class EightmusesRipper extends AbstractHTMLRipper {
}
else {
// 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
String image = null;
if (thumb.hasAttr("data-cfsrc")) {
image = thumb.attr("data-cfsrc");
}
else if (thumb.hasAttr("src")) {
image = thumb.attr("src");
}
else {
logger.warn("Thumb does not have data-cfsrc or src: " + thumb);
continue;
String parentHref = thumb.parent().attr("href");
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")) {
// Not hosted on 8mues.
@ -135,11 +147,17 @@ public class EightmusesRipper extends AbstractHTMLRipper {
}
image = image.replaceAll(" ", "%20");
imageURLs.add(image);
if (isThisATest()) break;
}
}
return imageURLs;
}
private String getFullSizeImage(String imageUrl) throws IOException {
Document doc = new Http(imageUrl).get();
return doc.select("#image").first().attr("src");
}
@Override
public void downloadURL(URL url, int index) {
addURLToDownload(url, getPrefix(index), "", this.url.toExternalForm(), cookies);

View File

@ -60,6 +60,8 @@ public class BasicRippersTest extends RippersTest {
public void testEightmusesAlbum() throws IOException {
EightmusesRipper ripper = new EightmusesRipper(new URL("http://www.8muses.com/index/category/jab-hotassneighbor7"));
testRipper(ripper);
ripper = new EightmusesRipper(new URL("https://www.8muses.com/album/jab-comics/a-model-life"));
testRipper(ripper);
}
public void testVineboxAlbum() throws IOException {