Fix dependencies on other plugins causing errors

This commit is contained in:
Blatzar 2022-08-11 01:05:19 +02:00
parent 62f5d8258f
commit b74b8614db
62 changed files with 94 additions and 488 deletions

View file

@ -0,0 +1,22 @@
// use an integer for version numbers
version = 1
cloudstream {
// All of these properties are optional, you can safely remove them
description = "Includes PinoyMoviePediaProvider and PinoyMoviesEsProvider"
// authors = listOf("Cloudburst")
/**
* Status int as the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta only
* */
status = 1 // will be 3 if unspecified
// Set to true to get an 18+ symbol next to the plugin
adult = false // will be false if unspecified
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lagradost"/>

View file

@ -0,0 +1,238 @@
package com.lagradost
import com.lagradost.cloudstream3.*
//import com.lagradost.cloudstream3.extractors.FEmbed
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
class PinoyMoviePediaProvider : MainAPI() {
override var name = "Pinoy Moviepedia"
override var mainUrl = "https://pinoymoviepedia.ru"
override var lang = "tl"
override val supportedTypes = setOf(TvType.AsianDrama)
override val hasDownloadSupport = true
override val hasMainPage = true
override val hasQuickSearch = false
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
val all = ArrayList<HomePageList>()
val document = app.get(mainUrl).document
val mainbody = document.getElementsByTag("body")
// All rows will be hardcoded bc of the nature of the site
val rows: List<Pair<String, String>> = listOf(
Pair("Latest Movies", "featured-titles"),
Pair("Movies", "dt-movies"),
Pair("Digitally Restored", "genre_digitally-restored"),
Pair("Action", "genre_action"),
Pair("Romance", "genre_romance"),
Pair("Comedy", "genre_comedy"),
Pair("Family", "genre_family")
//Pair("Adult +18", "genre_pinay-sexy-movies")
)
rows.forEach { item ->
val title = item.first
val inner = mainbody?.select("div#${item.second} > article")
val elements: List<SearchResponse> = inner?.mapNotNull {
if (it == null) { return@mapNotNull null }
// Get inner div from article
val urlTitle = it.select("div.data") ?: return@mapNotNull null
// Fetch details
val link = fixUrlNull(urlTitle.select("a")?.attr("href")) ?: return@mapNotNull null
val image = it.select("div.poster > img")?.attr("src")
// Get Title and Year
val titleYear = it.select("div.data.dfeatur")
var name = titleYear?.select("h3")?.text() ?: ""
var year = titleYear?.select("span")?.text()?.toIntOrNull()
if (name.isEmpty()) {
name = urlTitle.select("h3")?.text() ?: ""
year = titleYear?.select("span")?.text()?.takeLast(4)?.toIntOrNull()
}
// Get year from name
if (year == null) {
val rex = Regex("\\((\\d+)")
year = rex.find(name)?.value?.replace("(", "")?.toIntOrNull()
}
//Get quality
val qual = getQualityFromString(it.selectFirst("span.quality")?.text())
MovieSearchResponse(
name = name,
url = link,
apiName = this.name,
TvType.Movie,
posterUrl = image,
year = year,
quality = qual
)
}?.distinctBy { c -> c.url } ?: listOf()
// Add
all.add(
HomePageList(
title, elements
)
)
}
return HomePageResponse(all.filter { a -> a.list.isNotEmpty() })
}
override suspend fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/?s=${query}"
val document = app.get(url).document.selectFirst("div.search-page")
?.select("div.result-item")
return document?.mapNotNull {
val inner = it.select("article") ?: return@mapNotNull null
val details = inner.select("div.details") ?: return@mapNotNull null
val link = fixUrlNull(details.select("div.title > a")?.attr("href")) ?: return@mapNotNull null
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 qual = getQualityFromString(it.selectFirst("span.quality")?.text())
MovieSearchResponse(
name = title,
url = link,
apiName = this.name,
TvType.Movie,
posterUrl = image,
year = year,
quality = qual
)
}?.distinctBy { c -> c.url } ?: listOf()
}
override suspend fun load(url: String): LoadResponse {
val doc = app.get(url).document
val body = doc.getElementsByTag("body")
val inner = body?.select("div.sheader")
// Identify if movie or series
val isTvSeries = doc.select("title")?.text()?.lowercase()?.contains("full episode -") ?: false
// Video details
val data = inner?.select("div.data")
val poster = inner?.select("div.poster > img")?.attr("src")
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}")
val year = yearRes.replace("(", "").toIntOrNull()
val tags = data?.select("div.sgeneros > a")?.mapNotNull { tag ->
tag?.text()?.trim() ?: return@mapNotNull null
}?.toList()
val recList = body?.select("div#single_relacionados > article")?.mapNotNull {
val a = it.select("a") ?: return@mapNotNull null
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 = try {
aName.trim().takeLast(5).removeSuffix(")").toIntOrNull()
} catch (e: Exception) { null }
MovieSearchResponse(
url = aUrl,
name = aName,
type = TvType.Movie,
posterUrl = aImg,
year = aYear,
apiName = this.name
)
}
// Video links
val playcontainer = body?.select("div#playcontainer")
val listOfLinks: MutableList<String> = mutableListOf()
playcontainer?.select("iframe")?.forEach { item ->
val lnk = item?.attr("src")?.trim() ?: ""
//Log.i(this.name, "Result => (lnk) $lnk")
if (lnk.isNotEmpty()) {
listOfLinks.add(lnk)
}
}
// Parse episodes if series
if (isTvSeries) {
val episodeList = ArrayList<Episode>()
val epLinks = playcontainer?.select("div > div > div.source-box")
//Log.i(this.name, "Result => (epList) ${epList}")
body?.select("div#playeroptions > ul > li")?.forEach { ep ->
val epTitle = ep.select("span.title")?.text()
if (!epTitle.isNullOrEmpty()) {
val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull()
//Log.i(this.name, "Result => (epNum) ${epNum}")
val href = when (epNum != null && !epLinks.isNullOrEmpty()) {
true -> epLinks.select("div#source-player-$epNum")
?.select("iframe")?.attr("src") ?: ""
false -> ""
}
val streamEpLink = listOf(href.trim()).toJson()
//Log.i(this.name, "Result => (streamEpLink $epNum) $streamEpLink")
episodeList.add(
Episode(
name = null,
season = null,
episode = epNum,
data = streamEpLink,
posterUrl = poster,
date = null
)
)
}
}
return TvSeriesLoadResponse(
name = title,
url = url,
apiName = this.name,
type = TvType.AsianDrama,
episodes = episodeList,
posterUrl = poster,
year = year,
plot = descript,
tags = tags,
recommendations = recList
)
}
val streamlinks = listOfLinks.distinct().toJson()
return MovieLoadResponse(
name = title,
url = url,
apiName = this.name,
type = TvType.Movie,
dataUrl = streamlinks,
posterUrl = poster,
year = year,
plot = descript,
tags = tags,
recommendations = recList
)
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
// parse movie servers
var count = 0
tryParseJson<List<String>>(data)?.apmap { link ->
count++
if (link.contains("fembed.com")) {
val extractor = Diasfem()
extractor.getUrl(data).forEach {
callback.invoke(it)
}
} else {
loadExtractor(link, mainUrl, subtitleCallback, callback)
}
}
return count > 0
}
}

View file

@ -0,0 +1,16 @@
package com.lagradost
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context
@CloudstreamPlugin
class PinoyMoviePediaProviderPlugin : Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(PinoyMoviePediaProvider())
registerMainAPI(PinoyMoviesEsProvider())
registerExtractorAPI(Diasfem())
registerExtractorAPI(XStreamCdn())
}
}

View file

@ -0,0 +1,251 @@
package com.lagradost
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
//import com.lagradost.cloudstream3.extractors.FEmbed
//import com.lagradost.cloudstream3.extractors.helper.VstreamhubHelper
import com.lagradost.cloudstream3.network.DdosGuardKiller
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.select.Elements
class PinoyMoviesEsProvider : MainAPI() {
override var name = "Pinoy Movies"
override var mainUrl = "https://pinoymovies.es"
override var lang = "tl"
override val supportedTypes = setOf(TvType.AsianDrama)
override val hasDownloadSupport = false
override val hasMainPage = true
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> {
val all = mutableListOf<HomePageList>()
for (item in rows) {
val title = item.first
val elements = mainbody.select("div${sep}${item.second} > article")?.mapNotNull {
// Get inner div from article
var urlTitle = it?.select("div.data.dfeatur")
if (urlTitle.isNullOrEmpty()) {
urlTitle = it?.select("div.data")
}
if (urlTitle.isNullOrEmpty()) {
return@mapNotNull null
}
// Fetch details
val link = fixUrlNull(urlTitle.select("a")?.attr("href"))
if (link.isNullOrBlank()) {
return@mapNotNull null
}
val image = it?.select("div.poster > img")?.attr("data-src")
// Get Title and Year
val name = urlTitle.select("h3")?.text()
?: urlTitle.select("h2")?.text()
?: urlTitle.select("h1")?.text()
if (name.isNullOrBlank()) {
return@mapNotNull null
}
var year = urlTitle.select("span")?.text()?.toIntOrNull()
if (year == null) {
// Get year from name
val rex = Regex("\\((\\d+)")
year = rex.find(name)?.value?.replace("(", "")?.toIntOrNull()
}
//Log.i(this.name, "ApiError -> ${it.selectFirst("span.quality")?.text()}")
val searchQual = getQualityFromString(it.selectFirst("span.quality")?.text())
MovieSearchResponse(
name = name,
url = link,
apiName = this.name,
type = TvType.Movie,
posterUrl = image,
year = year,
quality = searchQual
)
}?.distinctBy { c -> c.url } ?: listOf()
//Add to list of homepages
if (!elements.isNullOrEmpty()) {
all.add(
HomePageList(
title, elements
)
)
}
}
return all
}
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
val all = ArrayList<HomePageList>()
val document = app.get(mainUrl).document
val mainbody = document.getElementsByTag("body")
if (mainbody != null) {
// All rows will be hardcoded bc of the nature of the site
val homepage1 = getRowElements(
mainbody, listOf(
Pair("Suggestion", "items.featured"),
Pair("All Movies", "items.full")
), "."
)
if (homepage1.isNotEmpty()) {
all.addAll(homepage1)
}
//2nd rows
val homepage2 = getRowElements(
mainbody, listOf(
Pair("Action", "genre_action"),
Pair("Comedy", "genre_comedy"),
Pair("Romance", "genre_romance"),
Pair("Horror", "genre_horror")
//Pair("Rated-R", "genre_rated-r")
), "#"
)
if (homepage2.isNotEmpty()) {
all.addAll(homepage2)
}
}
return HomePageResponse(all)
}
override suspend fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/?s=${query.replace(" ", "+")}"
val document = app.get(url, interceptor = DdosGuardKiller(true))
.document.select("div#archive-content > article")
return document?.mapNotNull {
// 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()?.trim() ?: "<No Title>"
val year = urlTitle.select("span.year")?.text()?.toIntOrNull()
val image = it.select("div.poster > img")?.attr("src")
val searchQual = getQualityFromString(it.selectFirst("span.quality")?.text())
MovieSearchResponse(
name = title,
url = link,
apiName = this.name,
type = TvType.Movie,
posterUrl = image,
year = year,
quality = searchQual
)
}?.distinctBy { it.url } ?: listOf()
}
override suspend fun load(url: String): LoadResponse {
val doc = app.get(url).document
val body = doc.getElementsByTag("body")
val inner = body?.select("div.sheader")
// Video details
val data = inner?.select("div.sheader > div.data")
val title = data?.select("h1")?.firstOrNull()?.text() ?: "<Untitled>"
val year = data?.select("span.date")?.text()?.takeLast(4)?.toIntOrNull()
val descript = body?.select("div#info > div.wp-content")?.text()
val poster = body?.select("div.poster > img")?.attr("src")
val tags = data?.select("div.sgeneros > a")?.mapNotNull { tag ->
tag?.text() ?: return@mapNotNull null
}?.toList()
val recList = body?.select("div#single_relacionados > article")?.mapNotNull {
val a = it.select("a") ?: return@mapNotNull null
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 = try {
aName.trim().takeLast(5).removeSuffix(")").toIntOrNull()
} catch (e: Exception) {
null
}
MovieSearchResponse(
url = aUrl,
name = aName,
type = TvType.Movie,
posterUrl = aImg,
year = aYear,
apiName = this.name
)
}
// Video links
val listOfLinks: MutableList<String> = mutableListOf()
val postlist = body?.select("div#playeroptions > ul > li")?.mapNotNull {
it?.attr("data-post") ?: return@mapNotNull null
}?.filter { it.isNotBlank() }?.distinct() ?: listOf()
postlist.apmap { datapost ->
//Log.i(this.name, "Result => (datapost) ${datapost}")
val content = mapOf(
Pair("action", "doo_player_ajax"),
Pair("post", datapost),
Pair("nume", "1"),
Pair("type", "movie")
)
val innerPage = app.post(
"https://pinoymovies.es/wp-admin/admin-ajax.php ",
referer = url, data = content
).document.select("body")?.text()?.trim()
if (!innerPage.isNullOrBlank()) {
tryParseJson<EmbedUrl>(innerPage)?.let {
listOfLinks.add(it.embed_url)
}
}
}
return MovieLoadResponse(
name = title,
url = url,
apiName = this.name,
type = TvType.Movie,
dataUrl = listOfLinks.toJson(),
posterUrl = poster,
year = year,
plot = descript,
tags = tags,
recommendations = recList
)
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
// parse movie servers
var count = 0
tryParseJson<List<String>>(data)?.forEach { link ->
//Log.i(this.name, "Result => (link) $link")
if (link.startsWith("https://vstreamhub.com")) {
VstreamhubHelper.getUrls(link, subtitleCallback, callback)
count++
} else if (link.contains("fembed.com")) {
val extractor = Diasfem()
extractor.getUrl(data).forEach {
callback.invoke(it)
count++
}
} else {
if (loadExtractor(link, mainUrl, subtitleCallback, callback)) {
count++
}
}
}
return count > 0
}
}

View file

@ -0,0 +1,58 @@
package com.lagradost
import com.lagradost.cloudstream3.SubtitleFile
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"
suspend fun getUrls(
url: String,
subtitleCallback: (SubtitleFile) -> Unit,
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.isNotBlank()) {
loadExtractor(datavid, url, subtitleCallback, callback)
//Log.i(baseName, "Result => (datavid) ${datavid}")
}
}
}
}
}
}
}
}

View file

@ -0,0 +1,68 @@
package com.lagradost
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.getQualityFromName
class Diasfem: XStreamCdn() {
override val name: String = "Diasfem"
override val mainUrl: String = "https://diasfem.com"
override var domainUrl: String = "diasfem.com"
}
open class XStreamCdn : ExtractorApi() {
override val name: String = "XStreamCdn"
override val mainUrl: String = "https://embedsito.com"
override val requiresReferer = false
open var domainUrl: String = "embedsito.com"
private data class ResponseData(
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String,
//val type: String // Mp4
)
private data class ResponseJson(
@JsonProperty("success") val success: Boolean,
@JsonProperty("data") val data: List<ResponseData>?
)
override fun getExtractorUrl(id: String): String {
return "$domainUrl/api/source/$id"
}
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val headers = mapOf(
"Referer" to url,
"User-Agent" to "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0",
)
val id = url.trimEnd('/').split("/").last()
val newUrl = "https://${domainUrl}/api/source/${id}"
val extractedLinksList: MutableList<ExtractorLink> = mutableListOf()
with(app.post(newUrl, headers = headers)) {
if (this.code != 200) return listOf()
val text = this.text
if (text.isEmpty()) return listOf()
if (text == """{"success":false,"data":"Video not found or has been removed"}""") return listOf()
AppUtils.parseJson<ResponseJson?>(text)?.let {
if (it.success && it.data != null) {
it.data.forEach { data ->
extractedLinksList.add(
ExtractorLink(
name,
name = name,
data.file,
url,
getQualityFromName(data.label),
)
)
}
}
}
}
return extractedLinksList
}
}