diff --git a/multisrc/overrides/fmreader/manhwa18/src/Manhwa18.kt b/multisrc/overrides/fmreader/manhwa18/src/Manhwa18.kt index ff1240838..10e07e5d2 100644 --- a/multisrc/overrides/fmreader/manhwa18/src/Manhwa18.kt +++ b/multisrc/overrides/fmreader/manhwa18/src/Manhwa18.kt @@ -2,16 +2,78 @@ package eu.kanade.tachiyomi.extension.en.manhwa18 import eu.kanade.tachiyomi.multisrc.fmreader.FMReader 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.Response +import org.jsoup.nodes.Document +import java.text.SimpleDateFormat +import java.util.Locale class Manhwa18 : FMReader("Manhwa18", "https://manhwa18.com", "en") { - override fun imageRequest(page: Page): Request { - return if (page.imageUrl!!.contains("manhwa18")) { - super.imageRequest(page) - } else { - GET(page.imageUrl!!, headers.newBuilder().removeAll("Referer").build()) + override val requestPath = "tim-kiem" + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { + val url = "$baseUrl/$requestPath?".toHttpUrlOrNull()!!.newBuilder() + .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 { + 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() } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt index 1e2a0b80c..51f45b9cf 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt @@ -19,7 +19,7 @@ class FMReaderGenerator : ThemeSourceGenerator { SingleLang("Epik Manga", "https://www.epikmanga.com", "tr"), SingleLang("KissLove", "https://kissaway.net", "ja"), 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), SingleLang("WeLoveManga", "https://weloma.net", "ja", pkgName = "rawlh", overrideVersionCode = 3), SingleLang("Say Truyen", "https://saytruyen.net", "vi", overrideVersionCode = 2),