From e51b2a7b3a8236c992d2dbc623e486eaf835fd4d Mon Sep 17 00:00:00 2001 From: Pavka Date: Sun, 30 Aug 2020 21:14:17 +0300 Subject: [PATCH] Fix henchan.pro single chapters mangas (#4258) Co-authored-by: pavkazzz --- src/ru/henchan/build.gradle | 2 +- .../tachiyomi/extension/ru/henchan/Henchan.kt | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ru/henchan/build.gradle b/src/ru/henchan/build.gradle index 1afa97e94..51bfb7da0 100644 --- a/src/ru/henchan/build.gradle +++ b/src/ru/henchan/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Henchan' pkgNameSuffix = 'ru.henchan' extClass = '.Henchan' - extVersionCode = 17 + extVersionCode = 18 libVersion = '1.2' containsNsfw = true } diff --git a/src/ru/henchan/src/eu/kanade/tachiyomi/extension/ru/henchan/Henchan.kt b/src/ru/henchan/src/eu/kanade/tachiyomi/extension/ru/henchan/Henchan.kt index 31e2ceca1..6f9947dc8 100644 --- a/src/ru/henchan/src/eu/kanade/tachiyomi/extension/ru/henchan/Henchan.kt +++ b/src/ru/henchan/src/eu/kanade/tachiyomi/extension/ru/henchan/Henchan.kt @@ -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> { + 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