From: David ‘Bombe’ Roden Date: Tue, 5 Nov 2013 06:09:06 +0000 (+0100) Subject: Allow multiple images on GPF. X-Git-Tag: v2~263 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=27e61fdc6e284e676bd711d3784ba3ba26b54dbb;p=rhynodge.git Allow multiple images on GPF. --- diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/comics/GeneralProtectionFaultComicFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/comics/GeneralProtectionFaultComicFilter.java index 660867a..0a8f16a 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/comics/GeneralProtectionFaultComicFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/comics/GeneralProtectionFaultComicFilter.java @@ -17,14 +17,19 @@ package net.pterodactylus.rhynodge.filters.comics; -import java.util.Arrays; +import static com.google.common.collect.FluentIterable.from; +import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; + import java.util.Collections; import java.util.List; import net.pterodactylus.rhynodge.filters.ComicSiteFilter; +import com.google.common.base.Function; import com.google.common.base.Optional; import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; import org.jsoup.select.Elements; /** @@ -43,12 +48,17 @@ public class GeneralProtectionFaultComicFilter extends ComicSiteFilter { @Override protected List extractImageUrls(Document document) { Elements imageElements = document.select(".content img[alt~=.Comic.for]"); - return imageElements.hasAttr("src") ? Arrays.asList(imageElements.attr("src")) : Collections.emptyList(); + return from(imageElements).transformAndConcat(new Function>() { + @Override + public Iterable apply(Element element) { + return ((element != null) && element.hasAttr("src")) ? asList(element.attr("src")) : Collections.emptyList(); + } + }).toList(); } @Override protected List extractImageComments(Document document) { - return Collections.emptyList(); + return emptyList(); } }