fix: multiple providers with reversed episode list. (#498)

load links for PinoyMoviesEsprovider.
abstracted asianembed helper for multiple providers.
This commit is contained in:
Jace 2022-01-22 22:14:47 +08:00 committed by GitHub
parent d4637a3a26
commit f8ac139b67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 194 additions and 172 deletions

View file

@ -0,0 +1,28 @@
package com.lagradost.cloudstream3.extractors.helper
import android.util.Log
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
class AsianEmbedHelper {
companion object {
fun getUrls(url: String, callback: (ExtractorLink) -> Unit) {
if (url.startsWith("https://asianembed.io")) {
// Fetch links
val doc = app.get(url).document
val links = doc.select("div#list-server-more > ul > li.linkserver")
if (!links.isNullOrEmpty()) {
links.forEach {
val datavid = it.attr("data-video") ?: ""
//Log.i("AsianEmbed", "Result => (datavid) ${datavid}")
if (datavid.isNotEmpty()) {
val res = loadExtractor(datavid, url, callback)
Log.i("AsianEmbed", "Result => ($res) (datavid) ${datavid}")
}
}
}
}
}
}
}

View file

@ -0,0 +1,51 @@
package com.lagradost.cloudstream3.extractors.helper
import android.util.Log
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.loadExtractor
class VstreamhubHelper {
companion object {
private val baseUrl: String = "https://vstreamhub.com"
private val baseName: String = "Vstreamhub"
fun getUrls(url: String, callback: (ExtractorLink) -> Unit) {
if (url.startsWith(baseUrl)) {
// Fetch links
val doc = app.get(url).document.select("script")
doc?.forEach {
val innerText = it?.toString()
if (!innerText.isNullOrEmpty()) {
if (innerText.contains("file:")) {
val startString = "file: "
val aa = innerText.substring(innerText.indexOf(startString))
val linkUrl = aa.substring(startString.length + 1, aa.indexOf("\",")).trim()
//Log.i(baseName, "Result => (linkUrl) ${linkUrl}")
val exlink = ExtractorLink(
name = "$baseName m3u8",
source = baseName,
url = linkUrl,
quality = Qualities.Unknown.value,
referer = url,
isM3u8 = true
)
callback.invoke(exlink)
}
if (innerText.contains("playerInstance")) {
val aa = innerText.substring(innerText.indexOf("playerInstance.addButton"))
val startString = "window.open(["
val bb = aa.substring(aa.indexOf(startString))
val datavid = bb.substring(startString.length, bb.indexOf("]")).removeSurrounding("\"")
if (datavid.isNotEmpty()) {
loadExtractor(datavid, url, callback)
//Log.i(baseName, "Result => (datavid) ${datavid}")
}
}
}
}
}
}
}
}

View file

@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.module.kotlin.readValue 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.extractors.helper.AsianEmbedHelper
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
@ -139,7 +140,7 @@ class DramaSeeProvider : MainAPI() {
url, url,
this.name, this.name,
TvType.TvSeries, TvType.TvSeries,
episodeList, episodeList.reversed(),
poster, poster,
year, year,
descript, descript,
@ -155,45 +156,32 @@ class DramaSeeProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
var count = 0
mapper.readValue<List<String>>(data).forEach { item -> mapper.readValue<List<String>>(data).forEach { item ->
if (item.isNotEmpty()) { if (item.isNotEmpty()) {
count++
var url = item.trim() var url = item.trim()
if (url.startsWith("//")) { if (url.startsWith("//")) {
url = "https:$url" url = "https:$url"
} }
//Log.i(this.name, "Result => (url) ${url}") //Log.i(this.name, "Result => (url) ${url}")
if (url.startsWith("https://asianembed.io")) { when {
// Fetch links url.startsWith("https://asianembed.io") -> {
val doc = app.get(url).document AsianEmbedHelper.getUrls(url, callback)
val links = doc.select("div#list-server-more > ul > li.linkserver") }
if (!links.isNullOrEmpty()) { url.startsWith("https://embedsito.com") -> {
links.forEach { val extractor = XStreamCdn()
val datavid = it.attr("data-video") ?: "" extractor.domainUrl = "embedsito.com"
//Log.i(this.name, "Result => (datavid) ${datavid}") extractor.getUrl(url).forEach { link ->
if (datavid.isNotEmpty()) { callback.invoke(link)
if (datavid.startsWith("https://fembed-hd.com")) {
val extractor = XStreamCdn()
extractor.domainUrl = "fembed-hd.com"
extractor.getUrl(datavid, url).forEach { link ->
callback.invoke(link)
}
} else {
loadExtractor(datavid, url, callback)
}
}
} }
} }
} else if (url.startsWith("https://embedsito.com")) { else -> {
val extractor = XStreamCdn() loadExtractor(url, mainUrl, callback)
extractor.domainUrl = "embedsito.com"
extractor.getUrl(url).forEach { link ->
callback.invoke(link)
} }
} else { }
loadExtractor(url, mainUrl, callback)
} // end if
} }
} }
return true return count > 0
} }
} }

