Tachiyomi-Extensions/multisrc/overrides/wpcomics/xoxocomics/src/XoxoComics.kt

48 lines
2.0 KiB
Kotlin

package eu.kanade.tachiyomi.extension.en.xoxocomics
import eu.kanade.tachiyomi.multisrc.wpcomics.WPComics
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.Locale
class XoxoComics : WPComics("XOXO Comics", "https://xoxocomics.com", "en", SimpleDateFormat("MM/dd/yy", Locale.US), null) {
override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/comic-updates?page=$page", headers)
override fun latestUpdatesSelector() = "li.row"
override fun latestUpdatesFromElement(element: Element): SManga {
return SManga.create().apply {
element.select("h3 a").let {
title = it.text()
setUrlWithoutDomain(it.attr("href"))
}
thumbnail_url = element.select("img").attr("data-original")
}
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
return GET("$baseUrl/search?keyword=$query&page=$page", headers)
}
override fun chapterListParse(response: Response): List<SChapter> {
val chapters = mutableListOf<SChapter>()
// recursively add chapters from paginated chapter list
fun parseChapters(document: Document) {
document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) }
document.select("ul.pagination a[rel=next]").firstOrNull()?.let { a ->
parseChapters(client.newCall(GET(a.attr("abs:href"), headers)).execute().asJsoup())
}
}
parseChapters(response.asJsoup())
return chapters
}
override fun pageListRequest(chapter: SChapter): Request = GET(baseUrl + "${chapter.url}/all")
}