Merge pull request #421 from cyian-1756/8muses
8muses now supports all page types
This commit is contained in:
commit
16baeb6f3c
@ -88,29 +88,13 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document page) {
|
public List<String> getURLsFromPage(Document page) {
|
||||||
List<String> imageURLs = new ArrayList<>();
|
List<String> imageURLs = new ArrayList<>();
|
||||||
// get the first image link on the page and check if the last char in it is a number
|
int x = 1;
|
||||||
// if it is a number then we're ripping a comic if not it's a subalbum
|
// This contains the thumbnails of all images on the page
|
||||||
String firstImageLink = page.select("div.gallery > a.t-hover").first().attr("href");
|
Elements pageImages = page.getElementsByClass("c-tile");
|
||||||
Pattern p = Pattern.compile("/comix/picture/([a-zA-Z0-9\\-_/]*/)?\\d+");
|
for (Element thumb : pageImages) {
|
||||||
Matcher m = p.matcher(firstImageLink);
|
// If true this link is a sub album
|
||||||
if (!m.matches()) {
|
if (thumb.attr("href").contains("/comix/album/")) {
|
||||||
logger.info("Ripping subalbums");
|
String subUrl = "https://www.8muses.com" + thumb.attr("href");
|
||||||
// Page contains subalbums (not images)
|
|
||||||
Elements albumElements = page.select("div.gallery > a.t-hover");
|
|
||||||
List<Element> albumsList = albumElements.subList(0, albumElements.size());
|
|
||||||
Collections.reverse(albumsList);
|
|
||||||
// Iterate over elements in reverse order
|
|
||||||
for (Element subalbum : albumsList) {
|
|
||||||
String subUrl = subalbum.attr("href");
|
|
||||||
// This if is to skip ads which don't have a href
|
|
||||||
if (subUrl != "") {
|
|
||||||
subUrl = subUrl.replaceAll("\\.\\./", "");
|
|
||||||
if (subUrl.startsWith("//")) {
|
|
||||||
subUrl = "https:";
|
|
||||||
}
|
|
||||||
else if (!subUrl.startsWith("http://")) {
|
|
||||||
subUrl = "https://www.8muses.com" + subUrl;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
logger.info("Retrieving " + subUrl);
|
logger.info("Retrieving " + subUrl);
|
||||||
sendUpdate(STATUS.LOADING_RESOURCE, subUrl);
|
sendUpdate(STATUS.LOADING_RESOURCE, subUrl);
|
||||||
@ -121,14 +105,9 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Error while loading subalbum " + subUrl, e);
|
logger.warn("Error while loading subalbum " + subUrl, e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
} else if (thumb.attr("href").contains("/comix/picture/")) {
|
||||||
}
|
logger.info("Ripping image");
|
||||||
else {
|
|
||||||
// Page contains images
|
|
||||||
// X is our page index
|
|
||||||
int x = 1;
|
|
||||||
for (Element thumb : page.select(".image")) {
|
|
||||||
if (super.isStopped()) break;
|
if (super.isStopped()) break;
|
||||||
// Find thumbnail image source
|
// Find thumbnail image source
|
||||||
String image = null;
|
String image = null;
|
||||||
@ -136,21 +115,21 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
image = thumb.attr("data-cfsrc");
|
image = thumb.attr("data-cfsrc");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String parentHref = thumb.parent().attr("href");
|
String imageHref = thumb.attr("href");
|
||||||
if (parentHref.equals("")) continue;
|
if (imageHref.equals("")) continue;
|
||||||
if (parentHref.startsWith("/")) {
|
if (imageHref.startsWith("/")) {
|
||||||
parentHref = "https://www.8muses.com" + parentHref;
|
imageHref = "https://www.8muses.com" + imageHref;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
logger.info("Retrieving full-size image location from " + parentHref);
|
logger.info("Retrieving full-size image location from " + imageHref);
|
||||||
image = getFullSizeImage(parentHref);
|
image = getFullSizeImage(imageHref);
|
||||||
URL imageUrl = new URL(image);
|
URL imageUrl = new URL(image);
|
||||||
addURLToDownload(imageUrl, getPrefix(x), getSubdir(page.select("title").text()), this.url.toExternalForm(), cookies);
|
addURLToDownload(imageUrl, getPrefix(x), getSubdir(page.select("title").text()), this.url.toExternalForm(), cookies);
|
||||||
// X is our page index
|
// X is our page index
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Failed to get full-size image from " + parentHref);
|
logger.error("Failed to get full-size image from " + imageHref);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,6 +140,7 @@ public class EightmusesRipper extends AbstractHTMLRipper {
|
|||||||
imageURLs.add(image);
|
imageURLs.add(image);
|
||||||
if (isThisATest()) break;
|
if (isThisATest()) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return imageURLs;
|
return imageURLs;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,11 @@ import com.rarchives.ripme.ripper.rippers.EightmusesRipper;
|
|||||||
|
|
||||||
public class EightmusesRipperTest extends RippersTest {
|
public class EightmusesRipperTest extends RippersTest {
|
||||||
public void testEightmusesAlbum() throws IOException {
|
public void testEightmusesAlbum() throws IOException {
|
||||||
EightmusesRipper ripper = new EightmusesRipper(new URL("https://www.8muses.com/album/jab-comics/a-model-life"));
|
// A simple image album
|
||||||
|
EightmusesRipper ripper = new EightmusesRipper(new URL("https://www.8muses.com/comix/album/Affect3D-Comics/TheDude3DX/Lust-Unleashed-The-Urge-To-Explore"));
|
||||||
|
testRipper(ripper);
|
||||||
|
// Test pages with subalbums
|
||||||
|
ripper = new EightmusesRipper(new URL("https://www.8muses.com/comix/album/Blacknwhitecomics_com-Comix/BlacknWhiteComics/The-Mayor"));
|
||||||
testRipper(ripper);
|
testRipper(ripper);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user