From cb3405e19ebcae539a060b2d322039f73dd9d77d Mon Sep 17 00:00:00 2001 From: happywillow0 <45346080+happywillow0@users.noreply.github.com> Date: Wed, 8 Jan 2020 20:52:34 -0500 Subject: [PATCH] TMO Update (#2012) TMO Update --- src/es/tumangaonline/build.gradle | 2 +- .../es/tumangaonline/TuMangaOnline.kt | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/es/tumangaonline/build.gradle b/src/es/tumangaonline/build.gradle index 6c2c00e74..834766799 100755 --- a/src/es/tumangaonline/build.gradle +++ b/src/es/tumangaonline/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: TuMangaOnline' pkgNameSuffix = 'es.tumangaonline' extClass = '.TuMangaOnline' - extVersionCode = 15 + extVersionCode = 16 libVersion = '1.2' } diff --git a/src/es/tumangaonline/src/eu/kanade/tachiyomi/extension/es/tumangaonline/TuMangaOnline.kt b/src/es/tumangaonline/src/eu/kanade/tachiyomi/extension/es/tumangaonline/TuMangaOnline.kt index bbc1d5449..a5705efaa 100755 --- a/src/es/tumangaonline/src/eu/kanade/tachiyomi/extension/es/tumangaonline/TuMangaOnline.kt +++ b/src/es/tumangaonline/src/eu/kanade/tachiyomi/extension/es/tumangaonline/TuMangaOnline.kt @@ -291,12 +291,27 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() { } override fun pageListParse(response: Response): List = mutableListOf().apply { + val chapterID = response.request().url().toString().substringAfter("viewer/").substringBefore("/cascade") val body = response.asJsoup() - - body.select("div#viewer-container > div.viewer-image-container > img.viewer-image")?.forEach { - add(Page(size, "", it.attr("src"))) + + //alternative lookup img.viewer-image:eq(1) + body.select("div#viewer-container > div.viewer-image-container > img.viewer-image[src*=$chapterID]:not([style=display:none;])")?.forEach { + add(Page(size, "", getImage(it))) } } + + private fun getImage(element: Element): String { + var url = + when { + element.attr("data-src").endsWith(".jpg") || element.attr("data-src").endsWith(".png") || element.attr("data-src").endsWith(".jpeg") -> element.attr("data-src") + element.attr("src").endsWith(".jpg") || element.attr("src").endsWith(".png") || element.attr("src").endsWith(".jpeg") -> element.attr("src") + else -> throw Exception("Extension needs update, post issue to GitHub") //element.attr("data-lazy-src") + } + if (url.startsWith("//")) { + url = "http:$url" + } + return url + } override fun pageListParse(document: Document) = throw UnsupportedOperationException("Not used")