mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-09-03 02:42:47 +02:00
Fix #1868 Imagebam Error : Change Layout
This commit is contained in:
@@ -11,6 +11,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
@@ -80,7 +82,7 @@ public class ImagebamRipper extends AbstractHTMLRipper {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getURLsFromPage(Document doc) {
|
public List<String> getURLsFromPage(Document doc) {
|
||||||
List<String> imageURLs = new ArrayList<>();
|
List<String> imageURLs = new ArrayList<>();
|
||||||
for (Element thumb : doc.select("div > a[target=_blank]:not(.footera)")) {
|
for (Element thumb : doc.select("div > a[class=thumbnail]:not(.footera)")) {
|
||||||
imageURLs.add(thumb.attr("href"));
|
imageURLs.add(thumb.attr("href"));
|
||||||
}
|
}
|
||||||
return imageURLs;
|
return imageURLs;
|
||||||
@@ -97,15 +99,12 @@ public class ImagebamRipper extends AbstractHTMLRipper {
|
|||||||
public String getAlbumTitle(URL url) throws MalformedURLException {
|
public String getAlbumTitle(URL url) throws MalformedURLException {
|
||||||
try {
|
try {
|
||||||
// Attempt to use album title as GID
|
// Attempt to use album title as GID
|
||||||
Elements elems = getFirstPage().select("legend");
|
Elements elems = getFirstPage().select("[id=gallery-name]");
|
||||||
String title = elems.first().text();
|
String title = elems.first().text();
|
||||||
LOGGER.info("Title text: '" + title + "'");
|
LOGGER.info("Title text: '" + title + "'");
|
||||||
Pattern p = Pattern.compile("^(.*)\\s\\d* image.*$");
|
if (StringUtils.isNotBlank(title)) {
|
||||||
Matcher m = p.matcher(title);
|
return getHost() + "_" + getGID(url) + " (" + title + ")";
|
||||||
if (m.matches()) {
|
|
||||||
return getHost() + "_" + getGID(url) + " (" + m.group(1).trim() + ")";
|
|
||||||
}
|
}
|
||||||
LOGGER.info("Doesn't match " + p.pattern());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Fall back to default album naming convention
|
// Fall back to default album naming convention
|
||||||
LOGGER.warn("Failed to get album title from " + url, e);
|
LOGGER.warn("Failed to get album title from " + url, e);
|
||||||
@@ -143,14 +142,9 @@ public class ImagebamRipper extends AbstractHTMLRipper {
|
|||||||
Elements metaTags = doc.getElementsByTag("meta");
|
Elements metaTags = doc.getElementsByTag("meta");
|
||||||
|
|
||||||
String imgsrc = "";//initialize, so no NullPointerExceptions should ever happen.
|
String imgsrc = "";//initialize, so no NullPointerExceptions should ever happen.
|
||||||
|
Elements elem = doc.select("img[class*=main-image]");
|
||||||
for (Element metaTag: metaTags) {
|
if ((elem != null) && (elem.size() > 0)) {
|
||||||
//the direct link to the image seems to always be linked in the <meta> part of the html.
|
imgsrc = elem.first().attr("src");
|
||||||
if (metaTag.attr("property").equals("og:image")) {
|
|
||||||
imgsrc = metaTag.attr("content");
|
|
||||||
LOGGER.info("Found URL " + imgsrc);
|
|
||||||
break;//only one (useful) image possible for an "image page".
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//for debug, or something goes wrong.
|
//for debug, or something goes wrong.
|
||||||
|
Reference in New Issue
Block a user