2021-02-10 14:05:12 +00:00
|
|
|
package eu.kanade.tachiyomi.extension.en.toonily
|
|
|
|
|
2021-08-22 15:29:08 +00:00
|
|
|
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
2023-04-25 17:20:09 +00:00
|
|
|
import eu.kanade.tachiyomi.network.GET
|
|
|
|
import eu.kanade.tachiyomi.source.model.FilterList
|
|
|
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
|
|
|
import okhttp3.OkHttpClient
|
|
|
|
import okhttp3.Request
|
2022-02-22 12:37:18 +00:00
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.util.Locale
|
2021-02-10 14:05:12 +00:00
|
|
|
|
2023-04-25 17:20:09 +00:00
|
|
|
private const val domain = "toonily.com"
|
2022-04-07 16:38:03 +00:00
|
|
|
class Toonily : Madara(
|
|
|
|
"Toonily",
|
2023-04-25 17:20:09 +00:00
|
|
|
"https://$domain",
|
2022-04-07 16:38:03 +00:00
|
|
|
"en",
|
2023-02-11 19:21:03 +00:00
|
|
|
SimpleDateFormat("MMM d, yy", Locale.US),
|
2022-04-07 16:38:03 +00:00
|
|
|
) {
|
|
|
|
|
2023-04-25 17:20:09 +00:00
|
|
|
private val cookieInterceptor = CookieInterceptor(domain, "toonily-mature", "1")
|
|
|
|
override val client: OkHttpClient = super.client.newBuilder()
|
|
|
|
.addNetworkInterceptor(cookieInterceptor)
|
|
|
|
.build()
|
|
|
|
|
2023-05-03 18:30:32 +00:00
|
|
|
override val mangaSubString = "webtoon"
|
2023-04-25 17:20:09 +00:00
|
|
|
|
|
|
|
override fun searchPage(page: Int): String {
|
|
|
|
return if (page > 1) {
|
|
|
|
"page/$page/"
|
|
|
|
} else {
|
|
|
|
""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun searchPage(page: Int, query: String): String {
|
|
|
|
val urlQuery = query.trim()
|
|
|
|
.lowercase(Locale.US)
|
|
|
|
.replace(titleSpecialCharactersRegex, "-")
|
|
|
|
.replace(trailingHyphenRegex, "")
|
|
|
|
.let { if (it.isNotEmpty()) "$it/" else it }
|
|
|
|
return if (page > 1) {
|
|
|
|
"search/${urlQuery}page/$page/"
|
|
|
|
} else {
|
|
|
|
"search/$urlQuery"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
|
|
|
val request = super.searchMangaRequest(page, query, filters)
|
|
|
|
|
|
|
|
val queries = request.url.queryParameterNames
|
|
|
|
.filterNot { it == "s" }
|
|
|
|
|
|
|
|
val newUrl = "$baseUrl/${searchPage(page, query)}".toHttpUrlOrNull()!!.newBuilder().apply {
|
|
|
|
queries.map { q ->
|
|
|
|
request.url.queryParameterValues(q).map {
|
|
|
|
this.addQueryParameter(q, it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.build()
|
|
|
|
|
|
|
|
return request.newBuilder()
|
|
|
|
.url(newUrl)
|
|
|
|
.build()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun genresRequest(): Request {
|
|
|
|
return GET("$baseUrl/search/?post_type=wp-manga", headers)
|
|
|
|
}
|
|
|
|
|
2022-04-07 16:38:03 +00:00
|
|
|
// The source customized the Madara theme and broke the filter.
|
|
|
|
override val filterNonMangaItems = false
|
|
|
|
|
2021-09-18 03:18:58 +00:00
|
|
|
override val useNewChapterEndpoint: Boolean = true
|
2022-05-09 21:13:23 +00:00
|
|
|
|
2022-08-23 12:56:32 +00:00
|
|
|
override fun searchMangaSelector() = "div.page-item-detail.manga"
|
|
|
|
|
2023-03-24 02:31:02 +00:00
|
|
|
override val pageListParseSelector = "div.reading-content div"
|
|
|
|
|
2022-05-09 21:13:23 +00:00
|
|
|
override fun parseChapterDate(date: String?): Long {
|
|
|
|
val formattedDate = if (date?.contains("UP") == true) "today" else date
|
|
|
|
return super.parseChapterDate(formattedDate)
|
|
|
|
}
|
2023-04-25 17:20:09 +00:00
|
|
|
|
|
|
|
companion object {
|
|
|
|
val titleSpecialCharactersRegex = "[^a-z0-9]+".toRegex()
|
|
|
|
val trailingHyphenRegex = "-+$".toRegex()
|
|
|
|
}
|
2021-02-10 14:05:12 +00:00
|
|
|
}
|