From 11964344486fa01519be818def416e5fbd76195c Mon Sep 17 00:00:00 2001 From: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> Date: Wed, 11 Oct 2023 23:07:33 -0300 Subject: [PATCH] Fix wrong images in SS (#18499) * Fix wrong images in SS. * Undo visibility modifier change. --- .../mangathemesia/ssshentais/src/SssHentais.kt | 16 ++++++++++++++++ .../sssscanlator/src/SSSScanlator.kt | 16 ++++++++++++++++ .../multisrc/mangathemesia/MangaThemesia.kt | 15 ++++++++++++--- .../mangathemesia/MangaThemesiaGenerator.kt | 4 ++-- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/multisrc/overrides/mangathemesia/ssshentais/src/SssHentais.kt b/multisrc/overrides/mangathemesia/ssshentais/src/SssHentais.kt index 4ef3b43e0..24fb3476b 100644 --- a/multisrc/overrides/mangathemesia/ssshentais/src/SssHentais.kt +++ b/multisrc/overrides/mangathemesia/ssshentais/src/SssHentais.kt @@ -1,8 +1,11 @@ package eu.kanade.tachiyomi.extension.pt.ssshentais 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 okhttp3.OkHttpClient +import okhttp3.Request import java.text.SimpleDateFormat import java.util.Locale import java.util.concurrent.TimeUnit @@ -17,4 +20,17 @@ class SssHentais : MangaThemesia( override val client: OkHttpClient = super.client.newBuilder() .rateLimit(1, 2, TimeUnit.SECONDS) .build() + + override fun imageRequest(page: Page): Request { + val newHeaders = headersBuilder() + .set("Referer", page.url) + .set("Accept", "image/avif,image/webp,*/*") + .set("Accept-Language", "pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3") + .set("Sec-Fetch-Dest", "image") + .set("Sec-Fetch-Mode", "no-cors") + .set("Sec-Fetch-Site", "same-origin") + .build() + + return GET(page.imageUrl!!, newHeaders) + } } diff --git a/multisrc/overrides/mangathemesia/sssscanlator/src/SSSScanlator.kt b/multisrc/overrides/mangathemesia/sssscanlator/src/SSSScanlator.kt index cc4c69dae..ff42ec467 100644 --- a/multisrc/overrides/mangathemesia/sssscanlator/src/SSSScanlator.kt +++ b/multisrc/overrides/mangathemesia/sssscanlator/src/SSSScanlator.kt @@ -1,8 +1,11 @@ package eu.kanade.tachiyomi.extension.pt.sssscanlator 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 okhttp3.OkHttpClient +import okhttp3.Request import java.text.SimpleDateFormat import java.util.Locale import java.util.concurrent.TimeUnit @@ -17,4 +20,17 @@ class SSSScanlator : MangaThemesia( override val client: OkHttpClient = super.client.newBuilder() .rateLimit(1, 2, TimeUnit.SECONDS) .build() + + override fun imageRequest(page: Page): Request { + val newHeaders = headersBuilder() + .set("Referer", page.url) + .set("Accept", "image/avif,image/webp,*/*") + .set("Accept-Language", "pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3") + .set("Sec-Fetch-Dest", "image") + .set("Sec-Fetch-Mode", "no-cors") + .set("Sec-Fetch-Site", "same-origin") + .build() + + return GET(page.imageUrl!!, newHeaders) + } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesia.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesia.kt index 40c740771..f2ede3dc4 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesia.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesia.kt @@ -35,6 +35,7 @@ import rx.Observable import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy +import java.lang.IllegalArgumentException import java.text.SimpleDateFormat import java.util.Locale import java.util.concurrent.TimeUnit @@ -214,7 +215,6 @@ abstract class MangaThemesia( listOf("ongoing", "publishing").any { this.contains(it, ignoreCase = true) } -> SManga.ONGOING this.contains("hiatus", ignoreCase = true) -> SManga.ON_HIATUS this.contains("completed", ignoreCase = true) -> SManga.COMPLETED - listOf("dropped", "cancelled").any { this.contains(it, ignoreCase = true) } -> SManga.CANCELLED else -> SManga.UNKNOWN } @@ -263,9 +263,10 @@ abstract class MangaThemesia( open val pageSelector = "div#readerarea img" override fun pageListParse(document: Document): List { + val chapterUrl = document.location() val htmlPages = document.select(pageSelector) .filterNot { it.imgAttr().isEmpty() } - .mapIndexed { i, img -> Page(i, "", img.imgAttr()) } + .mapIndexed { i, img -> Page(i, chapterUrl, img.imgAttr()) } countViews(document) @@ -280,12 +281,20 @@ abstract class MangaThemesia( emptyList() } val scriptPages = imageList.mapIndexed { i, jsonEl -> - Page(i, "", jsonEl.jsonPrimitive.content) + Page(i, chapterUrl, jsonEl.jsonPrimitive.content) } return scriptPages } + override fun imageRequest(page: Page): Request { + val newHeaders = headersBuilder() + .set("Referer", page.url) + .build() + + return GET(page.imageUrl!!, newHeaders) + } + /** * Set it to false if you want to disable the extension reporting the view count * back to the source website through admin-ajax.php. diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt index 5e761023f..6ddeae842 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangathemesia/MangaThemesiaGenerator.kt @@ -126,8 +126,8 @@ class MangaThemesiaGenerator : ThemeSourceGenerator { SingleLang("SkyMangas", "https://skymangas.com", "es"), SingleLang("Snudae Scans", "https://snudaescans.com", "en", isNsfw = true, className = "BatotoScans", overrideVersionCode = 1), SingleLang("Soul Scans", "https://soulscans.my.id", "id", overrideVersionCode = 1), - SingleLang("SSSScanlator", "https://sssscanlator.com", "pt-BR"), - SingleLang("SSS Hentais", "https://hentais.sssscanlator.com", "pt-BR", isNsfw = true, className = "SssHentais"), + SingleLang("SSSScanlator", "https://sssscanlator.com", "pt-BR", overrideVersionCode = 1), + SingleLang("SSS Hentais", "https://hentais.sssscanlator.com", "pt-BR", isNsfw = true, className = "SssHentais", overrideVersionCode = 1), SingleLang("Starlight Scan", "https://starligthscan.com", "pt-BR", isNsfw = true), SingleLang("Summer Fansub", "https://smmr.in", "pt-BR", isNsfw = true), SingleLang("SummerToon", "https://summertoon.com", "tr"),