From d9d05acc45a0408fe6fe6b6d245e306f0c0f5cd9 Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Tue, 23 Aug 2022 13:39:00 +0800 Subject: [PATCH] Fix JavHD homepage issue. Add script for easier debugging. --- JavHD/build.gradle.kts | 2 +- JavHD/src/main/kotlin/com/jacekun/JavHD.kt | 22 ++++++++++++++++++---- run.bat | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 run.bat diff --git a/JavHD/build.gradle.kts b/JavHD/build.gradle.kts index b0997fd..4d5d063 100644 --- a/JavHD/build.gradle.kts +++ b/JavHD/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 1 +version = 2 cloudstream { diff --git a/JavHD/src/main/kotlin/com/jacekun/JavHD.kt b/JavHD/src/main/kotlin/com/jacekun/JavHD.kt index ac4ee75..a3a0f21 100644 --- a/JavHD/src/main/kotlin/com/jacekun/JavHD.kt +++ b/JavHD/src/main/kotlin/com/jacekun/JavHD.kt @@ -32,6 +32,7 @@ class JavHD : MainAPI() { //Log.i(this.name, "Result => (mainbody) ${mainbody}") var count = 0 + //Log.i(this.name, "Titles => ${mainbody.select("div.section-header")}") val titles = mainbody.select("div.section-header").mapNotNull { val text = it?.text() ?: return@mapNotNull null count++ @@ -39,9 +40,9 @@ class JavHD : MainAPI() { } //Log.i(this.name, "Result => (titles) ${titles}") - val entries = mainbody.select("div#video-widget-3016") count = 0 - entries.forEach { it2 -> + //Log.i(this.name, "Body => ${mainbody.select("div#video-widget-3016")}") + mainbody.select("div#video-widget-3016").forEach { it2 -> count++ // Fetch row title val pair = titles.filter { aa -> aa.first == count } @@ -50,11 +51,24 @@ class JavHD : MainAPI() { val inner = it2.select("div.col-md-3.col-sm-6.col-xs-6.item.responsive-height.post") val elements: List = inner.mapNotNull { // Inner element + //Log.i(this.name, "Result => ${it.selectFirst("div.item-img > a")}") val aa = it.selectFirst("div.item-img > a") ?: return@mapNotNull null // Video details val link = aa.attr("href") ?: return@mapNotNull null val name = aa.attr("title").cleanTitle() - val image = aa.select("img").attr("src") + var image = aa.select("img").attr("src") + //Get another image from 'srcset' element + if (image.isNullOrBlank()) { + run breaking@ { + aa.select("img").attr("srcset").split("\\s+".toRegex()) + .forEach { imgItem -> + image = imgItem.trim() + if (image.startsWith("https")) { + return@breaking + } + } + } + } val year = null //Log.i(this.name, "Result => (link) ${link}") //Log.i(this.name, "Result => (image) ${image}") @@ -81,7 +95,7 @@ class JavHD : MainAPI() { } } if (homePageList.isNotEmpty()) { - HomePageResponse( + return HomePageResponse( items = homePageList, hasNext = homePageList.any{ it.list.isNotEmpty() } ) diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..c4ce4c7 --- /dev/null +++ b/run.bat @@ -0,0 +1 @@ +.\gradlew.bat deployWithAdb \ No newline at end of file