Skip to content

Commit

Permalink
Add CatharsisFantasy (#5543)
Browse files Browse the repository at this point in the history
  • Loading branch information
choppeh authored Oct 16, 2024
1 parent 3b5bc1f commit 5d85cf9
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/es/catharsisfantasy/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ext {
extName = 'Catharsis Fantasy'
extClass = '.CatharsisFantasy'
themePkg = 'mangathemesia'
baseUrl = 'https://catharsisfantasy.com'
overrideVersionCode = 0
isNsfw = true
}

apply from: "$rootDir/common.gradle"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package eu.kanade.tachiyomi.extension.es.catharsisfantasy

import android.annotation.SuppressLint
import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.OkHttpClient
import org.jsoup.nodes.Document
import java.security.SecureRandom
import java.security.cert.X509Certificate
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager

class CatharsisFantasy : MangaThemesia(
"Catharsis Fantasy",
"https://catharsisfantasy.com",
"es",
) {
override val client = super.client.newBuilder()
.rateLimit(3)
.ignoreAllSSLErrors()
.build()

private val iframeSelector: String = "#mangaIframe"

override fun pageListParse(document: Document): List<Page> {
return super.pageListParse(
document.takeIf { it.select(iframeSelector).isEmpty() }
?: fetchIframeDocumentPageList(document),
)
}

private fun fetchIframeDocumentPageList(document: Document): Document {
val pagesUrl = document.selectFirst(iframeSelector)!!
.absUrl("src")

return client.newCall(GET(pagesUrl, headers))
.execute().asJsoup()
}

private fun OkHttpClient.Builder.ignoreAllSSLErrors(): OkHttpClient.Builder {
val naiveTrustManager = @SuppressLint("CustomX509TrustManager")
object : X509TrustManager {
override fun getAcceptedIssuers(): Array<X509Certificate> = emptyArray()
override fun checkClientTrusted(certs: Array<X509Certificate>, authType: String) = Unit
override fun checkServerTrusted(certs: Array<X509Certificate>, authType: String) = Unit
}

val insecureSocketFactory = SSLContext.getInstance("TLSv1.2").apply {
val trustAllCerts = arrayOf<TrustManager>(naiveTrustManager)
init(null, trustAllCerts, SecureRandom())
}.socketFactory

sslSocketFactory(insecureSocketFactory, naiveTrustManager)
hostnameVerifier { _, _ -> true }
return this
}
}

0 comments on commit 5d85cf9

Please sign in to comment.