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

View file

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

View file

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