Initial commit
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
multisrc/overrides/madara/toonily/res/web_hi_res_512.png
Normal file
BIN
multisrc/overrides/madara/toonily/res/web_hi_res_512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
46
multisrc/overrides/madara/toonily/src/CookieInterceptor.kt
Normal file
46
multisrc/overrides/madara/toonily/src/CookieInterceptor.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
package eu.kanade.tachiyomi.extension.en.toonily
|
||||
|
||||
import android.util.Log
|
||||
import android.webkit.CookieManager
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
|
||||
class CookieInterceptor(
|
||||
private val domain: String,
|
||||
private val key: String,
|
||||
private val value: String,
|
||||
) : Interceptor {
|
||||
|
||||
init {
|
||||
val url = "https://$domain/"
|
||||
val cookie = "$key=$value; Domain=$domain; Path=/"
|
||||
setCookie(url, cookie)
|
||||
}
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
if (!request.url.host.endsWith(domain)) return chain.proceed(request)
|
||||
|
||||
val cookie = "$key=$value"
|
||||
val cookieList = request.header("Cookie")?.split("; ") ?: emptyList()
|
||||
if (cookie in cookieList) return chain.proceed(request)
|
||||
|
||||
setCookie("https://$domain/", "$cookie; Domain=$domain; Path=/")
|
||||
val prefix = "$key="
|
||||
val newCookie = buildList(cookieList.size + 1) {
|
||||
cookieList.filterNotTo(this) { it.startsWith(prefix) }
|
||||
add(cookie)
|
||||
}.joinToString("; ")
|
||||
val newRequest = request.newBuilder().header("Cookie", newCookie).build()
|
||||
return chain.proceed(newRequest)
|
||||
}
|
||||
|
||||
private fun setCookie(url: String, value: String) {
|
||||
try {
|
||||
CookieManager.getInstance().setCookie(url, value)
|
||||
} catch (e: Exception) {
|
||||
// Probably running on Tachidesk
|
||||
Log.e("Toonily", "failed to set cookie", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
89
multisrc/overrides/madara/toonily/src/Toonily.kt
Normal file
89
multisrc/overrides/madara/toonily/src/Toonily.kt
Normal file
@@ -0,0 +1,89 @@
|
||||
package eu.kanade.tachiyomi.extension.en.toonily
|
||||
|
||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
private const val domain = "toonily.com"
|
||||
class Toonily : Madara(
|
||||
"Toonily",
|
||||
"https://$domain",
|
||||
"en",
|
||||
SimpleDateFormat("MMM d, yy", Locale.US),
|
||||
) {
|
||||
|
||||
private val cookieInterceptor = CookieInterceptor(domain, "toonily-mature", "1")
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.addNetworkInterceptor(cookieInterceptor)
|
||||
.build()
|
||||
|
||||
override val mangaSubString = "webtoon"
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// The source customized the Madara theme and broke the filter.
|
||||
override val filterNonMangaItems = false
|
||||
|
||||
override val useNewChapterEndpoint: Boolean = true
|
||||
|
||||
override fun searchMangaSelector() = "div.page-item-detail.manga"
|
||||
|
||||
override val pageListParseSelector = "div.reading-content div"
|
||||
|
||||
override fun parseChapterDate(date: String?): Long {
|
||||
val formattedDate = if (date?.contains("UP") == true) "today" else date
|
||||
return super.parseChapterDate(formattedDate)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val titleSpecialCharactersRegex = "[^a-z0-9]+".toRegex()
|
||||
val trailingHyphenRegex = "-+$".toRegex()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user