Update extension for changes on Manhwa18 website (#10365)

This commit is contained in:
Vetle Ledaal 2022-01-06 10:54:03 +00:00 committed by GitHub
parent 05addfb95e
commit 1dfb6b491e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 8 deletions

View File

@ -2,16 +2,78 @@ package eu.kanade.tachiyomi.extension.en.manhwa18
import eu.kanade.tachiyomi.multisrc.fmreader.FMReader import eu.kanade.tachiyomi.multisrc.fmreader.FMReader
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.Request import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import java.text.SimpleDateFormat
import java.util.Locale
class Manhwa18 : FMReader("Manhwa18", "https://manhwa18.com", "en") { class Manhwa18 : FMReader("Manhwa18", "https://manhwa18.com", "en") {
override fun imageRequest(page: Page): Request { override val requestPath = "tim-kiem"
return if (page.imageUrl!!.contains("manhwa18")) {
super.imageRequest(page) override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
} else { val url = "$baseUrl/$requestPath?".toHttpUrlOrNull()!!.newBuilder()
GET(page.imageUrl!!, headers.newBuilder().removeAll("Referer").build()) .addQueryParameter("q", query)
.addQueryParameter("page", page.toString())
return GET(url.toString(), headers)
}
override fun latestUpdatesRequest(page: Int): Request =
GET("$baseUrl/$requestPath?listType=pagination&page=$page&sort=new&sort_type=DESC", headers)
override fun mangaDetailsParse(document: Document): SManga {
return SManga.create().apply {
title = document.select(".series-name").text()
thumbnail_url = document.select("meta[property='og:image']").attr("abs:content")
document.select(".series-information")?.let { info ->
author = info.select(".info-name:contains(Author:) + .info-value").text()
genre = info.select(".info-name:contains(Genre:) + .info-value > a")
.joinToString { it.text().trim() }
description = document.select(".summary-content").text().trim()
info.select(".info-name:contains(Other name:) + .info-value")
.firstOrNull()?.text()?.let {
val altName = removeGenericWords(it)
description = when (title.toLowerCase(Locale.US)) {
altName.toLowerCase(Locale.US) -> description
else -> description + "\n\n$altName"
}
}
status =
parseStatus(info.select(".info-name:contains(Status:) + .info-value").text())
}
} }
} }
override fun getGenreList() = getAdultGenreList()
private fun removeGenericWords(name: String): String {
val excludeList = listOf("manhwa", "engsub")
return name.split(' ').filterNot { word ->
word.toLowerCase(Locale.US) in excludeList
}.joinToString(" ")
}
override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup()
return document.select(".list-chapters > a").map { element ->
SChapter.create().apply {
setUrlWithoutDomain(element.attr("abs:href"))
name = element.attr("title")
date_upload =
SimpleDateFormat("dd/MM/yyyy", Locale.US).parse(
element.select(".chapter-time").text().substringAfter(" - ")
)?.time ?: 0L
chapter_number = element.attr("time").substringAfterLast(' ').toFloatOrNull() ?: -1f
}
}
}
override val pageListImageSelector = "#chapter-content > img"
override fun getFilterList() = FilterList()
} }

View File

@ -19,7 +19,7 @@ class FMReaderGenerator : ThemeSourceGenerator {
SingleLang("Epik Manga", "https://www.epikmanga.com", "tr"), SingleLang("Epik Manga", "https://www.epikmanga.com", "tr"),
SingleLang("KissLove", "https://kissaway.net", "ja"), SingleLang("KissLove", "https://kissaway.net", "ja"),
SingleLang("Manga-TR", "https://manga-tr.com", "tr", className = "MangaTR"), SingleLang("Manga-TR", "https://manga-tr.com", "tr", className = "MangaTR"),
SingleLang("Manhwa18", "https://manhwa18.com", "en", isNsfw = true), SingleLang("Manhwa18", "https://manhwa18.com", "en", isNsfw = true, overrideVersionCode = 1),
MultiLang("Manhwa18.net", "https://manhwa18.net", listOf("en", "ko"), className = "Manhwa18NetFactory", isNsfw = true), MultiLang("Manhwa18.net", "https://manhwa18.net", listOf("en", "ko"), className = "Manhwa18NetFactory", isNsfw = true),
SingleLang("WeLoveManga", "https://weloma.net", "ja", pkgName = "rawlh", overrideVersionCode = 3), SingleLang("WeLoveManga", "https://weloma.net", "ja", pkgName = "rawlh", overrideVersionCode = 3),
SingleLang("Say Truyen", "https://saytruyen.net", "vi", overrideVersionCode = 2), SingleLang("Say Truyen", "https://saytruyen.net", "vi", overrideVersionCode = 2),