update FMReader (#5016)

* remove ReadComicOnlineOrg

* add HeroScan

* fix manga description

showing wrong thing for some site
This commit is contained in:
Riztard Lanthorn 2020-12-05 00:14:31 +07:00 committed by GitHub
parent 8f606df520
commit 75cb78ddcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 40 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'FMReader (multiple aggregators)'
pkgNameSuffix = 'all.fmreader'
extClass = '.FMReaderFactory'
extVersionCode = 21
extVersionCode = 22
libVersion = '1.2'
containsNsfw = true
}

View File

@ -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()
}
}

View File

@ -25,7 +25,6 @@ class FMReaderFactory : SourceFactory {
override fun createSources(): List<Source> = 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<Page> = 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<Page> {
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<Page> = base64PageListParse(document)