Add motiontoon support to webtoons (#3798)
* Add support for motiontoons to webtoons * Update build.gradle * Remove unnecessary import that I added for some reason * Remove more unnecessary imports * Hope this passes
This commit is contained in:
parent
4c2505faa2
commit
f93fbabbdd
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'Webtoons'
|
||||
pkgNameSuffix = 'all.webtoons'
|
||||
extClass = '.WebtoonsFactory'
|
||||
extVersionCode = 17
|
||||
extVersionCode = 18
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Page> {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue