feat(multisrc/tr): New source: HentaiZM (#19419)

* feat(multisrc/tr): Create HentaiZM base

* fix: Auto-login to fix thumbnails & chapter pages

* fix: Fix pagination in popular/latest pages

* feat: Add source icons

* chore: Remove unnecessary overrideVersionCode

* refactor: Use interceptor instead of init block + check if already logged in

Thanks AwkwardPeak7!
This commit is contained in:
Claudemirovsky 2023-12-26 08:28:08 -03:00 committed by GitHub
parent f9fd34a4d2
commit db07d894e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 74 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,73 @@
package eu.kanade.tachiyomi.extension.tr.hentaizm
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.asObservable
import eu.kanade.tachiyomi.source.model.MangasPage
import okhttp3.FormBody
import okhttp3.Interceptor
import okhttp3.Response
import rx.Observable
class HentaiZM : Madara(
"HentaiZM",
"https://manga.hentaizm.fun",
"tr",
) {
override val client by lazy {
super.client.newBuilder().addInterceptor(::loginInterceptor).build()
}
private fun loginInterceptor(chain: Interceptor.Chain): Response {
val request = chain.request()
val url = request.url.toString()
if (baseUrl !in url) {
return chain.proceed(request)
}
val cookies = client.cookieJar.loadForRequest(request.url)
// Only log-in when necessary.
if (cookies.any { it.name.startsWith("wordpress_logged_in_") }) {
return chain.proceed(request)
}
// A login is required in order to load thumbnails and pages.
val body = FormBody.Builder()
.add("log", "demo") // Default user/password, provided in
.add("pwd", "demo") // the source itself.
.add("redirect_to", "$baseUrl/wp-admin/")
.add("rememberme", "forever")
.build()
val postUrl = "$baseUrl/wp-login.php"
val headers = headersBuilder()
.set("Origin", baseUrl)
.set("Referer", postUrl)
.build()
super.client.newCall(POST(postUrl, headers, body)).execute().close()
return chain.proceed(request)
}
// ============================== Popular ===============================
// Yep, asObservable instead of asObservableSuccess, because this source
// returns HTTP 404 after the first page even in the browser, while working
// perfectly.
// TODO: Replace with getPopularManga(page) when extensions-lib v1.5 gets released.
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
return client.newCall(popularMangaRequest(page))
.asObservable()
.map(::popularMangaParse)
}
// =============================== Latest ===============================
// Same situation as above.
// TODO: Replace with getLatestUpdates(page) when extensions-lib v1.5 gets released.
override fun fetchLatestUpdates(page: Int): Observable<MangasPage> {
return client.newCall(latestUpdatesRequest(page))
.asObservable()
.map(::latestUpdatesParse)
}
}

View File

@ -143,6 +143,7 @@ class MadaraGenerator : ThemeSourceGenerator {
SingleLang("HentaiXComic", "https://hentaixcomic.com", "en", isNsfw = true),
SingleLang("HentaiXDickgirl", "https://hentaixdickgirl.com", "en", isNsfw = true),
SingleLang("HentaiXYuri", "https://hentaixyuri.com", "en", isNsfw = true),
SingleLang("HentaiZM", "https://manga.hentaizm.fun", "tr", isNsfw = true),
SingleLang("HentaiZone", "https://hentaizone.xyz", "fr", isNsfw = true, overrideVersionCode = 1),
SingleLang("HerenScan", "https://herenscan.com", "es"),
SingleLang("HipercooL", "https://hipercool.xyz", "pt-BR", isNsfw = true, className = "Hipercool"),