View file

@ -4,6 +4,7 @@ import android.util.Log
import com.fasterxml.jackson.module.kotlin.readValue 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.extractors.helper.AsianEmbedHelper
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
@ -170,7 +171,7 @@ class KdramaHoodProvider : MainAPI() {
url, url,
this.name, this.name,
TvType.TvSeries, TvType.TvSeries,
episodeList, episodeList.reversed(),
poster, poster,
year, year,
descript, descript,
@ -195,28 +196,21 @@ class KdramaHoodProvider : MainAPI() {
url = "https:$url" url = "https:$url"
} }
//Log.i(this.name, "Result => (url) ${url}") //Log.i(this.name, "Result => (url) ${url}")
if (url.startsWith("https://asianembed.io")) { when {
// Fetch links url.startsWith("https://asianembed.io") -> {
val doc = app.get(url).document AsianEmbedHelper.getUrls(url, callback)
val links = doc.select("div#list-server-more > ul > li.linkserver") }
if (!links.isNullOrEmpty()) { url.startsWith("https://embedsito.com") -> {
links.forEach { val extractor = XStreamCdn()
val datavid = it.attr("data-video") ?: "" extractor.domainUrl = "embedsito.com"
//Log.i(this.name, "Result => (datavid) ${datavid}") extractor.getUrl(url).forEach { link ->
if (datavid.isNotEmpty()) { callback.invoke(link)
loadExtractor(datavid, url, callback)
}
} }
} }
} else if (url.startsWith("https://embedsito.com")) { else -> {
val extractor = XStreamCdn() loadExtractor(url, mainUrl, callback)
extractor.domainUrl = "embedsito.com"
extractor.getUrl(url).forEach { link ->
callback.invoke(link)
} }
} else { }
loadExtractor(url, mainUrl, callback)
} // end if
} }
} }
return count > 0 return count > 0

View file

@ -178,7 +178,9 @@ class PinoyMoviePediaProvider : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
// parse movie servers // parse movie servers
var count = 0
mapper.readValue<List<String>>(data).forEach { link -> mapper.readValue<List<String>>(data).forEach { link ->
count++
if (link.contains("fembed.com")) { if (link.contains("fembed.com")) {
val extractor = FEmbed() val extractor = FEmbed()
extractor.domainUrl = "diasfem.com" extractor.domainUrl = "diasfem.com"
@ -189,6 +191,6 @@ class PinoyMoviePediaProvider : MainAPI() {
loadExtractor(link, mainUrl, callback) loadExtractor(link, mainUrl, callback)
} }
} }
return true return count > 0
} }
} }

View file

