diff --git a/src/all/webtoons/build.gradle b/src/all/webtoons/build.gradle index 749a35b94..407578edb 100644 --- a/src/all/webtoons/build.gradle +++ b/src/all/webtoons/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Webtoons' pkgNameSuffix = 'all.webtoons' extClass = '.WebtoonsFactory' - extVersionCode = 17 + extVersionCode = 18 libVersion = '1.2' } diff --git a/src/all/webtoons/src/eu/kanade/tachiyomi/extension/all/webtoons/WebtoonsDefault.kt b/src/all/webtoons/src/eu/kanade/tachiyomi/extension/all/webtoons/WebtoonsDefault.kt index d3b6726f1..80231fa63 100644 --- a/src/all/webtoons/src/eu/kanade/tachiyomi/extension/all/webtoons/WebtoonsDefault.kt +++ b/src/all/webtoons/src/eu/kanade/tachiyomi/extension/all/webtoons/WebtoonsDefault.kt @@ -8,6 +8,7 @@ import java.text.SimpleDateFormat import java.util.Locale import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import org.json.JSONObject open class WebtoonsDefault( override val lang: String, @@ -40,5 +41,25 @@ open class WebtoonsDefault( override fun chapterListRequest(manga: SManga) = GET("https://m.webtoons.com" + manga.url, mobileHeaders) - override fun pageListParse(document: Document) = document.select("div#_imageList > img").mapIndexed { i, element -> Page(i, "", element.attr("data-url")) } + override fun pageListParse(document: Document): List { + val pages = document.select("div#_imageList > img").mapIndexed { i, element -> Page(i, "", element.attr("data-url")) } + + if (pages.isNotEmpty()) { return pages } + + val docString = document.toString() + + val docUrlRegex = Regex("documentURL:.*?'(.*?)'") + val motiontoonPathRegex = Regex("jpg:.*?'(.*?)\\{") + + val docUrl = docUrlRegex.find(docString)!!.destructured.toList()[0] + val motiontoonPath = motiontoonPathRegex.find(docString)!!.destructured.toList()[0] + + val motiontoonJson = JSONObject(client.newCall(GET(docUrl, headers)).execute().body()!!.string()).getJSONObject("assets").getJSONObject("image") + + val keys = motiontoonJson.keys().asSequence().toList().filter { it.contains("layer") } + + return keys.mapIndexed { i, key -> + Page(i, "", motiontoonPath + motiontoonJson.getString(key)) + } + } }