Fix Nekopost HTTP error 520 (#13027)
* Fix Nekopost https 520 error * Fix Nekopost https 520 error * Update src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update src/th/nekopost/src/eu/kanade/tachiyomi/extension/th/nekopost/Nekopost.kt Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> * Update Nekopost.kt * Fix Nekopost sometimes return empty mangas list due to API Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
parent
a5113107ff
commit
d47b7684ce
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Nekopost'
|
extName = 'Nekopost'
|
||||||
pkgNameSuffix = 'th.nekopost'
|
pkgNameSuffix = 'th.nekopost'
|
||||||
extClass = '.Nekopost'
|
extClass = '.Nekopost'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ class Nekopost : ParsedHttpSource() {
|
||||||
|
|
||||||
private val existingProject: HashSet<String> = HashSet()
|
private val existingProject: HashSet<String> = HashSet()
|
||||||
|
|
||||||
|
private var firstPageNulled: Boolean = false
|
||||||
|
|
||||||
override val lang: String = "th"
|
override val lang: String = "th"
|
||||||
override val name: String = "Nekopost"
|
override val name: String = "Nekopost"
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ class Nekopost : ParsedHttpSource() {
|
||||||
override fun mangaDetailsParse(document: Document): SManga = throw NotImplementedError("Unused")
|
override fun mangaDetailsParse(document: Document): SManga = throw NotImplementedError("Unused")
|
||||||
|
|
||||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||||
return client.newCall(GET("$projectDataEndpoint/${manga.url}"))
|
return client.newCall(GET("$projectDataEndpoint/${manga.url}", headers))
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
val responseBody =
|
val responseBody =
|
||||||
|
@ -93,6 +95,8 @@ class Nekopost : ParsedHttpSource() {
|
||||||
author = it.authorName
|
author = it.authorName
|
||||||
description = it.info
|
description = it.info
|
||||||
status = getStatus(it.status)
|
status = getStatus(it.status)
|
||||||
|
thumbnail_url =
|
||||||
|
"$fileHost/collectManga/${it.projectId}/${it.projectId}_cover.jpg"
|
||||||
initialized = true
|
initialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +111,7 @@ class Nekopost : ParsedHttpSource() {
|
||||||
|
|
||||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||||
return if (manga.status != SManga.LICENSED) {
|
return if (manga.status != SManga.LICENSED) {
|
||||||
client.newCall(GET("$projectDataEndpoint/${manga.url}"))
|
client.newCall(GET("$projectDataEndpoint/${manga.url}", headers))
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
val responseBody =
|
val responseBody =
|
||||||
|
@ -142,7 +146,7 @@ class Nekopost : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
||||||
return client.newCall(GET("$fileHost/collectManga/${chapter.url}"))
|
return client.newCall(GET("$fileHost/collectManga/${chapter.url}", headers))
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
val responseBody =
|
val responseBody =
|
||||||
|
@ -168,18 +172,18 @@ class Nekopost : ParsedHttpSource() {
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
if (page <= 1) existingProject.clear()
|
if (page <= 1) existingProject.clear()
|
||||||
|
//API has a bug that sometime it returns null on first page
|
||||||
return GET("$latestMangaEndpoint/$page")
|
return GET("$latestMangaEndpoint/${if (firstPageNulled) page else page - 1 }", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response): MangasPage {
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
val responseBody = response.body ?: throw Error("Unable to fetch mangas")
|
val responseBody = response.body ?: throw Error("Unable to fetch mangas")
|
||||||
val projectList: RawProjectSummaryList = json.decodeFromString(responseBody.string())
|
val projectList: RawProjectSummaryList = json.decodeFromString(responseBody.string())
|
||||||
|
|
||||||
val mangaList: List<SManga> =
|
val mangaList: List<SManga> = if (projectList.listChapter != null) {
|
||||||
projectList.listChapter
|
projectList.listChapter
|
||||||
?.filter { !existingProject.contains(it.projectId) }
|
.filter { !existingProject.contains(it.projectId) }
|
||||||
?.map {
|
.map {
|
||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
url = it.projectId
|
url = it.projectId
|
||||||
title = it.projectName
|
title = it.projectName
|
||||||
|
@ -188,7 +192,11 @@ class Nekopost : ParsedHttpSource() {
|
||||||
initialized = false
|
initialized = false
|
||||||
status = 0
|
status = 0
|
||||||
}
|
}
|
||||||
} ?: return MangasPage(emptyList(), hasNextPage = false)
|
}
|
||||||
|
} else {
|
||||||
|
firstPageNulled = true //API has a bug that sometime it returns null on first page
|
||||||
|
return MangasPage(emptyList(), hasNextPage = false)
|
||||||
|
}
|
||||||
|
|
||||||
mangaList.forEach { existingProject.add(it.url) }
|
mangaList.forEach { existingProject.add(it.url) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue