Various providers fixes (#426)

This commit is contained in:
Jace 2022-01-11 20:36:54 +08:00 committed by GitHub
parent 48d391c530
commit f7aa1ce06d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 309 additions and 344 deletions

View file

@ -1,11 +1,12 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import android.util.Log import android.util.Log
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.extractors.* import com.lagradost.cloudstream3.extractors.*
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.Jsoup
class DramaSeeProvider : MainAPI() { class DramaSeeProvider : MainAPI() {
override val mainUrl = "https://dramasee.net" override val mainUrl = "https://dramasee.net"
@ -18,16 +19,13 @@ class DramaSeeProvider : MainAPI() {
override fun getMainPage(): HomePageResponse { override fun getMainPage(): HomePageResponse {
val headers = mapOf("X-Requested-By" to "dramasee.net") val headers = mapOf("X-Requested-By" to "dramasee.net")
val html = app.get(mainUrl, headers = headers).text val document = app.get(mainUrl, headers = headers).document
val document = Jsoup.parse(html)
val mainbody = document.getElementsByTag("body") val mainbody = document.getElementsByTag("body")
return HomePageResponse( return HomePageResponse(mainbody?.select("section")?.map { row ->
mainbody?.select("section")?.map { row -> val main = row?.select("main") ?: return@map null
val main = row?.select("main") val title = main.select("div.title > div > h2")?.text() ?: "Main"
val inner = main.select("li.series-item") ?: return@map null
val title = main?.select("div.title > div > h2")?.text() ?: "Main"
val inner = main?.select("li.series-item") ?: return@map null
HomePageList( HomePageList(
title, title,
@ -59,24 +57,26 @@ class DramaSeeProvider : MainAPI() {
val document = html.getElementsByTag("body") val document = html.getElementsByTag("body")
.select("section > main > ul.series > li") ?: return listOf() .select("section > main > ul.series > li") ?: return listOf()
return document.map { return document.mapNotNull {
val innerA = it?.select("a.series-img") if (it == null) {
val href = innerA?.attr("href") ?: return@map null return@mapNotNull null
val link = fixUrlNull(href) ?: return@map null }
val title = it?.select("a.series-name")?.text() ?: return@map null val innerA = it.select("a.series-img") ?: return@mapNotNull null
val link = fixUrlNull(innerA.attr("href")) ?: return@mapNotNull null
val title = it.select("a.series-name")?.text() ?: return@mapNotNull null
val year = null val year = null
val imgsrc = innerA?.select("img")?.attr("src") ?: return@map null val imgsrc = innerA.select("img")?.attr("src") ?: return@mapNotNull null
val image = fixUrl(imgsrc) val image = fixUrlNull(imgsrc)
MovieSearchResponse( MovieSearchResponse(
title, name = title,
link, url = link,
this.name, apiName = this.name,
TvType.Movie, type = TvType.Movie,
image, posterUrl = image,
year year = year
) )
}.filterNotNull() }
} }
override fun load(url: String): LoadResponse { override fun load(url: String): LoadResponse {
@ -96,14 +96,10 @@ class DramaSeeProvider : MainAPI() {
// Episodes Links // Episodes Links
val episodeList = ArrayList<TvSeriesEpisode>() val episodeList = ArrayList<TvSeriesEpisode>()
val eps = body?.select("ul.episodes > li.episode-item") body?.select("ul.episodes > li.episode-item")?.forEach { ep ->
//Log.i(this.name, "Result => (eps) ${eps}") val innerA = ep.select("a") ?: return@forEach
if (!eps.isNullOrEmpty()) {
for (ep in eps) {
if (ep != null) {
val innerA = ep.select("a")
val count = innerA.select("span.episode")?.text()?.toIntOrNull() ?: 0 val count = innerA.select("span.episode")?.text()?.toIntOrNull() ?: 0
val epLink = fixUrlNull(innerA.attr("href")) ?: continue val epLink = fixUrlNull(innerA.attr("href")) ?: return@forEach
//Log.i(this.name, "Result => (epLink) ${epLink}") //Log.i(this.name, "Result => (epLink) ${epLink}")
if (epLink.isNotEmpty()) { if (epLink.isNotEmpty()) {
// Fetch video links // Fetch video links
@ -111,24 +107,22 @@ class DramaSeeProvider : MainAPI() {
val ajaxUrl = epVidLinkEl.select("div#js-player")?.attr("embed") val ajaxUrl = epVidLinkEl.select("div#js-player")?.attr("embed")
//Log.i(this.name, "Result => (ajaxUrl) ${ajaxUrl}") //Log.i(this.name, "Result => (ajaxUrl) ${ajaxUrl}")
if (!ajaxUrl.isNullOrEmpty()) { if (!ajaxUrl.isNullOrEmpty()) {
val innerPage = Jsoup.parse(app.get(fixUrl(ajaxUrl), referer = epLink).text) val innerPage = app.get(fixUrl(ajaxUrl), referer = epLink).document
val listOfLinks = mutableListOf<String>() val listOfLinks = mutableListOf<String>()
val serverAvail = innerPage?.select("div.player.active > main > div") innerPage.select("div.player.active > main > div")?.forEach { em ->
if (!serverAvail.isNullOrEmpty()) { val href = em.attr("src") ?: ""
for (em in serverAvail) { if (href.isNotEmpty()) {
val href = em.attr("src")
if (!href.isNullOrEmpty()) {
listOfLinks.add(href) listOfLinks.add(href)
} }
} }
}
//Log.i(this.name, "Result => (listOfLinks) ${listOfLinks}") //Log.i(this.name, "Result => (listOfLinks) ${listOfLinks}")
episodeList.add( episodeList.add(
TvSeriesEpisode( TvSeriesEpisode(
name = "Episode $count", name = null,
season = null, season = null,
episode = count, episode = count,
data = listOfLinks.toString(), data = listOfLinks.distinct().toJson(),
posterUrl = poster, posterUrl = poster,
date = null date = null
) )
@ -136,8 +130,7 @@ class DramaSeeProvider : MainAPI() {
} }
} }
} }
}
}
//If there's only 1 episode, consider it a movie. //If there's only 1 episode, consider it a movie.
if (episodeList.size == 1) { if (episodeList.size == 1) {
return MovieLoadResponse(title, url, this.name, TvType.Movie, episodeList[0].data, poster, year, descript, null, null) return MovieLoadResponse(title, url, this.name, TvType.Movie, episodeList[0].data, poster, year, descript, null, null)
@ -163,13 +156,11 @@ class DramaSeeProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
if (data == "about:blank") return false
if (data == "[]") return false
if (data.isEmpty()) return false if (data.isEmpty()) return false
if (data == "[]") return false
if (data == "about:blank") return false
val urls = data.trim('[').trim(']').split(',') mapper.readValue<List<String>>(data).forEach { item ->
if (!urls.isNullOrEmpty()) {
for (item in urls) {
if (item.isNotEmpty()) { if (item.isNotEmpty()) {
var url = item.trim() var url = item.trim()
if (url.startsWith("//")) { if (url.startsWith("//")) {
@ -188,8 +179,7 @@ class DramaSeeProvider : MainAPI() {
if (datavid.startsWith("https://fembed-hd.com")) { if (datavid.startsWith("https://fembed-hd.com")) {
val extractor = XStreamCdn() val extractor = XStreamCdn()
extractor.domainUrl = "fembed-hd.com" extractor.domainUrl = "fembed-hd.com"
val src = extractor.getUrl(datavid, url) extractor.getUrl(datavid, url).forEach { link ->
src.forEach { link ->
callback.invoke(link) callback.invoke(link)
} }
} else { } else {
@ -201,17 +191,14 @@ class DramaSeeProvider : MainAPI() {
} else if (url.startsWith("https://embedsito.com")) { } else if (url.startsWith("https://embedsito.com")) {
val extractor = XStreamCdn() val extractor = XStreamCdn()
extractor.domainUrl = "embedsito.com" extractor.domainUrl = "embedsito.com"
val src = extractor.getUrl(url) extractor.getUrl(url).forEach { link ->
src.forEach { link ->
callback.invoke(link) callback.invoke(link)
} }
} else { } else {
loadExtractor(url, url, callback) loadExtractor(url, mainUrl, callback)
} // end if } // end if
} }
} }
return true return true
} }
return false
}
} }

View file

@ -1,25 +1,26 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import android.util.Log import android.util.Log
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
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.Jsoup import java.lang.Exception
class PinoyHDXyzProvider : MainAPI() { class PinoyHDXyzProvider : MainAPI() {
override val name = "Pinoy-HD" override val name = "Pinoy-HD"
override val mainUrl = "https://www.pinoy-hd.xyz" override val mainUrl = "https://www.pinoy-hd.xyz"
override val lang = "tl" override val lang = "tl"
override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries) override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries)
override val hasDownloadSupport = false override val hasDownloadSupport = true
override val hasMainPage = true override val hasMainPage = true
override val hasQuickSearch = false override val hasQuickSearch = false
override fun getMainPage(): HomePageResponse { override fun getMainPage(): HomePageResponse {
val all = ArrayList<HomePageList>() val all = ArrayList<HomePageList>()
val html = app.get(mainUrl, referer = mainUrl).text val document = app.get(mainUrl, referer = mainUrl).document
val document = Jsoup.parse(html)
val mainbody = document.getElementsByTag("body") val mainbody = document.getElementsByTag("body")
mainbody?.select("div.section-cotent.col-md-12.bordert")?.forEach { row -> mainbody?.select("div.section-cotent.col-md-12.bordert")?.forEach { row ->
@ -69,11 +70,12 @@ class PinoyHDXyzProvider : MainAPI() {
override fun search(query: String): List<SearchResponse> { override fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/search/?q=${query.replace(" ", "+")}" val url = "$mainUrl/search/?q=${query.replace(" ", "+")}"
val document = app.get(url).document.select("div.portfolio-thumb") val document = app.get(url).document.select("div.portfolio-thumb")
if (!document.isNullOrEmpty()) { return document?.mapNotNull {
return document.map { if (it == null) {
return@mapNotNull null
val link = it?.select("a")?.firstOrNull()?.attr("href") ?: "" }
val title = it?.text() ?: "" val link = it.selectFirst("a")?.attr("href") ?: return@mapNotNull null
val title = it.text() ?: ""
val year = null val year = null
val image = null // site provides no image on search page val image = null // site provides no image on search page
@ -85,16 +87,11 @@ class PinoyHDXyzProvider : MainAPI() {
image, image,
year year
) )
}.filter { a -> a.url.isNotEmpty() } }?.distinctBy { c -> c.url } ?: listOf()
.filter { b -> b.name.isNotEmpty() }
.distinctBy { c -> c.url }
}
return listOf()
} }
override fun load(url: String): LoadResponse { override fun load(url: String): LoadResponse {
val response = app.get(url).text val doc = app.get(url).document
val doc = Jsoup.parse(response)
val body = doc.getElementsByTag("body") val body = doc.getElementsByTag("body")
val inner = body?.select("div.info") val inner = body?.select("div.info")
@ -120,32 +117,44 @@ class PinoyHDXyzProvider : MainAPI() {
var descript = body?.select("div.eText")?.text() var descript = body?.select("div.eText")?.text()
if (!descript.isNullOrEmpty()) { if (!descript.isNullOrEmpty()) {
try {
descript = descript.substring(0, descript.indexOf("_x_Polus1")) descript = descript.substring(0, descript.indexOf("_x_Polus1"))
.replace("_x_Polus1", "") .replace("_x_Polus1", "")
} catch (e: java.lang.Exception) { }
} }
// Video links // Video links
val listOfLinks: MutableList<String> = mutableListOf() val listOfLinks: MutableList<String> = mutableListOf()
val linkMain = body?.select("div.tabcontent > iframe")?.attr("src") body?.select("div.tabcontent > iframe")?.forEach {
val linkMain = it?.attr("src")
if (!linkMain.isNullOrEmpty()) { if (!linkMain.isNullOrEmpty()) {
listOfLinks.add(linkMain) listOfLinks.add(linkMain)
//Log.i(this.name, "Result => (linkMain) $linkMain")
} }
}
body?.select("div.tabcontent.hide > iframe")?.forEach {
val linkMain = it?.attr("src")
if (!linkMain.isNullOrEmpty()) {
listOfLinks.add(linkMain)
//Log.i(this.name, "Result => (linkMain hide) $linkMain")
}
}
var extraLinks = body?.select("div.tabcontent.hide")?.text() var extraLinks = body?.select("div.tabcontent.hide")?.text()
if (!extraLinks.isNullOrEmpty()) { if (!extraLinks.isNullOrEmpty()) {
try {
extraLinks = extraLinks.substring(extraLinks.indexOf("_x_Polus1")) extraLinks = extraLinks.substring(extraLinks.indexOf("_x_Polus1"))
extraLinks = extraLinks.trim().substring("_x_Polus1".length) extraLinks = extraLinks.trim().substring("_x_Polus1".length)
extraLinks = extraLinks.substring(0, extraLinks.indexOf("<script>")) extraLinks = extraLinks.substring(0, extraLinks.indexOf("<script>"))
val lnks = extraLinks.split("_x_Polus") extraLinks.split("_x_Polus").forEach { item ->
//Log.i(this.name, "Result => (lnks) ${lnks}")
for (item in lnks) {
if (item.contains("https://")) { if (item.contains("https://")) {
val lnkurl = item.substring(item.indexOf("https://")).trim() val lnkurl = item.substring(item.indexOf("https://")).trim()
listOfLinks.add(lnkurl) listOfLinks.add(lnkurl)
//Log.i(this.name, "Result => (lnkurl) $lnkurl")
} }
} }
} catch (e: Exception) { }
} }
val streamlinks = listOfLinks.toString()
//Log.i(this.name, "Result => (streamlinks) ${streamlinks}")
// Parse episodes if series // Parse episodes if series
if (tvtype == TvType.TvSeries) { if (tvtype == TvType.TvSeries) {
@ -160,20 +169,17 @@ class PinoyHDXyzProvider : MainAPI() {
epListText = epListText.substring(indexStart.length, epListText.indexOf(")")) epListText = epListText.substring(indexStart.length, epListText.indexOf(")"))
.trim().trim('\'') .trim().trim('\'')
//Log.i(this.name, "Result => (epListText) ${epListText}") //Log.i(this.name, "Result => (epListText) ${epListText}")
val epList = epListText.split(',')
//Log.i(this.name, "Result => (epLinks) ${epLinks}")
if (!epList.isNullOrEmpty()) {
var count = 0 var count = 0
epList.forEach { ep -> epListText.split(',').forEach { ep ->
count++ count++
val epTitle = " Episode $count" val listEpStream = listOf(ep.trim()).toJson()
//Log.i(this.name, "Result => (epLinks href) ${href}") //Log.i(this.name, "Result => (ep $count) $listEpStream")
episodeList.add( episodeList.add(
TvSeriesEpisode( TvSeriesEpisode(
name = name + epTitle, name = null,
season = null, season = null,
episode = count, episode = count,
data = ep.trim(), data = listEpStream,
posterUrl = poster, posterUrl = poster,
date = null date = null
) )
@ -195,8 +201,8 @@ class PinoyHDXyzProvider : MainAPI() {
} }
} }
} }
} val streamLinks = listOfLinks.distinct().toJson()
return MovieLoadResponse(title, url, this.name, tvtype, streamlinks, poster, year, descript, null, null) return MovieLoadResponse(title, url, this.name, tvtype, streamLinks, poster, year, descript, null, null)
} }
override fun loadLinks( override fun loadLinks(
@ -205,19 +211,16 @@ class PinoyHDXyzProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
if (data == "about:blank") return false
if (data.isEmpty()) return false if (data.isEmpty()) return false
try { if (data == "about:blank") return false
data.trim('[').trim(']').split(',').map { item -> if (data == "[]") return false
mapper.readValue<List<String>>(data).forEach { item ->
if (item.isNotEmpty()) { if (item.isNotEmpty()) {
val url = item.trim() val url = item.trim()
loadExtractor(url, url, callback) loadExtractor(url, mainUrl, callback)
} }
} }
} catch (e: Exception) { return true
e.printStackTrace()
Log.i(this.name, "Result => (e) $e")
}
return false
} }
} }

View file

@ -1,11 +1,12 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import android.util.Log import android.util.Log
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.extractors.FEmbed import com.lagradost.cloudstream3.extractors.FEmbed
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.Jsoup
import java.lang.Exception import java.lang.Exception
class PinoyMoviePediaProvider : MainAPI() { class PinoyMoviePediaProvider : MainAPI() {
@ -19,8 +20,7 @@ class PinoyMoviePediaProvider : MainAPI() {
override fun getMainPage(): HomePageResponse { override fun getMainPage(): HomePageResponse {
val all = ArrayList<HomePageList>() val all = ArrayList<HomePageList>()
val html = app.get(mainUrl).text val document = app.get(mainUrl).document
val document = Jsoup.parse(html)
val mainbody = document.getElementsByTag("body") val mainbody = document.getElementsByTag("body")
// All rows will be hardcoded bc of the nature of the site // All rows will be hardcoded bc of the nature of the site
val rows: List<Pair<String, String>> = listOf( val rows: List<Pair<String, String>> = listOf(
@ -33,21 +33,25 @@ class PinoyMoviePediaProvider : MainAPI() {
Pair("Family", "genre_family") Pair("Family", "genre_family")
//Pair("Adult +18", "genre_pinay-sexy-movies") //Pair("Adult +18", "genre_pinay-sexy-movies")
) )
for (item in rows) { rows.forEach { item ->
val title = item.first val title = item.first
val inner = mainbody?.select("div#${item.second} > article") val inner = mainbody?.select("div#${item.second} > article")
if (inner != null) {
val elements: List<SearchResponse> = inner.map { val elements: List<SearchResponse> = inner?.mapNotNull {
if (it == null) {
return@mapNotNull null
}
// Get inner div from article // Get inner div from article
val urlTitle = it?.select("div.data") val urlTitle = it.select("div.data") ?: return@mapNotNull null
// Fetch details // Fetch details
val link = urlTitle?.select("a")?.attr("href") ?: "" val link = fixUrlNull(urlTitle.select("a")?.attr("href")) ?: return@mapNotNull null
val name = urlTitle?.text() ?: "" val name = urlTitle.text() ?: ""
val image = it?.select("div.poster > img")?.attr("src") val image = it.select("div.poster > img")?.attr("src")
// Get Year from Title // Get Year from Title
val year = try {
val rex = Regex("\\((\\d+)") val rex = Regex("\\((\\d+)")
val yearRes = rex.find(name)?.value ?: "" rex.find(name)?.value?.replace("(", "")?.toIntOrNull()
val year = yearRes.replace("(", "").toIntOrNull() } catch (e: Exception) { null }
val tvType = TvType.Movie val tvType = TvType.Movie
MovieSearchResponse( MovieSearchResponse(
@ -59,9 +63,7 @@ class PinoyMoviePediaProvider : MainAPI() {
year, year,
null, null,
) )
}.filter { a -> a.url.isNotEmpty() } }?.distinctBy { c -> c.url } ?: listOf()
.filter { b -> b.name.isNotEmpty() }
.distinctBy { c -> c.url }
// Add // Add
all.add( all.add(
HomePageList( HomePageList(
@ -69,27 +71,21 @@ class PinoyMoviePediaProvider : MainAPI() {
) )
) )
} }
} return HomePageResponse(all.filter { a -> a.list.isNotEmpty() })
return HomePageResponse(all)
} }
override fun search(query: String): List<SearchResponse> { override fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/?s=${query}" val url = "$mainUrl/?s=${query}"
val html = app.get(url).text val document = app.get(url).document.selectFirst("div.search-page")
val document = Jsoup.parse(html).select("div.search-page")?.firstOrNull()
?.select("div.result-item") ?.select("div.result-item")
if (document != null) {
return document.map {
val inner = it.select("article")
val details = inner.select("div.details")
val href = details?.select("div.title > a")?.attr("href") ?: ""
val title = details?.select("div.title")?.text() ?: "" return document?.mapNotNull {
val link: String = when (href != "") { val inner = it.select("article") ?: return@mapNotNull null
true -> fixUrl(href) val details = inner.select("div.details") ?: return@mapNotNull null
false -> "" val link = fixUrlNull(details.select("div.title > a")?.attr("href")) ?: return@mapNotNull null
}
val year = details?.select("div.meta > span.year")?.text()?.toIntOrNull() val title = details.select("div.title")?.text() ?: ""
val year = details.select("div.meta > span.year")?.text()?.toIntOrNull()
val image = inner.select("div.image > div > a > img")?.attr("src") val image = inner.select("div.image > div > a > img")?.attr("src")
MovieSearchResponse( MovieSearchResponse(
@ -100,20 +96,15 @@ class PinoyMoviePediaProvider : MainAPI() {
image, image,
year year
) )
}.filter { a -> a.url.isNotEmpty() } }?.distinctBy { c -> c.url } ?: listOf()
.filter { b -> b.name.isNotEmpty() }
.distinctBy { c -> c.url }
}
return listOf()
} }
override fun load(url: String): LoadResponse { override fun load(url: String): LoadResponse {
val response = app.get(url).text val doc = app.get(url).document
val doc = Jsoup.parse(response)
val body = doc.getElementsByTag("body") val body = doc.getElementsByTag("body")
val inner = body?.select("div.sheader") val inner = body?.select("div.sheader")
// Identify if movie or series // Identify if movie or series
val isTvSeries = doc?.select("title")?.text()?.lowercase()?.contains("full episode -") ?: false val isTvSeries = doc.select("title")?.text()?.lowercase()?.contains("full episode -") ?: false
// Video details // Video details
val poster = inner?.select("div.poster > img")?.attr("src") val poster = inner?.select("div.poster > img")?.attr("src")
@ -125,37 +116,41 @@ class PinoyMoviePediaProvider : MainAPI() {
val year = yearRes.replace("(", "").toIntOrNull() val year = yearRes.replace("(", "").toIntOrNull()
// Video links // Video links
val linksContainer = body?.select("div#playcontainer") val playcontainer = body?.select("div#playcontainer")
val streamlinks = linksContainer?.toString() ?: "" val listOfLinks: MutableList<String> = mutableListOf()
//Log.i(this.name, "Result => (streamlinks) ${streamlinks}") playcontainer?.select("iframe")?.forEach { item ->
val lnk = item?.attr("src")?.trim()
//Log.i(this.name, "Result => (lnk) $lnk")
if (!lnk.isNullOrEmpty()) {
listOfLinks.add(lnk)
}
}
// Parse episodes if series // Parse episodes if series
if (isTvSeries) { if (isTvSeries) {
val episodeList = ArrayList<TvSeriesEpisode>() val episodeList = ArrayList<TvSeriesEpisode>()
val epList = body?.select("div#playeroptions > ul > li") val epLinks = playcontainer?.select("div > div > div.source-box")
//Log.i(this.name, "Result => (epList) ${epList}") //Log.i(this.name, "Result => (epList) ${epList}")
val epLinks = linksContainer?.select("div > div > div.source-box") body?.select("div#playeroptions > ul > li")?.forEach { ep ->
//Log.i(this.name, "Result => (epLinks) ${epLinks}") val epTitle = ep.select("span.title")?.text()
if (epList != null) { if (!epTitle.isNullOrEmpty()) {
for (ep in epList) {
val epTitle = ep.select("span.title")?.text() ?: ""
if (epTitle.isNotEmpty()) {
val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull() val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull()
//Log.i(this.name, "Result => (epNum) ${epNum}") //Log.i(this.name, "Result => (epNum) ${epNum}")
val href = when (epNum != null && epLinks != null) { val href = when (epNum != null && !epLinks.isNullOrEmpty()) {
true -> epLinks.select("div#source-player-${epNum}") true -> epLinks.select("div#source-player-$epNum")
?.select("iframe")?.attr("src") ?: "" ?.select("iframe")?.attr("src") ?: ""
false -> "" false -> ""
} }
//Log.i(this.name, "Result => (epLinks href) ${href}") val streamEpLink = listOf(href.trim()).toJson()
//Log.i(this.name, "Result => (streamEpLink $epNum) $streamEpLink")
episodeList.add( episodeList.add(
TvSeriesEpisode( TvSeriesEpisode(
"Episode $epNum", name = null,
null, season = null,
epNum, episode = epNum,
href, data = streamEpLink,
poster, posterUrl = poster,
null date = null
) )
) )
} }
@ -174,7 +169,7 @@ class PinoyMoviePediaProvider : MainAPI() {
null null
) )
} }
} val streamlinks = listOfLinks.distinct().toJson()
return MovieLoadResponse(title, url, this.name, TvType.Movie, streamlinks, poster, year, descript, null, null) return MovieLoadResponse(title, url, this.name, TvType.Movie, streamlinks, poster, year, descript, null, null)
} }
@ -184,42 +179,22 @@ class PinoyMoviePediaProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
if (data == "about:blank") return false
if (data.isEmpty()) return false if (data.isEmpty()) return false
val sources = mutableListOf<ExtractorLink>() if (data == "[]") return false
if (data == "about:blank") return false
// parse movie servers // parse movie servers
if (data.contains("playcontainer")) { mapper.readValue<List<String>>(data).forEach { link ->
Jsoup.parse(data).select("div")?.map { item -> if (link.contains("fembed.com")) {
val url = item.select("iframe")?.attr("src")
if (!url.isNullOrEmpty()) {
//Log.i(this.name, "Result => (url) ${url}")
loadExtractor(url, url, callback)
}
}
} else {
// parse single link
try {
if (data.contains("fembed.com")) {
val extractor = FEmbed() val extractor = FEmbed()
extractor.domainUrl = "diasfem.com" extractor.domainUrl = "diasfem.com"
val src = extractor.getUrl(data) extractor.getUrl(data).forEach {
if (src.isNotEmpty()) { callback.invoke(it)
sources.addAll(src) }
} else {
loadExtractor(link, mainUrl, callback)
} }
} }
} catch (e: Exception) {
Log.i(this.name, "Result => (exception) $e")
}
}
// Invoke sources
if (sources.isNotEmpty()) {
for (source in sources) {
callback.invoke(source)
//Log.i(this.name, "Result => (source) ${source.url}")
return true return true
} }
}
return false
}
} }