From 27e61fdc6e284e676bd711d3784ba3ba26b54dbb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Nov 2013 07:09:06 +0100 Subject: [PATCH] Allow multiple images on GPF. --- .../comics/GeneralProtectionFaultComicFilter.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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(); } } -- 2.7.4