From 12204f16f950c0a78c727ef87412cbc792a3f8d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 8 Nov 2024 20:51:44 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=A8=20Add=20Grrl=20Power=20comic?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../rhynodge/filters/comics/GrrlPowerFilter.kt | 19 + .../rhynodge/watchers/GrrlPowerWatcher.kt | 13 + .../rhynodge/filters/comics/GrrlPowerFilterTest.kt | 16 + .../rhynodge/filters/comics/grrl-power.html | 1452 ++++++++++++++++++++ 4 files changed, 1500 insertions(+) create mode 100644 src/main/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilter.kt create mode 100644 src/main/kotlin/net/pterodactylus/rhynodge/watchers/GrrlPowerWatcher.kt create mode 100644 src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilterTest.kt create mode 100644 src/test/resources/net/pterodactylus/rhynodge/filters/comics/grrl-power.html diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilter.kt b/src/main/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilter.kt new file mode 100644 index 0000000..a5c0f38 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilter.kt @@ -0,0 +1,19 @@ +package net.pterodactylus.rhynodge.filters.comics + +import com.google.common.base.Optional +import net.pterodactylus.rhynodge.filters.ComicSiteFilter +import net.pterodactylus.rhynodge.utils.asOptional +import org.jsoup.nodes.Document + +class GrrlPowerFilter : ComicSiteFilter() { + + override fun extractTitle(document: Document): Optional = + document.select("#comic img").attr("title").asOptional() + + override fun extractImageUrls(document: Document) = + document.select("#comic img").map { it.attr("src") } + + override fun extractImageComments(document: Document) = + emptyList() + +} diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/watchers/GrrlPowerWatcher.kt b/src/main/kotlin/net/pterodactylus/rhynodge/watchers/GrrlPowerWatcher.kt new file mode 100644 index 0000000..a737458 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/rhynodge/watchers/GrrlPowerWatcher.kt @@ -0,0 +1,13 @@ +package net.pterodactylus.rhynodge.watchers + +import net.pterodactylus.rhynodge.filters.HtmlFilter +import net.pterodactylus.rhynodge.filters.comics.GrrlPowerFilter +import net.pterodactylus.rhynodge.mergers.ComicMerger +import net.pterodactylus.rhynodge.queries.HttpQuery + +@Suppress("unused") +class GrrlPowerWatcher : DefaultWatcher(query, filters, merger) + +private val query = HttpQuery("https://www.grrlpowercomic.com/") +private val filters = listOf(HtmlFilter(), GrrlPowerFilter()) +private val merger = ComicMerger() diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilterTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilterTest.kt new file mode 100644 index 0000000..a499293 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/GrrlPowerFilterTest.kt @@ -0,0 +1,16 @@ +package net.pterodactylus.rhynodge.filters.comics + +import net.pterodactylus.rhynodge.states.ComicState +import net.pterodactylus.rhynodge.states.ComicState.Strip + +class GrrlPowerFilterTest : ComicSiteFilterTest() { + + override val filter = GrrlPowerFilter() + override val baseUrl = "https://www.grrlpowercomic.com/" + override val resource = "grrl-power.html" + override val expectedComics = listOf( + ComicState.Comic("Grrl Power #1302 – Oh, What A Feeling!") + .add(Strip("https://www.grrlpowercomic.com/wp-content/uploads/2024/11/2024-11-07-GP1302.jpg", "")) + ) + +} diff --git a/src/test/resources/net/pterodactylus/rhynodge/filters/comics/grrl-power.html b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/grrl-power.html new file mode 100644 index 0000000..c745228 --- /dev/null +++ b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/grrl-power.html @@ -0,0 +1,1452 @@ + + + + + + + + + + + + + + + + + + + + +Grrl Power – A webcomic about superheroines. + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ + +
+
+
+
+ + + + + + + + + +
‹‹ First‹ PrevComments(77)Next ›Last ››
+
+
+
+ Grrl Power #1302 – Oh, What A Feeling!
+
+
+ + + + + + + + + +
‹‹ First‹ PrevComments(77)Next ›Last ››
+
+
+
+
+ +
+ + + + +
+
+
+
+
+
+
+ +
+ + +
+
+
+ + + + + + \ No newline at end of file -- 2.7.4