Temporary fix images not loading at SuperMangás. (#5954)

This commit is contained in:
Alessandro Jean 2021-02-21 17:03:19 -03:00 committed by GitHub
parent e72bb09d1a
commit e0ce2732ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 4 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Super Mangás'
pkgNameSuffix = 'pt.supermangas'
extClass = '.SuperMangasFactory'
extVersionCode = 5
extVersionCode = 6
libVersion = '1.2'
containsNsfw = true
}

View File

@ -147,7 +147,7 @@ abstract class SuperMangasGeneric(
override fun latestUpdatesSelector() = popularMangaSelector()
override fun latestUpdatesFromElement(element: Element) = genericMangaFromElement(element)
override fun latestUpdatesFromElement(element: Element) = genericMangaFromElement(element, "data-src")
override fun latestUpdatesNextPageSelector(): String? = null
@ -370,7 +370,7 @@ abstract class SuperMangasGeneric(
private const val ACCEPT_JSON = "application/json, text/javascript, */*; q=0.01"
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"
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
private val JSON_PARSER by lazy { JsonParser() }

View File

@ -6,12 +6,19 @@ import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import okhttp3.FormBody
import okhttp3.HttpUrl
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
class SuperMangas : SuperMangasGeneric(
"Super Mangás",
"https://supermangas.site"
) {
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.addInterceptor(::tempCoverImageFixIntercept)
.build()
override val contentList = listOf(
Triple("100", "", "Todos"),
Triple("6", "", "Mangá"),
@ -33,8 +40,26 @@ class SuperMangas : SuperMangasGeneric(
super.chapterListPaginatedBody(idCategory, page, totalPage)
.add("order_audio", "pt-br")
private fun tempCoverImageFixIntercept(chain: Interceptor.Chain): Response {
val requestUrl = chain.request().url().toString()
if (requestUrl.contains(IMG_CDN_URL) && requestUrl.contains("?src=")) {
val newUrl = requestUrl
.replace("?src=", "")
.replaceFirst("&", "?")
val newRequest = chain.request().newBuilder()
.url(newUrl)
.build()
return chain.proceed(newRequest)
}
return chain.proceed(chain.request())
}
override fun getFilterList() = FilterList(
Filter.Header("Filtros abaixo são ignorados na busca!"),
Filter.Header("Os filtros abaixo são ignorados na busca!"),
ContentFilter(contentList),
LetterFilter(),
StatusFilter(),
@ -108,4 +133,8 @@ class SuperMangas : SuperMangasGeneric(
Tag("70", "War"),
Tag("15", "Yuri")
)
companion object {
private const val IMG_CDN_URL = "https://img.supermangas.site"
}
}