From c2b7c1cb20383c47e789cb04def89c47f3b76937 Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Sun, 3 Mar 2024 01:37:34 +0500 Subject: [PATCH] OppaiStream: update selectors (#1658) --- src/en/oppaistream/build.gradle | 2 +- .../extension/en/oppaistream/OppaiStream.kt | 32 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/en/oppaistream/build.gradle b/src/en/oppaistream/build.gradle index 27efcaccd..eff16da64 100644 --- a/src/en/oppaistream/build.gradle +++ b/src/en/oppaistream/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'Oppai Stream' extClass = '.OppaiStream' - extVersionCode = 1 + extVersionCode = 2 isNsfw = true } diff --git a/src/en/oppaistream/src/eu/kanade/tachiyomi/extension/en/oppaistream/OppaiStream.kt b/src/en/oppaistream/src/eu/kanade/tachiyomi/extension/en/oppaistream/OppaiStream.kt index e3fdafdba..f273d33f3 100644 --- a/src/en/oppaistream/src/eu/kanade/tachiyomi/extension/en/oppaistream/OppaiStream.kt +++ b/src/en/oppaistream/src/eu/kanade/tachiyomi/extension/en/oppaistream/OppaiStream.kt @@ -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:" } }