Add filter for “The Monster under the Bed”
[rhynodge.git] / src / main / kotlin / net / pterodactylus / rhynodge / filters / comics / TheMonsterUnderTheBedFilter.kt
1 package net.pterodactylus.rhynodge.filters.comics
2
3 import com.google.common.base.*
4 import com.google.common.base.Optional.*
5 import net.pterodactylus.rhynodge.filters.*
6 import org.jsoup.nodes.*
7
8 class TheMonsterUnderTheBedFilter : ComicSiteFilter() {
9
10         override fun extractTitle(document: Document): Optional<String> =
11                         document.select("h2.post-title").text().toOptional()
12
13         override fun extractImageUrls(document: Document): List<String> =
14                         document.select("div#comic img").map { it.attr("src") }
15
16         override fun extractImageComments(document: Document): List<String> = emptyList()
17
18 }
19
20 private fun <T> T?.toOptional(): Optional<T> = fromNullable(this)