nekopost: fix webview urls (#4456)

This commit is contained in:
AwkwardPeak7 2024-08-07 08:43:21 +05:00 committed by Draff
parent 5fca0cb71f
commit fdcae35d12
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 11 additions and 7 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'Nekopost' extName = 'Nekopost'
extClass = '.Nekopost' extClass = '.Nekopost'
extVersionCode = 11 extVersionCode = 12
isNsfw = true isNsfw = true
} }

View File

@ -28,17 +28,16 @@ import java.util.Locale
class Nekopost : HttpSource() { class Nekopost : HttpSource() {
private val json: Json by injectLazy() private val json: Json by injectLazy()
override val baseUrl: String = "https://www.nekopost.net/project" override val baseUrl: String = "https://www.nekopost.net"
private val latestMangaEndpoint: String = "https://api.osemocphoto.com/frontAPI/getLatestChapter/m" private val latestMangaEndpoint: String = "https://api.osemocphoto.com/frontAPI/getLatestChapter/m"
private val projectDataEndpoint: String = "https://api.osemocphoto.com/frontAPI/getProjectInfo" private val projectDataEndpoint: String = "https://api.osemocphoto.com/frontAPI/getProjectInfo"
private val fileHost: String = "https://www.osemocphoto.com" private val fileHost: String = "https://www.osemocphoto.com"
private val nekopostUrl = "https://www.nekopost.net"
override val client: OkHttpClient = network.cloudflareClient override val client: OkHttpClient = network.cloudflareClient
override fun headersBuilder(): Headers.Builder { override fun headersBuilder(): Headers.Builder {
return super.headersBuilder().add("Referer", baseUrl) return super.headersBuilder().add("Referer", "$baseUrl/")
} }
private val existingProject: HashSet<String> = HashSet() private val existingProject: HashSet<String> = HashSet()
@ -69,6 +68,8 @@ class Nekopost : HttpSource() {
return GET("$projectDataEndpoint/${manga.url}", headers) return GET("$projectDataEndpoint/${manga.url}", headers)
} }
override fun getMangaUrl(manga: SManga) = "$baseUrl/manga/${manga.url}"
override fun mangaDetailsParse(response: Response): SManga { override fun mangaDetailsParse(response: Response): SManga {
val responseBody = response.body val responseBody = response.body
val projectInfo: RawProjectInfo = json.decodeFromString(responseBody.string()) val projectInfo: RawProjectInfo = json.decodeFromString(responseBody.string())
@ -95,7 +96,7 @@ class Nekopost : HttpSource() {
} }
override fun chapterListRequest(manga: SManga): Request { override fun chapterListRequest(manga: SManga): Request {
val headers = Headers.headersOf("accept", "*/*", "content-type", "text/plain;charset=UTF-8", "origin", nekopostUrl) val headers = Headers.headersOf("accept", "*/*", "content-type", "text/plain;charset=UTF-8", "origin", baseUrl)
return GET("$projectDataEndpoint/${manga.url}", headers) return GET("$projectDataEndpoint/${manga.url}", headers)
} }
@ -127,6 +128,9 @@ class Nekopost : HttpSource() {
return GET("$fileHost/collectManga/${chapter.url}", headers) return GET("$fileHost/collectManga/${chapter.url}", headers)
} }
override fun getChapterUrl(chapter: SChapter) =
"$baseUrl/manga/${chapter.url.substringBefore("/")}/${chapter.chapter_number.toString().removeSuffix(".0")}"
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response): List<Page> {
val responseBody = response.body val responseBody = response.body
val chapterInfo: RawChapterInfo = json.decodeFromString(responseBody.string()) val chapterInfo: RawChapterInfo = json.decodeFromString(responseBody.string())
@ -174,9 +178,9 @@ class Nekopost : HttpSource() {
} }
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { 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 headers = Headers.headersOf("accept", "*/*", "content-type", "text/plain;charset=UTF-8", "origin", baseUrl)
val requestBody = Json.encodeToString(SearchRequest(query, page)).toRequestBody() val requestBody = Json.encodeToString(SearchRequest(query, page)).toRequestBody()
return POST("$nekopostUrl/api/explore/search", headers, requestBody) return POST("$baseUrl/api/explore/search", headers, requestBody)
} }
override fun searchMangaParse(response: Response): MangasPage { override fun searchMangaParse(response: Response): MangasPage {