Fix chapter images not loading at Tsuki (again). (#4907)

Fix chapter images not loading at Tsuki (again)
This commit is contained in:
Alessandro Jean 2020-11-20 21:10:59 -03:00 committed by GitHub
parent 2c9cbb24e1
commit 1abfadeab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Tsuki Mangás' extName = 'Tsuki Mangás'
pkgNameSuffix = 'pt.tsukimangas' pkgNameSuffix = 'pt.tsukimangas'
extClass = '.TsukiMangas' extClass = '.TsukiMangas'
extVersionCode = 4 extVersionCode = 5
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -45,7 +45,8 @@ class TsukiMangas : HttpSource() {
.build() .build()
override fun headersBuilder(): Headers.Builder = Headers.Builder() override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("Accept", "application/json, text/plain, */*") .add("Accept", ACCEPT)
.add("Accept-Language", ACCEPT_LANGUAGE)
.add("User-Agent", USER_AGENT) .add("User-Agent", USER_AGENT)
.add("Referer", baseUrl) .add("Referer", baseUrl)
@ -247,7 +248,7 @@ class TsukiMangas : HttpSource() {
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response): List<Page> {
val result = response.asJson().array val result = response.asJson().array
return result.mapIndexed { i, page -> Page(i, baseUrl, page.obj["IMG"].string) } return result.mapIndexed { i, page -> Page(i, baseUrl + "/", page.obj["IMG"].string) }
} }
override fun fetchImageUrl(page: Page): Observable<String> = Observable.just(page.imageUrl!!) override fun fetchImageUrl(page: Page): Observable<String> = Observable.just(page.imageUrl!!)
@ -256,7 +257,8 @@ class TsukiMangas : HttpSource() {
override fun imageRequest(page: Page): Request { override fun imageRequest(page: Page): Request {
val newHeaders = headersBuilder() val newHeaders = headersBuilder()
.set("Accept", "image/avif,image/webp,image/apng,image/*,*/*;q=0.8") .set("Accept", ACCEPT_IMAGE)
.set("Accept-Language", ACCEPT_LANGUAGE)
.set("Referer", page.url) .set("Referer", page.url)
.build() .build()
@ -334,6 +336,9 @@ class TsukiMangas : HttpSource() {
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body()!!.string()) private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body()!!.string())
companion object { companion object {
private const val ACCEPT = "application/json, text/plain, */*"
private const val ACCEPT_IMAGE = "image/avif,image/webp,image/apng,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"
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + 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/87.0.4280.66 Safari/537.36"