diff --git a/multisrc/overrides/fmreader/manhwa18net/src/Manhwa18NetFactory.kt b/multisrc/overrides/fmreader/manhwa18net/src/Manhwa18NetFactory.kt index e3e26a830..179b63e53 100644 --- a/multisrc/overrides/fmreader/manhwa18net/src/Manhwa18NetFactory.kt +++ b/multisrc/overrides/fmreader/manhwa18net/src/Manhwa18NetFactory.kt @@ -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 = 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(" - "), + ) + } + } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReader.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReader.kt index 3873d626f..dfb96dc11 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReader.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReader.kt @@ -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" 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 6ff5091f9..46d824c50 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 @@ -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),