OppaiStream: update selectors (#1658)

This commit is contained in:
AwkwardPeak7 2024-03-03 01:37:34 +05:00 committed by Draff
parent feef718f2a
commit c2b7c1cb20
2 changed files with 16 additions and 18 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Oppai Stream'
extClass = '.OppaiStream'
extVersionCode = 1
extVersionCode = 2
isNsfw = true
}

View File

@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
@ -31,10 +30,10 @@ class OppaiStream : ParsedHttpSource() {
override val supportsLatest = true
override val client: OkHttpClient = network.cloudflareClient
override val client = network.cloudflareClient
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
.add("Referer", baseUrl)
.add("Referer", "$baseUrl/")
// popular
override fun popularMangaRequest(page: Int): Request {
@ -84,22 +83,20 @@ class OppaiStream : ParsedHttpSource() {
addQueryParameter("order", filter.selectedValue())
}
is GenreListFilter -> {
val genresInclude = filter.state.filter { it.state == Filter.TriState.STATE_INCLUDE }.map { genre -> genre.value }
val genresExclude = filter.state.filter { it.state == Filter.TriState.STATE_EXCLUDE }.map { genre -> genre.value }
addQueryParameter("genres", genresInclude.joinToString(",") { it })
addQueryParameter("blacklist", genresExclude.joinToString(",") { it })
addQueryParameter("genres", filter.state.filter { it.isIncluded() }.joinToString(",") { it.value })
addQueryParameter("blacklist", filter.state.filter { it.isExcluded() }.joinToString(",") { it.value })
}
else -> {}
}
}
addQueryParameter("page", "$page")
addQueryParameter("limit", "$searchLimit")
addQueryParameter("limit", "$SEARCH_LIMIT")
}.build()
return GET(url, headers)
}
override fun searchMangaSelector() = "div.in-grid"
override fun searchMangaSelector() = "div.in-grid > a"
override fun searchMangaParse(response: Response): MangasPage {
val document = response.asJsoup()
@ -109,16 +106,16 @@ class OppaiStream : ParsedHttpSource() {
searchMangaFromElement(element)
}
val hasNextPage = elements.size >= searchLimit
val hasNextPage = elements.size >= SEARCH_LIMIT
return MangasPage(mangas, hasNextPage)
}
override fun searchMangaFromElement(element: Element): SManga {
return SManga.create().apply {
thumbnail_url = element.select(".split-1 img").attr("src")
title = element.select("a div h3").text()
setUrlWithoutDomain(element.select("a").attr("href"))
thumbnail_url = element.select("img.read-cover").attr("src")
title = element.select("h3.man-title").text()
setUrlWithoutDomain(element.absUrl("href"))
}
}
@ -129,9 +126,9 @@ class OppaiStream : ParsedHttpSource() {
return SManga.create().apply {
thumbnail_url = document.select(".cover-img").attr("src")
document.select(".manhwa-info-in").let { it ->
it.select("h1").text().let {
title = it.substringBeforeLast("By").trim()
author = it.substringAfterLast("By").trim()
it.select("h1").run {
title = text().substringBeforeLast("By").trim()
author = select("a.red").text().trim()
artist = author
}
genre = it.select(".genres h5").joinToString { it.text() }
@ -186,6 +183,7 @@ class OppaiStream : ParsedHttpSource() {
private class OrderByFilter(defaultOrder: String? = null) : SelectFilter(
"Sort By",
arrayOf(
Pair("", ""),
Pair("A-Z", "az"),
Pair("Z-A", "za"),
Pair("Recently Released", "recent"),
@ -334,7 +332,7 @@ class OppaiStream : ParsedHttpSource() {
}
companion object {
const val searchLimit = 36
const val SEARCH_LIMIT = 36
const val SLUG_SEARCH_PREFIX = "slug:"
}
}