Fix YT chapter images not loading (#10922). (#10944)

This commit is contained in:
Alessandro Jean 2022-02-27 11:47:19 -03:00 committed by GitHub
parent f1385cbdba
commit c50ac5ee87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View File

@ -2,8 +2,11 @@ package eu.kanade.tachiyomi.extension.pt.yaoitoshokan
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Page
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.Request
import org.jsoup.nodes.Document
import java.text.SimpleDateFormat
import java.util.Locale
@ -11,12 +14,15 @@ import java.util.concurrent.TimeUnit
class YaoiToshokan : Madara(
"Yaoi Toshokan",
"https://yaoitoshokan.net",
"https://www.yaoitoshokan.net",
"pt-BR",
SimpleDateFormat("dd MMM yyyy", Locale("pt", "BR"))
) {
override val client: OkHttpClient = super.client.newBuilder()
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
.removeAll("User-Agent")
override val client: OkHttpClient = network.client.newBuilder()
.addInterceptor(RateLimitInterceptor(1, 2, TimeUnit.SECONDS))
.build()
@ -24,11 +30,28 @@ class YaoiToshokan : Madara(
override val popularMangaUrlSelector = "div.post-title a:not([target])"
override fun pageListParse(document: Document): List<Page> {
countViews(document)
return document.select(pageListParseSelector)
.mapIndexed { index, element ->
// Had to add trim because of white space in source.
val imageUrl = element.select("img").attr("data-src").trim()
Page(index, document.location(), imageUrl)
Page(index, "$baseUrl/", imageUrl)
}
}
override fun imageRequest(page: Page): Request {
val newHeaders = headersBuilder()
.add("Accept", ACCEPT_IMAGE)
.add("Accept-Language", ACCEPT_LANGUAGE)
.set("Referer", page.url)
.build()
return GET(page.imageUrl!!, newHeaders)
}
companion object {
private const val ACCEPT_IMAGE = "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,gl;q=0.5"
}
}

View File

@ -456,7 +456,7 @@ class MadaraGenerator : ThemeSourceGenerator {
SingleLang("XManga", "https://xmanga.io", "en", isNsfw = true),
SingleLang("XuN Scans", "https://xunscans.xyz", "en", overrideVersionCode = 2),
SingleLang("Yaoi Hentai", "https://yaoihentai.me", "en", isNsfw = true),
SingleLang("Yaoi Toshokan", "https://yaoitoshokan.net", "pt-BR", isNsfw = true, overrideVersionCode = 3),
SingleLang("Yaoi Toshokan", "https://yaoitoshokan.net", "pt-BR", isNsfw = true, overrideVersionCode = 4),
SingleLang("Yaoi.mobi", "https://yaoi.mobi", "en", isNsfw = true, className = "YaoiManga", pkgName = "yaoimanga", overrideVersionCode = 4),
SingleLang("YaoiScan", "https://yaoiscan.com", "en", isNsfw = true),
SingleLang("YaoiToon", "https://yaoitoon.com", "en", isNsfw = true),