MangaKatana - fix covers (#3378)
This commit is contained in:
parent
11efc8f282
commit
92132e47c9
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: MangaKatana'
|
appName = 'Tachiyomi: MangaKatana'
|
||||||
pkgNameSuffix = 'en.mangakatana'
|
pkgNameSuffix = 'en.mangakatana'
|
||||||
extClass = '.MangaKatana'
|
extClass = '.MangaKatana'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,12 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
|
import java.lang.Exception
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import okhttp3.MediaType
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.ResponseBody
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
|
@ -20,7 +24,19 @@ class MangaKatana : ParsedHttpSource() {
|
||||||
|
|
||||||
override val supportsLatest = true
|
override val supportsLatest = true
|
||||||
|
|
||||||
override val client = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient.newBuilder().addNetworkInterceptor { chain ->
|
||||||
|
val originalResponse = chain.proceed(chain.request())
|
||||||
|
if (originalResponse.headers("Content-Type").contains("application/octet-stream")) {
|
||||||
|
val orgBody = originalResponse.body()!!.bytes()
|
||||||
|
val extension = chain.request().url().toString().substringAfterLast(".")
|
||||||
|
val newBody = ResponseBody.create(MediaType.parse("image/$extension"), orgBody)
|
||||||
|
originalResponse.newBuilder()
|
||||||
|
.body(newBody)
|
||||||
|
.build()
|
||||||
|
} else {
|
||||||
|
originalResponse
|
||||||
|
}
|
||||||
|
}.build()
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = "div#book_list > div.item"
|
override fun latestUpdatesSelector() = "div#book_list > div.item"
|
||||||
|
|
||||||
|
@ -29,7 +45,7 @@ class MangaKatana : ParsedHttpSource() {
|
||||||
override fun latestUpdatesFromElement(element: Element) = SManga.create().apply {
|
override fun latestUpdatesFromElement(element: Element) = SManga.create().apply {
|
||||||
setUrlWithoutDomain(element.select("div.text > h3 > a").attr("href"))
|
setUrlWithoutDomain(element.select("div.text > h3 > a").attr("href"))
|
||||||
title = element.select("div.text > h3 > a").text()
|
title = element.select("div.text > h3 > a").text()
|
||||||
thumbnail_url = element.select("img").attr("abs:data-src")
|
thumbnail_url = element.select("img").attr("abs:src")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector() = ".next.page-numbers"
|
override fun latestUpdatesNextPageSelector() = ".next.page-numbers"
|
||||||
|
@ -55,7 +71,7 @@ class MangaKatana : ParsedHttpSource() {
|
||||||
description = document.select(".summary > p").text()
|
description = document.select(".summary > p").text()
|
||||||
status = parseStatus(document.select(".value.status").text())
|
status = parseStatus(document.select(".value.status").text())
|
||||||
genre = document.select(".genres > a").joinToString { it.text() }
|
genre = document.select(".genres > a").joinToString { it.text() }
|
||||||
thumbnail_url = document.select(".cover > img").attr("abs:data-src")
|
thumbnail_url = document.select("div.media div.cover img").attr("abs:src")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseStatus(status: String) = when {
|
private fun parseStatus(status: String) = when {
|
||||||
|
@ -69,7 +85,7 @@ class MangaKatana : ParsedHttpSource() {
|
||||||
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
||||||
setUrlWithoutDomain(element.select("a").attr("href"))
|
setUrlWithoutDomain(element.select("a").attr("href"))
|
||||||
name = element.select("a").text()
|
name = element.select("a").text()
|
||||||
date_upload = dateFormat.parse(element.select(".update_time").text()).time ?: 0
|
date_upload = dateFormat.parse(element.select(".update_time").text()).time
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -79,18 +95,14 @@ class MangaKatana : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val html = document.toString()
|
// image URLs are in an array with each URL being reversed (e.g. 1.jpg becomes gpj.1)
|
||||||
|
val script = document.select("script:containsData(var ytaw)").firstOrNull()?.data()
|
||||||
// Thanks to https://github.com/manga-py/manga-py
|
?: throw Exception("Image array not found")
|
||||||
val regex = Regex("var\\s+\\w+\\s?=\\s?(\\[['\"].+?['\"]).?\\]\\s?;")
|
val regex = Regex("""'(.[^']*ptth)'""")
|
||||||
val match = regex.find(html)?.destructured?.toList()?.get(0)?.removePrefix("[")
|
return regex.findAll(script).toList().mapIndexed { i, mr ->
|
||||||
|
Page(i, "", mr.groupValues[1].reversed())
|
||||||
return match!!.split(",").mapIndexed { i, string ->
|
|
||||||
Page(i, "", string.reversed().replace("\"", "").replace("'", ""))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not Used")
|
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not Used")
|
||||||
|
|
||||||
override fun getFilterList() = FilterList()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue