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()) {
links.forEach {
val datavid = it.attr("data-video") ?: ""
//Log.i(this.name, "Result => (datavid) ${datavid}")
if (datavid.isNotEmpty()) {
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 { url.startsWith("https://embedsito.com") -> {
loadExtractor(datavid, url, callback)
}
}
}
}
} else if (url.startsWith("https://embedsito.com")) {
val extractor = XStreamCdn() val extractor = XStreamCdn()
extractor.domainUrl = "embedsito.com" extractor.domainUrl = "embedsito.com"
extractor.getUrl(url).forEach { link -> extractor.getUrl(url).forEach { link ->
callback.invoke(link) callback.invoke(link)
} }
} else { }
else -> {
loadExtractor(url, mainUrl, callback) 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()) {
links.forEach {
val datavid = it.attr("data-video") ?: ""
//Log.i(this.name, "Result => (datavid) ${datavid}")
if (datavid.isNotEmpty()) {
loadExtractor(datavid, url, callback)
} }
} 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"
extractor.getUrl(url).forEach { link -> extractor.getUrl(url).forEach { link ->
callback.invoke(link) callback.invoke(link)
} }
} else { }
else -> {
loadExtractor(url, mainUrl, callback) 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,19 +94,17 @@ 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,
@ -110,18 +114,13 @@ class PinoyMoviesEsProvider : MainAPI() {
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 epTitle = ep.select("span.title")?.text() ?: ""
if (epTitle.isNotEmpty()) {
val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull()
//Log.i(this.name, "Result => (epNum) ${epNum}")
val href = when (epNum != null && epLinks != null) {
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()
)
) )
val innerPage = app.post("https://pinoymovies.es/wp-admin/admin-ajax.php ",
referer = url, data = content).document.select("body")?.text()?.trim()
if (!innerPage.isNullOrEmpty()) {
val embedData = mapper.readValue<EmbedUrl>(innerPage)
//Log.i(this.name, "Result => (embed_url) ${embedData.embed_url}")
listOfLinks.add(embedData.embed_url)
} }
} }
return TvSeriesLoadResponse( return MovieLoadResponse(title, url, this.name, TvType.Movie, listOfLinks.toJson(), poster, year, descript, null, null)
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)
} }
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>()
try {
if (data.contains("playcontainer")) {
// parse movie servers // parse movie servers
//Log.i(this.name, "Result => (data) ${data}") var count = 0
Jsoup.parse(data).select("div")?.map { item -> mapper.readValue<List<String>>(data).forEach { link ->
val url = item.select("iframe")?.attr("src") count++
if (!url.isNullOrEmpty()) { //Log.i(this.name, "Result => (link) $link")
//Log.i(this.name, "Result => (url) ${url}") if (link.startsWith("https://vstreamhub.com")) {
loadExtractor(url, url, callback) VstreamhubHelper.getUrls(link, callback)
} } else if (link.contains("fembed.com")) {
}
} else {
// parse single link
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)
} }
} }
} return count > 0
// 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
} }
} }

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 ->
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")) {
// 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 {