2021-12-21 23:11:13 +00:00
|
|
|
package com.lagradost.cloudstream3.movieproviders
|
|
|
|
|
2022-01-11 12:36:54 +00:00
|
|
|
import com.fasterxml.jackson.module.kotlin.readValue
|
2021-12-21 23:11:13 +00:00
|
|
|
import com.lagradost.cloudstream3.*
|
2022-01-11 12:36:54 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
2021-12-21 23:11:13 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
|
|
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
|
|
|
|
|
|
|
class PinoyHDXyzProvider : MainAPI() {
|
2022-03-16 15:29:11 +00:00
|
|
|
override var name = "Pinoy-HD"
|
|
|
|
override var mainUrl = "https://www.pinoy-hd.xyz"
|
2021-12-21 23:11:13 +00:00
|
|
|
override val lang = "tl"
|
2022-03-21 11:07:36 +00:00
|
|
|
override val supportedTypes = setOf(TvType.AsianDrama)
|
2022-01-11 12:36:54 +00:00
|
|
|
override val hasDownloadSupport = true
|
2021-12-21 23:11:13 +00:00
|
|
|
override val hasMainPage = true
|
|
|
|
override val hasQuickSearch = false
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun getMainPage(): HomePageResponse {
|
2021-12-21 23:11:13 +00:00
|
|
|
val all = ArrayList<HomePageList>()
|
2022-01-11 12:36:54 +00:00
|
|
|
val document = app.get(mainUrl, referer = mainUrl).document
|
2021-12-21 23:11:13 +00:00
|
|
|
val mainbody = document.getElementsByTag("body")
|
|
|
|
|
|
|
|
mainbody?.select("div.section-cotent.col-md-12.bordert")?.forEach { row ->
|
|
|
|
val title = row?.select("div.title-section.tt")?.text() ?: "<Row>"
|
2022-02-06 11:43:12 +00:00
|
|
|
val elements = row?.select("li.img_frame.preview-tumb7")?.mapNotNull {
|
|
|
|
// Get inner div from article
|
|
|
|
val innerBody = it?.selectFirst("a") ?: return@mapNotNull null
|
|
|
|
// Fetch details
|
2022-02-07 09:18:18 +00:00
|
|
|
val name = it.text()?.trim()
|
2022-02-06 11:43:12 +00:00
|
|
|
if (name.isNullOrBlank()) { return@mapNotNull null }
|
|
|
|
|
|
|
|
val link = innerBody.attr("href") ?: return@mapNotNull null
|
|
|
|
val image = fixUrlNull(innerBody.select("img")?.attr("src"))
|
|
|
|
//Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}")
|
|
|
|
// Get Year from Link
|
|
|
|
val rex = Regex("_(\\d+)_")
|
|
|
|
val year = rex.find(link)?.value?.replace("_", "")?.toIntOrNull()
|
|
|
|
//Log.i(this.name, "Result => (yearRes, year) ${yearRes} / ${year}")
|
|
|
|
MovieSearchResponse(
|
|
|
|
name = name,
|
|
|
|
url = link,
|
|
|
|
apiName = this.name,
|
|
|
|
type = TvType.Movie,
|
|
|
|
posterUrl = image,
|
|
|
|
year = year
|
|
|
|
)
|
|
|
|
}?.distinctBy { c -> c.url } ?: listOf()
|
|
|
|
// Add to Homepage
|
|
|
|
if (elements.isNotEmpty()) {
|
2021-12-21 23:11:13 +00:00
|
|
|
all.add(
|
|
|
|
HomePageList(
|
|
|
|
title, elements
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return HomePageResponse(all)
|
|
|
|
}
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun search(query: String): List<SearchResponse> {
|
2021-12-21 23:11:13 +00:00
|
|
|
val url = "$mainUrl/search/?q=${query.replace(" ", "+")}"
|
2022-01-03 00:57:36 +00:00
|
|
|
val document = app.get(url).document.select("div.portfolio-thumb")
|
2022-01-11 12:36:54 +00:00
|
|
|
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
|
2021-12-21 23:11:13 +00:00
|
|
|
|
2022-01-11 12:36:54 +00:00
|
|
|
MovieSearchResponse(
|
2022-02-06 11:43:12 +00:00
|
|
|
name = title,
|
|
|
|
url = link,
|
|
|
|
apiName = this.name,
|
|
|
|
type = TvType.Movie,
|
|
|
|
posterUrl = image,
|
|
|
|
year = year
|
2022-01-11 12:36:54 +00:00
|
|
|
)
|
|
|
|
}?.distinctBy { c -> c.url } ?: listOf()
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun load(url: String): LoadResponse {
|
2022-01-11 12:36:54 +00:00
|
|
|
val doc = app.get(url).document
|
2021-12-21 23:11:13 +00:00
|
|
|
val body = doc.getElementsByTag("body")
|
|
|
|
val inner = body?.select("div.info")
|
|
|
|
|
2022-02-06 11:43:12 +00:00
|
|
|
// Video links
|
|
|
|
val listOfLinks: MutableList<String> = mutableListOf()
|
|
|
|
|
2021-12-21 23:11:13 +00:00
|
|
|
// Video details
|
2022-02-06 11:43:12 +00:00
|
|
|
var title = ""
|
|
|
|
var year: Int? = null
|
|
|
|
var tags: List<String>? = null
|
|
|
|
val poster = fixUrlNull(inner?.select("div.portfolio-tumb.ph-link > img")?.attr("src"))
|
2021-12-21 23:11:13 +00:00
|
|
|
//Log.i(this.name, "Result => (imgLinkCode) ${imgLinkCode}")
|
2022-02-06 11:43:12 +00:00
|
|
|
inner?.select("table")?.select("tr")?.forEach {
|
|
|
|
val td = it?.select("td") ?: return@forEach
|
|
|
|
val caption = td[0].text()?.lowercase()
|
|
|
|
//Log.i(this.name, "Result => (caption) $caption")
|
|
|
|
when (caption) {
|
|
|
|
"name" -> {
|
|
|
|
title = td[1].text()
|
|
|
|
}
|
|
|
|
"year" -> {
|
|
|
|
var yearRes = td[1].toString()
|
|
|
|
year = if (yearRes.isNotBlank()) {
|
|
|
|
if (yearRes.contains("var year =")) {
|
|
|
|
yearRes = yearRes.substring(yearRes.indexOf("var year =") + "var year =".length)
|
|
|
|
//Log.i(this.name, "Result => (yearRes) $yearRes")
|
|
|
|
yearRes = yearRes.substring(0, yearRes.indexOf(';'))
|
|
|
|
.trim().removeSurrounding("'")
|
|
|
|
}
|
|
|
|
yearRes.toIntOrNull()
|
|
|
|
} else { null }
|
|
|
|
}
|
|
|
|
"genre" -> {
|
|
|
|
tags = td[1].select("a")?.mapNotNull { tag ->
|
|
|
|
tag?.text()?.trim() ?: return@mapNotNull null
|
|
|
|
}?.filter { a -> a.isNotBlank() }
|
|
|
|
}
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
2022-02-06 11:43:12 +00:00
|
|
|
}
|
2021-12-21 23:11:13 +00:00
|
|
|
|
|
|
|
var descript = body?.select("div.eText")?.text()
|
|
|
|
if (!descript.isNullOrEmpty()) {
|
2022-01-11 12:36:54 +00:00
|
|
|
try {
|
2022-02-06 11:43:12 +00:00
|
|
|
descript = "(undefined_x_Polus+[.\\d+])".toRegex().replace(descript, "")
|
|
|
|
descript = "(_x_Polus+[.\\d+])".toRegex().replace(descript, "")
|
|
|
|
descript = descript.trim().removeSuffix("undefined").trim()
|
2022-01-11 12:36:54 +00:00
|
|
|
} catch (e: java.lang.Exception) { }
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
2022-02-06 11:43:12 +00:00
|
|
|
// Add links hidden in description
|
|
|
|
listOfLinks.addAll(fetchUrls(descript))
|
|
|
|
listOfLinks.forEach { link ->
|
|
|
|
//Log.i(this.name, "Result => (hidden link) $link")
|
|
|
|
descript = descript?.replace(link, "")
|
|
|
|
}
|
2021-12-21 23:11:13 +00:00
|
|
|
|
2022-01-29 17:02:52 +00:00
|
|
|
// Try looking for episodes, for series
|
|
|
|
val episodeList = ArrayList<TvSeriesEpisode>()
|
|
|
|
val bodyText = body?.select("div.section-cotent1.col-md-12")?.select("section")
|
|
|
|
?.select("script")?.toString() ?: ""
|
|
|
|
//Log.i(this.name, "Result => (bodyText) ${bodyText}")
|
|
|
|
|
|
|
|
"(?<=ses=\\(')(.*)(?='\\).split)".toRegex().find(bodyText)?.groupValues?.get(0).let {
|
|
|
|
if (!it.isNullOrEmpty()) {
|
|
|
|
var count = 0
|
|
|
|
it.split(", ").forEach { ep ->
|
|
|
|
count++
|
|
|
|
val listEpStream = listOf(ep.trim()).toJson()
|
|
|
|
//Log.i(this.name, "Result => (ep $count) $listEpStream")
|
|
|
|
episodeList.add(
|
|
|
|
TvSeriesEpisode(
|
|
|
|
name = null,
|
|
|
|
season = null,
|
|
|
|
episode = count,
|
|
|
|
data = listEpStream,
|
|
|
|
posterUrl = null,
|
|
|
|
date = null
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (episodeList.size > 0) {
|
|
|
|
return TvSeriesLoadResponse(
|
2022-02-06 11:43:12 +00:00
|
|
|
name = title,
|
|
|
|
url = url,
|
|
|
|
apiName = this.name,
|
2022-03-21 11:07:36 +00:00
|
|
|
type = TvType.AsianDrama,
|
2022-02-06 11:43:12 +00:00
|
|
|
episodes = episodeList,
|
|
|
|
posterUrl = poster,
|
|
|
|
year = year,
|
|
|
|
plot = descript,
|
|
|
|
tags = tags
|
2022-01-29 17:02:52 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Video links for Movie
|
2022-01-11 12:36:54 +00:00
|
|
|
body?.select("div.tabcontent > iframe")?.forEach {
|
|
|
|
val linkMain = it?.attr("src")
|
|
|
|
if (!linkMain.isNullOrEmpty()) {
|
|
|
|
listOfLinks.add(linkMain)
|
|
|
|
//Log.i(this.name, "Result => (linkMain) $linkMain")
|
|
|
|
}
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
2022-01-11 12:36:54 +00:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-29 17:02:52 +00:00
|
|
|
val extraLinks = body?.select("div.tabcontent.hide")?.text()
|
|
|
|
listOfLinks.addAll(fetchUrls(extraLinks))
|
2021-12-21 23:11:13 +00:00
|
|
|
|
2022-01-11 12:36:54 +00:00
|
|
|
val streamLinks = listOfLinks.distinct().toJson()
|
2022-01-29 17:02:52 +00:00
|
|
|
//Log.i(this.name, "Result => (streamLinks) streamLinks")
|
2022-02-06 11:43:12 +00:00
|
|
|
return MovieLoadResponse(
|
|
|
|
name = title,
|
|
|
|
url = url,
|
|
|
|
apiName = this.name,
|
|
|
|
type = TvType.Movie,
|
|
|
|
dataUrl = streamLinks,
|
|
|
|
posterUrl = poster,
|
|
|
|
year = year,
|
|
|
|
plot = descript,
|
|
|
|
tags = tags
|
|
|
|
)
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun loadLinks(
|
2021-12-21 23:11:13 +00:00
|
|
|
data: String,
|
|
|
|
isCasting: Boolean,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
2022-01-29 17:02:52 +00:00
|
|
|
var count = 0
|
2022-02-06 11:43:12 +00:00
|
|
|
mapper.readValue<List<String>>(data).forEach { item ->
|
|
|
|
val url = item.trim()
|
|
|
|
if (url.isNotBlank()) {
|
|
|
|
if (loadExtractor(url, mainUrl, callback)) {
|
|
|
|
count++
|
|
|
|
}
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-29 17:02:52 +00:00
|
|
|
return count > 0
|
2021-12-21 23:11:13 +00:00
|
|
|
}
|
|
|
|
}
|