Fix henchan.pro single chapters mangas (#4258)

Co-authored-by: pavkazzz <me@pavkazzz.ru>
This commit is contained in:
Pavka 2020-08-30 21:14:17 +03:00 committed by GitHub
parent 29c3798c2a
commit e51b2a7b3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Henchan'
pkgNameSuffix = 'ru.henchan'
extClass = '.Henchan'
extVersionCode = 17
extVersionCode = 18
libVersion = '1.2'
containsNsfw = true
}

View File

@ -10,6 +10,7 @@ import com.google.gson.JsonObject
import eu.kanade.tachiyomi.annotations.Nsfw
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservable
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page
@ -27,6 +28,7 @@ import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import rx.Observable
@Nsfw
class Henchan : ParsedHttpSource() {
@ -140,6 +142,26 @@ class Henchan : ParsedHttpSource() {
return manga
}
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
return client.newCall(chapterListRequest(manga))
.asObservable().doOnNext { response ->
if (!response.isSuccessful) {
response.close()
// Error message for exceeding last page
if (response.code() == 404)
Observable.just(listOf(SChapter.create().apply {
url = manga.url
name = "Chapter"
chapter_number = 1f
}))
else throw Exception("HTTP error ${response.code()}")
}
}
.map { response ->
chapterListParse(response)
}
}
override fun chapterListRequest(manga: SManga): Request {
val url = baseUrl + if (manga.thumbnail_url?.endsWith("#") == true) {
manga.url