fixes on providers (#590)

This commit is contained in:
Jace 2022-02-07 17:18:18 +08:00 committed by GitHub
parent c191d16b01
commit 50de0baefb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View file

@ -28,7 +28,7 @@ class PinoyHDXyzProvider : MainAPI() {
// Get inner div from article // Get inner div from article
val innerBody = it?.selectFirst("a") ?: return@mapNotNull null val innerBody = it?.selectFirst("a") ?: return@mapNotNull null
// Fetch details // Fetch details
val name = it.text() val name = it.text()?.trim()
if (name.isNullOrBlank()) { return@mapNotNull null } if (name.isNullOrBlank()) { return@mapNotNull null }
val link = innerBody.attr("href") ?: return@mapNotNull null val link = innerBody.attr("href") ?: return@mapNotNull null

View file

@ -6,6 +6,7 @@ import com.lagradost.cloudstream3.extractors.FEmbed
import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import java.lang.Exception
class PinoyMoviePediaProvider : MainAPI() { class PinoyMoviePediaProvider : MainAPI() {
override val name = "Pinoy Moviepedia" override val name = "Pinoy Moviepedia"
@ -115,9 +116,8 @@ class PinoyMoviePediaProvider : MainAPI() {
// Video details // Video details
val data = inner?.select("div.data") val data = inner?.select("div.data")
val poster = inner?.select("div.poster > img")?.attr("src") val poster = inner?.select("div.poster > img")?.attr("src")
val title = data?.select("h1")?.firstOrNull()?.text() ?: "" val title = data?.select("h1")?.firstOrNull()?.text()?.trim() ?: ""
val descript = body?.select("div#info > div.wp-content") val descript = body?.select("div#info > div.wp-content p")?.firstOrNull()?.text()
?.select("p")?.get(0)?.text()
val rex = Regex("\\((\\d+)") val rex = Regex("\\((\\d+)")
val yearRes = rex.find(title)?.value ?: "" val yearRes = rex.find(title)?.value ?: ""
//Log.i(this.name, "Result => (yearRes) ${yearRes}") //Log.i(this.name, "Result => (yearRes) ${yearRes}")
@ -130,7 +130,10 @@ class PinoyMoviePediaProvider : MainAPI() {
val aUrl = a.attr("href") ?: return@mapNotNull null val aUrl = a.attr("href") ?: return@mapNotNull null
val aImg = a.select("img")?.attr("src") val aImg = a.select("img")?.attr("src")
val aName = a.select("img")?.attr("alt") ?: return@mapNotNull null 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( MovieSearchResponse(
url = aUrl, url = aUrl,
name = aName, name = aName,
@ -145,9 +148,9 @@ class PinoyMoviePediaProvider : MainAPI() {
val playcontainer = body?.select("div#playcontainer") val playcontainer = body?.select("div#playcontainer")
val listOfLinks: MutableList<String> = mutableListOf() val listOfLinks: MutableList<String> = mutableListOf()
playcontainer?.select("iframe")?.forEach { item -> playcontainer?.select("iframe")?.forEach { item ->
val lnk = item?.attr("src")?.trim() val lnk = item?.attr("src")?.trim() ?: ""
//Log.i(this.name, "Result => (lnk) $lnk") //Log.i(this.name, "Result => (lnk) $lnk")
if (!lnk.isNullOrEmpty()) { if (lnk.isNotBlank()) {
listOfLinks.add(lnk) listOfLinks.add(lnk)
} }
} }

View file

@ -10,6 +10,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.select.Elements import org.jsoup.select.Elements
import java.lang.Exception
class PinoyMoviesEsProvider : MainAPI() { class PinoyMoviesEsProvider : MainAPI() {
override val name = "Pinoy Movies" override val name = "Pinoy Movies"
@ -110,10 +111,10 @@ class PinoyMoviesEsProvider : MainAPI() {
.document.select("div#archive-content > article") .document.select("div#archive-content > article")
return document?.mapNotNull { return document?.mapNotNull {
val urlTitle = it?.select("div.data") ?: return@mapNotNull null
// Fetch details // Fetch details
val urlTitle = it?.select("div.data") ?: return@mapNotNull null
val link = urlTitle.select("a")?.attr("href") ?: return@mapNotNull null val link = urlTitle.select("a")?.attr("href") ?: return@mapNotNull null
val title = urlTitle.text() ?: "<No Title>" val title = urlTitle.text()?.trim() ?: "<No Title>"
val year = urlTitle.select("span.year")?.text()?.toIntOrNull() val year = urlTitle.select("span.year")?.text()?.toIntOrNull()
val image = it.select("div.poster > img")?.attr("src") 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 aUrl = a.attr("href") ?: return@mapNotNull null
val aImg = a.select("img")?.attr("data-src") val aImg = a.select("img")?.attr("data-src")
val aName = a.select("img")?.attr("alt") ?: return@mapNotNull null 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( MovieSearchResponse(
url = aUrl, url = aUrl,
name = aName, name = aName,