From 47e328dc84e94e11ceaf9b0837b2f0069cdd90a4 Mon Sep 17 00:00:00 2001 From: beerpsi <92439990+beerpiss@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:57:04 +0700 Subject: [PATCH] Nekopost: Fix search (#1124) * Nekopost: Fix search * Bump version --- src/th/nekopost/build.gradle | 6 +++- .../extension/th/nekopost/Nekopost.kt | 30 +++++++++++-------- .../model/RawProjectSearchSummaryList.kt | 9 ++++++ .../th/nekopost/model/SearchRequest.kt | 9 ++++++ 4 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/RawProjectSearchSummaryList.kt create mode 100644 src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/SearchRequest.kt diff --git a/src/th/nekopost/build.gradle b/src/th/nekopost/build.gradle index 2868c8ed0..b3614e24f 100644 --- a/src/th/nekopost/build.gradle +++ b/src/th/nekopost/build.gradle @@ -1,8 +1,12 @@ ext { extName = 'Nekopost' extClass = '.Nekopost' - extVersionCode = 10 + extVersionCode = 11 isNsfw = true } apply from: "$rootDir/common.gradle" + +dependencies { + implementation(project(":lib:cryptoaes")) +} diff --git a/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt b/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt index b8bccf779..31c3b2841 100644 --- a/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt +++ b/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt @@ -2,8 +2,10 @@ package eu.kanade.tachiyomi.extension.th.nekopost import eu.kanade.tachiyomi.extension.th.nekopost.model.RawChapterInfo import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectInfo -import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectSearchSummary +import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectSearchSummaryList import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectSummaryList +import eu.kanade.tachiyomi.extension.th.nekopost.model.SearchRequest +import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.source.model.FilterList @@ -13,6 +15,7 @@ import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource import kotlinx.serialization.decodeFromString +import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import okhttp3.Headers import okhttp3.OkHttpClient @@ -25,7 +28,7 @@ import java.util.Locale class Nekopost : HttpSource() { private val json: Json by injectLazy() - override val baseUrl: String = "https://www.nekopost.net/manga/" + override val baseUrl: String = "https://www.nekopost.net/project" private val latestMangaEndpoint: String = "https://api.osemocphoto.com/frontAPI/getLatestChapter/m" private val projectDataEndpoint: String = "https://api.osemocphoto.com/frontAPI/getProjectInfo" @@ -172,24 +175,25 @@ class Nekopost : HttpSource() { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { val headers = Headers.headersOf("accept", "*/*", "content-type", "text/plain;charset=UTF-8", "origin", nekopostUrl) - val requestBody = "{\"keyword\":\"$query\"}".toRequestBody() + val requestBody = Json.encodeToString(SearchRequest(query, page)).toRequestBody() return POST("$nekopostUrl/api/explore/search", headers, requestBody) } override fun searchMangaParse(response: Response): MangasPage { val responseBody = response.body.string() + val decrypted = CryptoAES.decrypt(responseBody, "AeyTest") - val projectList: List = json.decodeFromString(responseBody) - val mangaList: List = projectList.filter { project -> - project.projectType == "m" - }.map { project -> - SManga.create().apply { - url = project.projectId.toString() - title = project.projectName - status = project.status - initialized = false + val projectList: RawProjectSearchSummaryList = json.decodeFromString(decrypted) + val mangaList: List = projectList.listProject + .filter { it.projectType == "m" } + .map { + SManga.create().apply { + url = it.projectId.toString() + title = it.projectName + status = it.status + thumbnail_url = "$fileHost/collectManga/${it.projectId}/${it.projectId}_cover.jpg?ver=${it.coverVersion}" + } } - } return MangasPage(mangaList, false) } diff --git a/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/RawProjectSearchSummaryList.kt b/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/RawProjectSearchSummaryList.kt new file mode 100644 index 000000000..dda6ef66d --- /dev/null +++ b/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/RawProjectSearchSummaryList.kt @@ -0,0 +1,9 @@ +package eu.kanade.tachiyomi.extension.th.nekopost.model + +import kotlinx.serialization.Serializable + +@Serializable +data class RawProjectSearchSummaryList( + val listProject: List, + val totalRecord: String, +) diff --git a/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/SearchRequest.kt b/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/SearchRequest.kt new file mode 100644 index 000000000..4584e4112 --- /dev/null +++ b/src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/model/SearchRequest.kt @@ -0,0 +1,9 @@ +package eu.kanade.tachiyomi.extension.th.nekopost.model + +import kotlinx.serialization.Serializable + +@Serializable +data class SearchRequest( + val keyword: String, + val pageNo: Int, +)