@ -1,23 +1,30 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import android.util.Log import com.fasterxml.jackson.annotation.JsonProperty
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.extractors.helper.VstreamhubHelper
import com.lagradost.cloudstream3.network.DdosGuardKiller import com.lagradost.cloudstream3.network.DdosGuardKiller
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 org.jsoup.select.Elements import org.jsoup.select.Elements
class PinoyMoviesEsProvider : MainAPI() { class PinoyMoviesEsProvider : MainAPI() {
override val name = "Pinoy Movies" override val name = "Pinoy Movies"
override val mainUrl = "https://pinoymovies.es/" override val mainUrl = "https://pinoymovies.es"
override val lang = "tl" override val lang = "tl"
override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries) override val supportedTypes = setOf(TvType.Movie)
override val hasDownloadSupport = false override val hasDownloadSupport = false
override val hasMainPage = true override val hasMainPage = true
override val hasQuickSearch = false override val hasQuickSearch = false
data class EmbedUrl(
@JsonProperty("embed_url") val embed_url: String,
@JsonProperty("type") val type: String
)
private fun getRowElements(mainbody: Elements, rows: List<Pair<String, String>>, sep: String): MutableList<HomePageList> { private fun getRowElements(mainbody: Elements, rows: List<Pair<String, String>>, sep: String): MutableList<HomePageList> {
val all = mutableListOf<HomePageList>() val all = mutableListOf<HomePageList>()
for (item in rows) { for (item in rows) {
@ -60,8 +67,7 @@ class PinoyMoviesEsProvider : MainAPI() {
} }
override suspend fun getMainPage(): HomePageResponse { override suspend 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")
if (mainbody != null) { if (mainbody != null) {
// All rows will be hardcoded bc of the nature of the site // All rows will be hardcoded bc of the nature of the site
@ -88,40 +94,33 @@ class PinoyMoviesEsProvider : MainAPI() {
} }
override suspend fun search(query: String): List<SearchResponse> { override suspend fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/?s=${query}" val url = "$mainUrl/?s=${query.replace(" ", "+")}"
val html = app.get(url, interceptor = DdosGuardKiller(true)).text val document = app.get(url, interceptor = DdosGuardKiller(true))
//Log.i(this.name, "Result => (html) ${Jsoup.parse(html).getElementsByTag("body")}") .document.select("div#archive-content > article")
val document = Jsoup.parse(html).select("div#archive-content > article")
if (document != null) {
return document.map {
val urlTitle = it?.select("div.data")
// Fetch details
val link = urlTitle?.select("a")?.attr("href") ?: ""
val title = urlTitle?.text() ?: "<No Title>"
val year = urlTitle?.select("span.year")?.text()?.toIntOrNull()
val image = it?.select("div.poster > img")?.attr("src") return document?.mapNotNull {
val urlTitle = it?.select("div.data") ?: return@mapNotNull null
// Fetch details
val link = urlTitle.select("a")?.attr("href") ?: return@mapNotNull null
val title = urlTitle.text() ?: "<No Title>"
val year = urlTitle.select("span.year")?.text()?.toIntOrNull()
val image = it.select("div.poster > img")?.attr("src")
MovieSearchResponse( MovieSearchResponse(
title, title,
link, link,
this.name, this.name,
TvType.Movie, TvType.Movie,
image, image,
year year
) )
} }?.distinctBy { it.url } ?: listOf()
}
return listOf()
} }
override suspend fun load(url: String): LoadResponse { override suspend 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
val isTvSeries = doc?.select("title")?.text()?.lowercase()?.contains("full episode -") ?: false
// Video details // Video details
val data = inner?.select("div.sheader > div.data") val data = inner?.select("div.sheader > div.data")
@ -132,57 +131,28 @@ class PinoyMoviesEsProvider : MainAPI() {
val poster = body?.select("div.poster > img")?.attr("src") val poster = body?.select("div.poster > img")?.attr("src")
// Video links // Video links
val linksContainer = body?.select("div#playcontainer") val listOfLinks: MutableList<String> = mutableListOf()
val streamlinks = linksContainer?.toString() ?: "" val postlist = body?.select("div#playeroptions > ul > li")?.mapNotNull {
//Log.i(this.name, "Result => (streamlinks) ${streamlinks}") it?.attr("data-post") ?: return@mapNotNull null
}?.filter { it.isNotEmpty() }?.distinct() ?: listOf()
// Parse episodes if series postlist.forEach { datapost ->
if (isTvSeries) { //Log.i(this.name, "Result => (datapost) ${datapost}")
val episodeList = ArrayList<TvSeriesEpisode>() val content = mapOf(
val epList = body?.select("div#playeroptions > ul > li") Pair("action", "doo_player_ajax"),
//Log.i(this.name, "Result => (epList) ${epList}") Pair("post", datapost),
val epLinks = linksContainer?.select("div > div > div.source-box") Pair("nume", "1"),
//Log.i(this.name, "Result => (epLinks) ${epLinks}") Pair("type", "movie")
if (epList != null) { )
for (ep in epList) { val innerPage = app.post("https://pinoymovies.es/wp-admin/admin-ajax.php ",
val epTitle = ep.select("span.title")?.text() ?: "" referer = url, data = content).document.select("body")?.text()?.trim()
if (epTitle.isNotEmpty()) { if (!innerPage.isNullOrEmpty()) {
val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull() val embedData = mapper.readValue<EmbedUrl>(innerPage)
//Log.i(this.name, "Result => (epNum) ${epNum}") //Log.i(this.name, "Result => (embed_url) ${embedData.embed_url}")
val href = when (epNum != null && epLinks != null) { listOfLinks.add(embedData.embed_url)
true -> epLinks.select("div#source-player-${epNum}")
?.select("iframe")?.attr("src") ?: ""
false -> ""
}
//Log.i(this.name, "Result => (epLinks href) ${href}")
episodeList.add(
TvSeriesEpisode(
name = name,
season = null,
episode = epNum,
data = href,
posterUrl = poster,
date = year.toString()
)
)
}
}
return TvSeriesLoadResponse(
title,
url,
this.name,
TvType.TvSeries,
episodeList,
poster,
year,
descript,
null,
null,
null
)
} }
} }
return MovieLoadResponse(title, url, this.name, TvType.Movie, streamlinks, poster, year, descript, null, null) return MovieLoadResponse(title, url, this.name, TvType.Movie, listOfLinks.toJson(), poster, year, descript, null, null)
} }
override suspend fun loadLinks( override suspend fun loadLinks(
@ -191,41 +161,23 @@ class PinoyMoviesEsProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val sources = mutableListOf<ExtractorLink>() // parse movie servers
try { var count = 0
if (data.contains("playcontainer")) { mapper.readValue<List<String>>(data).forEach { link ->
// parse movie servers count++
//Log.i(this.name, "Result => (data) ${data}") //Log.i(this.name, "Result => (link) $link")
Jsoup.parse(data).select("div")?.map { item -> if (link.startsWith("https://vstreamhub.com")) {
val url = item.select("iframe")?.attr("src") VstreamhubHelper.getUrls(link, callback)
if (!url.isNullOrEmpty()) { } else if (link.contains("fembed.com")) {
//Log.i(this.name, "Result => (url) ${url}") val extractor = FEmbed()
loadExtractor(url, url, callback) extractor.domainUrl = "diasfem.com"
} extractor.getUrl(data).forEach {
callback.invoke(it)
} }
} else { } else {
// parse single link loadExtractor(link, mainUrl, callback)
if (data.contains("fembed.com")) {
val extractor = FEmbed()
extractor.domainUrl = "diasfem.com"
val src = extractor.getUrl(data)
if (src.isNotEmpty()) {
sources.addAll(src)
}
}
} }
// Invoke sources
if (sources.isNotEmpty()) {
for (source in sources) {
callback.invoke(source)
//Log.i(this.name, "Result => (source) ${source.url}")
}
return true
}
} catch (e: Exception) {
e.printStackTrace()
Log.i(this.name, "Result => (e) ${e}")
} }
return false return count > 0
} }
} }

View file

@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.module.kotlin.readValue 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.extractors.helper.AsianEmbedHelper
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
@ -153,7 +154,7 @@ class WatchAsianProvider : MainAPI() {
url, url,
this.name, this.name,
TvType.TvSeries, TvType.TvSeries,
episodeList, episodeList.reversed(),
poster, poster,
year, year,
descript, descript,
@ -172,16 +173,22 @@ class WatchAsianProvider : MainAPI() {
val links = if (data.startsWith(mainUrl)) { val links = if (data.startsWith(mainUrl)) {
getServerLinks(data) getServerLinks(data)
} else { data } } else { data }
mapper.readValue<List<String>>(links) var count = 0
.forEach { item -> mapper.readValue<List<String>>(links).forEach { item ->
var url = item.trim() count++
if (url.startsWith("//")) { var url = item.trim()
url = "https:$url" if (url.startsWith("//")) {
} url = "https:$url"
//Log.i(this.name, "Result => (url) $url") }
//Log.i(this.name, "Result => (url) $url")
if (url.startsWith("https://asianembed.io")) {
// Fetch links
AsianEmbedHelper.getUrls(url, callback)
} else {
loadExtractor(url, mainUrl, callback) loadExtractor(url, mainUrl, callback)
} }
return true }
return count > 0
} }
private fun getServerLinks(url: String) : String { private fun getServerLinks(url: String) : String {