From 50de0baefb6f1cc4be04af444d8667290e7900cc Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:18:18 +0800 Subject: [PATCH] fixes on providers (#590) --- .../movieproviders/PinoyHDXyzProvider.kt | 2 +- .../movieproviders/PinoyMoviePediaProvider.kt | 15 +++++++++------ .../movieproviders/PinoyMoviesEsProvider.kt | 9 ++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt index 3116e314..45951d47 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt @@ -28,7 +28,7 @@ class PinoyHDXyzProvider : MainAPI() { // Get inner div from article val innerBody = it?.selectFirst("a") ?: return@mapNotNull null // Fetch details - val name = it.text() + val name = it.text()?.trim() if (name.isNullOrBlank()) { return@mapNotNull null } val link = innerBody.attr("href") ?: return@mapNotNull null diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt index 3448b02f..212b5804 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt @@ -6,6 +6,7 @@ import com.lagradost.cloudstream3.extractors.FEmbed import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor +import java.lang.Exception class PinoyMoviePediaProvider : MainAPI() { override val name = "Pinoy Moviepedia" @@ -115,9 +116,8 @@ class PinoyMoviePediaProvider : MainAPI() { // Video details val data = inner?.select("div.data") val poster = inner?.select("div.poster > img")?.attr("src") - val title = data?.select("h1")?.firstOrNull()?.text() ?: "" - val descript = body?.select("div#info > div.wp-content") - ?.select("p")?.get(0)?.text() + val title = data?.select("h1")?.firstOrNull()?.text()?.trim() ?: "" + val descript = body?.select("div#info > div.wp-content p")?.firstOrNull()?.text() val rex = Regex("\\((\\d+)") val yearRes = rex.find(title)?.value ?: "" //Log.i(this.name, "Result => (yearRes) ${yearRes}") @@ -130,7 +130,10 @@ class PinoyMoviePediaProvider : MainAPI() { val aUrl = a.attr("href") ?: return@mapNotNull null val aImg = a.select("img")?.attr("src") val aName = a.select("img")?.attr("alt") ?: return@mapNotNull null - val aYear = aName.trim().takeLast(5).removeSuffix(")").toIntOrNull() + val aYear = try { + aName.trim().takeLast(5).removeSuffix(")").toIntOrNull() + } catch (e: Exception) { null } + MovieSearchResponse( url = aUrl, name = aName, @@ -145,9 +148,9 @@ class PinoyMoviePediaProvider : MainAPI() { val playcontainer = body?.select("div#playcontainer") val listOfLinks: MutableList = mutableListOf() playcontainer?.select("iframe")?.forEach { item -> - val lnk = item?.attr("src")?.trim() + val lnk = item?.attr("src")?.trim() ?: "" //Log.i(this.name, "Result => (lnk) $lnk") - if (!lnk.isNullOrEmpty()) { + if (lnk.isNotBlank()) { listOfLinks.add(lnk) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt index bab11a05..7254d5da 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt @@ -10,6 +10,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor import org.jsoup.select.Elements +import java.lang.Exception class PinoyMoviesEsProvider : MainAPI() { override val name = "Pinoy Movies" @@ -110,10 +111,10 @@ class PinoyMoviesEsProvider : MainAPI() { .document.select("div#archive-content > article") return document?.mapNotNull { - val urlTitle = it?.select("div.data") ?: return@mapNotNull null // Fetch details + val urlTitle = it?.select("div.data") ?: return@mapNotNull null val link = urlTitle.select("a")?.attr("href") ?: return@mapNotNull null - val title = urlTitle.text() ?: "" + val title = urlTitle.text()?.trim() ?: "" val year = urlTitle.select("span.year")?.text()?.toIntOrNull() val image = it.select("div.poster > img")?.attr("src") @@ -148,7 +149,9 @@ class PinoyMoviesEsProvider : MainAPI() { val aUrl = a.attr("href") ?: return@mapNotNull null val aImg = a.select("img")?.attr("data-src") val aName = a.select("img")?.attr("alt") ?: return@mapNotNull null - val aYear = aName.trim().takeLast(5).removeSuffix(")").toIntOrNull() + val aYear = try { + aName.trim().takeLast(5).removeSuffix(")").toIntOrNull() + } catch (e: Exception) { null } MovieSearchResponse( url = aUrl, name = aName,