Update Manhwa18net layout (#18040)
* Update Manhwa18net layout * Make SimpleDateFormat a constant * Move/rename date parser functions to/in Constructor * Add missing Imports Reformat
This commit is contained in:
parent
63e02aabe1
commit
de5d0be524
|
@ -5,7 +5,9 @@ import eu.kanade.tachiyomi.network.GET
|
|||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import okhttp3.Request
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
class Manhwa18NetFactory : SourceFactory {
|
||||
override fun createSources(): List<Source> = listOf(
|
||||
|
@ -15,26 +17,61 @@ class Manhwa18NetFactory : SourceFactory {
|
|||
}
|
||||
|
||||
class Manhwa18Net : FMReader("Manhwa18.net", "https://manhwa18.net", "en") {
|
||||
override fun popularMangaRequest(page: Int): Request =
|
||||
GET("$baseUrl/$requestPath?listType=pagination&page=$page&sort=views&sort_type=DESC&ungenre=raw", headers)
|
||||
override val requestPath = "genre/manhwa"
|
||||
override val popularSort = "sort=top"
|
||||
override val pageListImageSelector = "div#chapter-content > img"
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request =
|
||||
GET("$baseUrl/$requestPath?listType=pagination&page=$page&sort=last_update&sort_type=DESC&ungenre=raw", headers)
|
||||
GET(
|
||||
"$baseUrl/$requestPath?listType=pagination&page=$page&sort=update&sort_type=DESC",
|
||||
headers,
|
||||
)
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val noRawsUrl = super.searchMangaRequest(page, query, filters).url.newBuilder().addQueryParameter("ungenre", "raw").toString()
|
||||
val noRawsUrl = super.searchMangaRequest(page, query, filters).url.newBuilder().toString()
|
||||
return GET(noRawsUrl, headers)
|
||||
}
|
||||
|
||||
override fun getGenreList() = getAdultGenreList()
|
||||
|
||||
override fun chapterFromElement(element: Element, mangaTitle: String): SChapter {
|
||||
return SChapter.create().apply {
|
||||
setUrlWithoutDomain(element.attr("abs:href"))
|
||||
name = element.attr("title")
|
||||
date_upload = parseAbsoluteDate(
|
||||
element.select(chapterTimeSelector).text().substringAfter(" - "),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Manhwa18NetRaw : FMReader("Manhwa18.net", "https://manhwa18.net", "ko") {
|
||||
override val requestPath = "manga-list-genre-raw.html"
|
||||
override val requestPath = "genre/raw"
|
||||
override val popularSort = "sort=top"
|
||||
override val pageListImageSelector = "div#chapter-content > img"
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request =
|
||||
GET(
|
||||
"$baseUrl/$requestPath?listType=pagination&page=$page&sort=update&sort_type=DESC",
|
||||
headers,
|
||||
)
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val onlyRawsUrl = super.searchMangaRequest(page, query, filters).url.newBuilder().addQueryParameter("genre", "raw").toString()
|
||||
val onlyRawsUrl = super.searchMangaRequest(page, query, filters).url.newBuilder().toString()
|
||||
return GET(onlyRawsUrl, headers)
|
||||
}
|
||||
|
||||
override fun getFilterList() = FilterList(super.getFilterList().filterNot { it == GenreList(getGenreList()) })
|
||||
override fun getFilterList() = FilterList(
|
||||
super.getFilterList().filterNot { it == GenreList(getGenreList()) },
|
||||
)
|
||||
|
||||
override fun chapterFromElement(element: Element, mangaTitle: String): SChapter {
|
||||
return SChapter.create().apply {
|
||||
setUrlWithoutDomain(element.attr("abs:href"))
|
||||
name = element.attr("title")
|
||||
date_upload = parseAbsoluteDate(
|
||||
element.select(chapterTimeSelector).text().substringAfter(" - "),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ import org.jsoup.nodes.Document
|
|||
import org.jsoup.nodes.Element
|
||||
import org.jsoup.select.Elements
|
||||
import java.nio.charset.Charset
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* For sites based on the Flat-Manga CMS
|
||||
*/
|
||||
|
@ -27,6 +30,7 @@ abstract class FMReader(
|
|||
override val name: String,
|
||||
override val baseUrl: String,
|
||||
override val lang: String,
|
||||
private val dateFormat: SimpleDateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH),
|
||||
) : ParsedHttpSource() {
|
||||
|
||||
override val supportsLatest = true
|
||||
|
@ -237,7 +241,7 @@ abstract class FMReader(
|
|||
name = element.attr(chapterNameAttrSelector).substringAfter("$mangaTitle ")
|
||||
}
|
||||
}
|
||||
date_upload = element.select(chapterTimeSelector).let { if (it.hasText()) parseChapterDate(it.text()) else 0 }
|
||||
date_upload = element.select(chapterTimeSelector).let { if (it.hasText()) parseRelativeDate(it.text()) else 0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +251,7 @@ abstract class FMReader(
|
|||
// gets the unit of time (day, week hour) from "1 day ago"
|
||||
open val dateWordIndex = 1
|
||||
|
||||
private fun parseChapterDate(date: String): Long {
|
||||
private fun parseRelativeDate(date: String): Long {
|
||||
val value = date.split(' ')[dateValueIndex].toInt()
|
||||
val dateWord = date.split(' ')[dateWordIndex].let {
|
||||
if (it.contains("(")) {
|
||||
|
@ -294,6 +298,10 @@ abstract class FMReader(
|
|||
}
|
||||
}
|
||||
}
|
||||
open fun parseAbsoluteDate(dateStr: String): Long {
|
||||
return runCatching { dateFormat.parse(dateStr)?.time }
|
||||
.getOrNull() ?: 0L
|
||||
}
|
||||
|
||||
open val pageListImageSelector = "img.chapter-img"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class FMReaderGenerator : ThemeSourceGenerator {
|
|||
override val baseVersionCode: Int = 8
|
||||
|
||||
override val sources = listOf(
|
||||
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, overrideVersionCode = 1),
|
||||
SingleLang("Epik Manga", "https://www.epikmanga.com", "tr"),
|
||||
SingleLang("KissLove", "https://klz9.com", "ja", isNsfw = true, overrideVersionCode = 4),
|
||||
SingleLang("Manga-TR", "https://manga-tr.com", "tr", className = "MangaTR", overrideVersionCode = 1),
|
||||
|
|
Loading…
Reference in New Issue