Mangalek avoid tripping cloudflare detections (#18756)
* Update .gitignore * Avoid tripping cloudflare detections
This commit is contained in:
parent
9c2a65df4d
commit
958850c5d8
|
@ -6,6 +6,17 @@ import android.widget.Toast
|
|||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.extension.BuildConfig
|
||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -36,6 +47,7 @@ class Mangalek : Madara("مانجا ليك", "https://manga-lek.net", "ar", Simp
|
|||
summary = BASE_URL_PREF_SUMMARY
|
||||
this.setDefaultValue(defaultBaseUrl)
|
||||
dialogTitle = BASE_URL_PREF_TITLE
|
||||
dialogMessage = "Default: $defaultBaseUrl"
|
||||
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show()
|
||||
|
@ -48,4 +60,57 @@ class Mangalek : Madara("مانجا ليك", "https://manga-lek.net", "ar", Simp
|
|||
}
|
||||
|
||||
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!!
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
return GET(
|
||||
url = "$baseUrl/$mangaSubString/${searchPage(page)}",
|
||||
headers = headers,
|
||||
cache = CacheControl.FORCE_NETWORK,
|
||||
)
|
||||
}
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request = popularMangaRequest(page)
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request =
|
||||
POST(
|
||||
"$baseUrl/wp-admin/admin-ajax.php",
|
||||
headers,
|
||||
FormBody.Builder()
|
||||
.add("action", "wp-manga-search-manga")
|
||||
.add("title", query)
|
||||
.build(),
|
||||
)
|
||||
|
||||
private inline fun <reified T> Response.parseAs(): T {
|
||||
return json.decodeFromString(body.string())
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class SearchResponseDto(
|
||||
val data: List<SearchEntryDto>,
|
||||
val success: Boolean,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SearchEntryDto(
|
||||
val url: String = "",
|
||||
val title: String = "",
|
||||
)
|
||||
|
||||
override fun searchMangaParse(response: Response): MangasPage {
|
||||
val dto = response.parseAs<SearchResponseDto>()
|
||||
|
||||
if (!dto.success) {
|
||||
return MangasPage(emptyList(), false)
|
||||
}
|
||||
|
||||
val manga = dto.data.map {
|
||||
SManga.create().apply {
|
||||
setUrlWithoutDomain(it.url)
|
||||
title = it.title
|
||||
}
|
||||
}
|
||||
|
||||
return MangasPage(manga, false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -526,7 +526,7 @@ class MadaraGenerator : ThemeSourceGenerator {
|
|||
SingleLang("شبكة كونان العربية", "https://manga.detectiveconanar.com", "ar", className = "DetectiveConanAr", overrideVersionCode = 2),
|
||||
SingleLang("عرب تونز", "https://arabtoons.net", "ar", isNsfw = true, className = "ArabToons"),
|
||||
SingleLang("مانجا العاشق", "https://3asq.org", "ar", className = "Manga3asq", overrideVersionCode = 2),
|
||||
SingleLang("مانجا ليك", "https://manga-lek.net", "ar", className = "Mangalek", overrideVersionCode = 3),
|
||||
SingleLang("مانجا ليك", "https://manga-lek.net", "ar", className = "Mangalek", overrideVersionCode = 4),
|
||||
SingleLang("مانجا ليكس", "https://mangaleks.com", "ar", className = "MangaLeks"),
|
||||
SingleLang("مانجا لينك", "https://mangalink.io", "ar", className = "MangaLinkio", overrideVersionCode = 3),
|
||||
SingleLang("كوميك العرب", "https://comicarab.com", "ar", isNsfw = true, className = "ComicArab"),
|
||||
|
|
Loading…
Reference in New Issue