From 75cb78ddcc8961a34c375039e2fb67858cbb10c0 Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Sat, 5 Dec 2020 00:14:31 +0700 Subject: [PATCH] update FMReader (#5016) * remove ReadComicOnlineOrg * add HeroScan * fix manga description showing wrong thing for some site --- src/all/fmreader/build.gradle | 2 +- .../extension/all/fmreader/FMReader.kt | 2 +- .../extension/all/fmreader/FMReaderFactory.kt | 56 ++++++------------- 3 files changed, 20 insertions(+), 40 deletions(-) diff --git a/src/all/fmreader/build.gradle b/src/all/fmreader/build.gradle index f95a7aada..9595006bc 100644 --- a/src/all/fmreader/build.gradle +++ b/src/all/fmreader/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'FMReader (multiple aggregators)' pkgNameSuffix = 'all.fmreader' extClass = '.FMReaderFactory' - extVersionCode = 21 + extVersionCode = 22 libVersion = '1.2' containsNsfw = true } diff --git a/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReader.kt b/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReader.kt index 25f9d87a0..75bf98db6 100644 --- a/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReader.kt +++ b/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReader.kt @@ -161,7 +161,7 @@ abstract class FMReader( author = infoElement.select("li a.btn-info").text() genre = infoElement.select("li a.btn-danger").joinToString { it.text() } status = parseStatus(infoElement.select("li a.btn-success").first()?.text()) - description = document.select("div.row ~ div.row p").text().trim() + description = document.select("div.detail .content, div.row ~ div.row:has(h3:first-child) p").text().trim() thumbnail_url = infoElement.select("img.thumbnail").imgAttr() } } diff --git a/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReaderFactory.kt b/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReaderFactory.kt index 586d14dbb..c7bf4923f 100644 --- a/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReaderFactory.kt +++ b/src/all/fmreader/src/eu/kanade/tachiyomi/extension/all/fmreader/FMReaderFactory.kt @@ -25,7 +25,6 @@ class FMReaderFactory : SourceFactory { override fun createSources(): List = listOf( LHTranslation(), KissLove(), - ReadComicOnlineOrg(), HanaScan(), RawLH(), Manhwa18(), @@ -36,7 +35,8 @@ class FMReaderFactory : SourceFactory { SayTruyen(), EpikManga(), ManhuaScan(), - ManhwaSmut() + ManhwaSmut(), + HeroScan() ) } @@ -49,48 +49,28 @@ class KissLove : FMReader("KissLove", "https://kisslove.net", "ja") { override fun pageListParse(document: Document): List = base64PageListParse(document) } -class ReadComicOnlineOrg : FMReader("ReadComicOnline.org", "https://readcomiconline.org", "en") { - override val client: OkHttpClient = network.cloudflareClient.newBuilder() - .addInterceptor { requestIntercept(it) } - .build() - - private fun requestIntercept(chain: Interceptor.Chain): Response { - val request = chain.request() - val response = chain.proceed(request) - - return if (response.headers("set-cookie").isNotEmpty()) { - val body = FormBody.Builder() - .add("dqh_firewall", URLEncoder.encode(request.url().toString().substringAfter(baseUrl), "utf-8")) - .build() - val cookie = response.headers("set-cookie")[0].split(" ") - .filter { it.contains("__cfduid") || it.contains("PHPSESSID") } - .joinToString("; ") { it.substringBefore(";") } - headers.newBuilder().add("Cookie", cookie).build() - client.newCall(POST(request.url().toString(), headers, body)).execute() - } else { - response - } - } - - override val requestPath = "comic-list.html" - override fun pageListParse(document: Document): List { - val pages = document.select("div#divImage > select:first-of-type option").mapIndexed { i, imgPage -> - Page(i, imgPage.attr("value")) - } - return pages.dropLast(1) // last page is a comments page - } - - override fun imageUrlRequest(page: Page): Request = GET(baseUrl + page.url, headers) - override fun imageUrlParse(document: Document): String = document.select("img.chapter-img").attr("abs:src").trim() - override fun getGenreList() = getComicsGenreList() -} - class HanaScan : FMReader("HanaScan (RawQQ)", "https://hanascan.com", "ja") { override fun popularMangaNextPageSelector() = "div.col-md-8 button" // Referer needs to be chapter URL override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().set("Referer", page.url).build()) } +class HeroScan : FMReader("HeroScan", "https://heroscan.com", "en") { + override val client: OkHttpClient = super.client.newBuilder() + .addInterceptor { chain -> + val originalRequest = chain.request() + chain.proceed(originalRequest).let { response -> + if (response.code() == 403 && originalRequest.url().host().contains("b-cdn")) { + response.close() + chain.proceed(originalRequest.newBuilder().removeHeader("Referer").addHeader("Referer", "https://isekaiscan.com").build()) + } else { + response + } + } + } + .build() +} + class RawLH : FMReader("RawLH", "https://loveheaven.net", "ja") { override fun popularMangaNextPageSelector() = "div.col-md-8 button" override fun pageListParse(document: Document): List = base64PageListParse(document)