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 { ext {
extName = 'Oppai Stream' extName = 'Oppai Stream'
extClass = '.OppaiStream' extClass = '.OppaiStream'
extVersionCode = 1 extVersionCode = 2
isNsfw = true isNsfw = true
} }

View File

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