forked from recloudstream/cloudstream
		
	Various providers fixes (#426)
This commit is contained in:
		
							parent
							
								
									48d391c530
								
							
						
					
					
						commit
						f7aa1ce06d
					
				
					 3 changed files with 309 additions and 344 deletions
				
			
		|  | @ -1,11 +1,12 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import android.util.Log | import android.util.Log | ||||||
|  | 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.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 |  | ||||||
| 
 | 
 | ||||||
| class DramaSeeProvider : MainAPI() { | class DramaSeeProvider : MainAPI() { | ||||||
|     override val mainUrl = "https://dramasee.net" |     override val mainUrl = "https://dramasee.net" | ||||||
|  | @ -18,36 +19,33 @@ class DramaSeeProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|     override fun getMainPage(): HomePageResponse { |     override fun getMainPage(): HomePageResponse { | ||||||
|         val headers = mapOf("X-Requested-By" to "dramasee.net") |         val headers = mapOf("X-Requested-By" to "dramasee.net") | ||||||
|         val html = app.get(mainUrl, headers = headers).text |         val document = app.get(mainUrl, headers = headers).document | ||||||
|         val document = Jsoup.parse(html) |  | ||||||
|         val mainbody = document.getElementsByTag("body") |         val mainbody = document.getElementsByTag("body") | ||||||
| 
 | 
 | ||||||
|         return HomePageResponse( |         return HomePageResponse(mainbody?.select("section")?.map { row -> | ||||||
|     mainbody?.select("section")?.map { row -> |             val main = row?.select("main") ?: return@map null | ||||||
|             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 | ||||||
|             val title = main?.select("div.title > div > h2")?.text() ?: "Main" |  | ||||||
|             val inner = main?.select("li.series-item") ?: return@map null |  | ||||||
| 
 | 
 | ||||||
|             HomePageList( |             HomePageList( | ||||||
|                 title, |                 title, | ||||||
|                 inner.mapNotNull { |                 inner.mapNotNull { | ||||||
|                 // Get inner div from article |                     // Get inner div from article | ||||||
|                 val innerBody = it?.selectFirst("a") |                     val innerBody = it?.selectFirst("a") | ||||||
|                 // Fetch details |                     // Fetch details | ||||||
|                 val link = fixUrlNull(innerBody?.attr("href")) ?: return@mapNotNull null |                     val link = fixUrlNull(innerBody?.attr("href")) ?: return@mapNotNull null | ||||||
|                 val image = fixUrlNull(innerBody?.select("img")?.attr("src")) ?: "" |                     val image = fixUrlNull(innerBody?.select("img")?.attr("src")) ?: "" | ||||||
|                 val name = it?.selectFirst("a.series-name")?.text() ?: "<Untitled>" |                     val name = it?.selectFirst("a.series-name")?.text() ?: "<Untitled>" | ||||||
|                 //Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}") |                     //Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}") | ||||||
|                 MovieSearchResponse( |                     MovieSearchResponse( | ||||||
|                     name, |                         name, | ||||||
|                     link, |                         link, | ||||||
|                     this.name, |                         this.name, | ||||||
|                     TvType.TvSeries, |                         TvType.TvSeries, | ||||||
|                     image, |                         image, | ||||||
|                     year = null, |                         year = null, | ||||||
|                     id = null, |                         id = null, | ||||||
|                 ) |                     ) | ||||||
|                 }.distinctBy { c -> c.url }) |                 }.distinctBy { c -> c.url }) | ||||||
|             }?.filterNotNull() ?: listOf() |             }?.filterNotNull() ?: listOf() | ||||||
|         ) |         ) | ||||||
|  | @ -59,24 +57,26 @@ class DramaSeeProvider : MainAPI() { | ||||||
|         val document = html.getElementsByTag("body") |         val document = html.getElementsByTag("body") | ||||||
|                 .select("section > main > ul.series > li") ?: return listOf() |                 .select("section > main > ul.series > li") ?: return listOf() | ||||||
| 
 | 
 | ||||||
|         return document.map { |         return document.mapNotNull { | ||||||
|             val innerA = it?.select("a.series-img") |             if (it == null) { | ||||||
|             val href = innerA?.attr("href") ?: return@map null |                 return@mapNotNull null | ||||||
|             val link = fixUrlNull(href) ?: return@map null |             } | ||||||
|             val title = it?.select("a.series-name")?.text() ?: return@map 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 year = null | ||||||
|             val imgsrc = innerA?.select("img")?.attr("src") ?: return@map null |             val imgsrc = innerA.select("img")?.attr("src") ?: return@mapNotNull null | ||||||
|             val image = fixUrl(imgsrc) |             val image = fixUrlNull(imgsrc) | ||||||
| 
 | 
 | ||||||
|             MovieSearchResponse( |             MovieSearchResponse( | ||||||
|                 title, |                 name = title, | ||||||
|                 link, |                 url = link, | ||||||
|                 this.name, |                 apiName = this.name, | ||||||
|                 TvType.Movie, |                 type = TvType.Movie, | ||||||
|                 image, |                 posterUrl = image, | ||||||
|                 year |                 year = year | ||||||
|             ) |             ) | ||||||
|         }.filterNotNull() |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun load(url: String): LoadResponse { |     override fun load(url: String): LoadResponse { | ||||||
|  | @ -96,48 +96,41 @@ class DramaSeeProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|         // Episodes Links |         // Episodes Links | ||||||
|         val episodeList = ArrayList<TvSeriesEpisode>() |         val episodeList = ArrayList<TvSeriesEpisode>() | ||||||
|         val eps = body?.select("ul.episodes > li.episode-item") |         body?.select("ul.episodes > li.episode-item")?.forEach { ep -> | ||||||
|         //Log.i(this.name, "Result => (eps) ${eps}") |             val innerA = ep.select("a") ?: return@forEach | ||||||
|         if (!eps.isNullOrEmpty()) { |             val count = innerA.select("span.episode")?.text()?.toIntOrNull() ?: 0 | ||||||
|             for (ep in eps) { |             val epLink = fixUrlNull(innerA.attr("href")) ?: return@forEach | ||||||
|                 if (ep != null) { |             //Log.i(this.name, "Result => (epLink) ${epLink}") | ||||||
|                     val innerA = ep.select("a") |             if (epLink.isNotEmpty()) { | ||||||
|                     val count = innerA.select("span.episode")?.text()?.toIntOrNull() ?: 0 |                 // Fetch video links | ||||||
|                     val epLink = fixUrlNull(innerA.attr("href")) ?: continue |                 val epVidLinkEl = app.get(epLink, referer = mainUrl).document | ||||||
|                     //Log.i(this.name, "Result => (epLink) ${epLink}") |                 val ajaxUrl = epVidLinkEl.select("div#js-player")?.attr("embed") | ||||||
|                     if (epLink.isNotEmpty()) { |                 //Log.i(this.name, "Result => (ajaxUrl) ${ajaxUrl}") | ||||||
|                         // Fetch video links |                 if (!ajaxUrl.isNullOrEmpty()) { | ||||||
|                         val epVidLinkEl = app.get(epLink, referer = mainUrl).document |                     val innerPage = app.get(fixUrl(ajaxUrl), referer = epLink).document | ||||||
|                         val ajaxUrl = epVidLinkEl.select("div#js-player")?.attr("embed") |                     val listOfLinks = mutableListOf<String>() | ||||||
|                         //Log.i(this.name, "Result => (ajaxUrl) ${ajaxUrl}") |                     innerPage.select("div.player.active > main > div")?.forEach { em -> | ||||||
|                         if (!ajaxUrl.isNullOrEmpty()) { |                         val href = em.attr("src") ?: "" | ||||||
|                             val innerPage = Jsoup.parse(app.get(fixUrl(ajaxUrl), referer = epLink).text) |                         if (href.isNotEmpty()) { | ||||||
|                             val listOfLinks = mutableListOf<String>() |                             listOfLinks.add(href) | ||||||
|                             val serverAvail = innerPage?.select("div.player.active > main > div") |  | ||||||
|                             if (!serverAvail.isNullOrEmpty()) { |  | ||||||
|                                 for (em in serverAvail) { |  | ||||||
|                                     val href = em.attr("src") |  | ||||||
|                                     if (!href.isNullOrEmpty()) { |  | ||||||
|                                         listOfLinks.add(href) |  | ||||||
|                                     } |  | ||||||
|                                 } |  | ||||||
|                             } |  | ||||||
|                             //Log.i(this.name, "Result => (listOfLinks) ${listOfLinks}") |  | ||||||
|                             episodeList.add( |  | ||||||
|                                 TvSeriesEpisode( |  | ||||||
|                                     name = "Episode $count", |  | ||||||
|                                     season = null, |  | ||||||
|                                     episode = count, |  | ||||||
|                                     data = listOfLinks.toString(), |  | ||||||
|                                     posterUrl = poster, |  | ||||||
|                                     date = null |  | ||||||
|                                 ) |  | ||||||
|                             ) |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  | 
 | ||||||
|  |                     //Log.i(this.name, "Result => (listOfLinks) ${listOfLinks}") | ||||||
|  |                     episodeList.add( | ||||||
|  |                         TvSeriesEpisode( | ||||||
|  |                             name = null, | ||||||
|  |                             season = null, | ||||||
|  |                             episode = count, | ||||||
|  |                             data = listOfLinks.distinct().toJson(), | ||||||
|  |                             posterUrl = poster, | ||||||
|  |                             date = null | ||||||
|  |                         ) | ||||||
|  |                     ) | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         //If there's only 1 episode, consider it a movie. |         //If there's only 1 episode, consider it a movie. | ||||||
|         if (episodeList.size == 1) { |         if (episodeList.size == 1) { | ||||||
|             return MovieLoadResponse(title, url, this.name, TvType.Movie, episodeList[0].data, poster, year, descript, null, null) |             return MovieLoadResponse(title, url, this.name, TvType.Movie, episodeList[0].data, poster, year, descript, null, null) | ||||||
|  | @ -163,55 +156,49 @@ class DramaSeeProvider : MainAPI() { | ||||||
|         subtitleCallback: (SubtitleFile) -> Unit, |         subtitleCallback: (SubtitleFile) -> Unit, | ||||||
|         callback: (ExtractorLink) -> Unit |         callback: (ExtractorLink) -> Unit | ||||||
|     ): Boolean { |     ): Boolean { | ||||||
|         if (data == "about:blank") return false |  | ||||||
|         if (data == "[]") return false |  | ||||||
|         if (data.isEmpty()) return false |         if (data.isEmpty()) return false | ||||||
|  |         if (data == "[]") return false | ||||||
|  |         if (data == "about:blank") return false | ||||||
| 
 | 
 | ||||||
|         val urls = data.trim('[').trim(']').split(',') |         mapper.readValue<List<String>>(data).forEach { item -> | ||||||
|         if (!urls.isNullOrEmpty()) { |             if (item.isNotEmpty()) { | ||||||
|             for (item in urls) { |                 var url = item.trim() | ||||||
|                 if (item.isNotEmpty()) { |                 if (url.startsWith("//")) { | ||||||
|                     var url = item.trim() |                     url = "https:$url" | ||||||
|                     if (url.startsWith("//")) { |                 } | ||||||
|                         url = "https:$url" |                 //Log.i(this.name, "Result => (url) ${url}") | ||||||
|                     } |                 if (url.startsWith("https://asianembed.io")) { | ||||||
|                     //Log.i(this.name, "Result => (url) ${url}") |                     // Fetch links | ||||||
|                     if (url.startsWith("https://asianembed.io")) { |                     val doc = app.get(url).document | ||||||
|                         // Fetch links |                     val links = doc.select("div#list-server-more > ul > li.linkserver") | ||||||
|                         val doc = app.get(url).document |                     if (!links.isNullOrEmpty()) { | ||||||
|                         val links = doc.select("div#list-server-more > ul > li.linkserver") |                         links.forEach { | ||||||
|                         if (!links.isNullOrEmpty()) { |                             val datavid = it.attr("data-video") ?: "" | ||||||
|                             links.forEach { |                             //Log.i(this.name, "Result => (datavid) ${datavid}") | ||||||
|                                 val datavid = it.attr("data-video") ?: "" |                             if (datavid.isNotEmpty()) { | ||||||
|                                 //Log.i(this.name, "Result => (datavid) ${datavid}") |                                 if (datavid.startsWith("https://fembed-hd.com")) { | ||||||
|                                 if (datavid.isNotEmpty()) { |                                     val extractor = XStreamCdn() | ||||||
|                                     if (datavid.startsWith("https://fembed-hd.com")) { |                                     extractor.domainUrl = "fembed-hd.com" | ||||||
|                                         val extractor = XStreamCdn() |                                     extractor.getUrl(datavid, url).forEach { link -> | ||||||
|                                         extractor.domainUrl = "fembed-hd.com" |                                         callback.invoke(link) | ||||||
|                                         val src = extractor.getUrl(datavid, url) |  | ||||||
|                                         src.forEach { link -> |  | ||||||
|                                             callback.invoke(link) |  | ||||||
|                                         } |  | ||||||
|                                     } else { |  | ||||||
|                                         loadExtractor(datavid, url, callback) |  | ||||||
|                                     } |                                     } | ||||||
|  |                                 } else { | ||||||
|  |                                     loadExtractor(datavid, url, callback) | ||||||
|                                 } |                                 } | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } else if (url.startsWith("https://embedsito.com")) { |                     } | ||||||
|                         val extractor = XStreamCdn() |                 } else if (url.startsWith("https://embedsito.com")) { | ||||||
|                         extractor.domainUrl = "embedsito.com" |                     val extractor = XStreamCdn() | ||||||
|                         val src = extractor.getUrl(url) |                     extractor.domainUrl = "embedsito.com" | ||||||
|                         src.forEach { link -> |                     extractor.getUrl(url).forEach { link -> | ||||||
|                             callback.invoke(link) |                         callback.invoke(link) | ||||||
|                         } |                     } | ||||||
|                     } else { |                 } else { | ||||||
|                         loadExtractor(url, url, callback) |                     loadExtractor(url, mainUrl, callback) | ||||||
|                     } // end if |                 } // end if | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|             return true |  | ||||||
|         } |         } | ||||||
|         return false |         return true | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -1,25 +1,26 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import android.util.Log | import android.util.Log | ||||||
|  | import com.fasterxml.jackson.module.kotlin.readValue | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
|  | 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 java.lang.Exception | ||||||
| 
 | 
 | ||||||
| class PinoyHDXyzProvider : MainAPI() { | class PinoyHDXyzProvider : MainAPI() { | ||||||
|     override val name = "Pinoy-HD" |     override val name = "Pinoy-HD" | ||||||
|     override val mainUrl = "https://www.pinoy-hd.xyz" |     override val mainUrl = "https://www.pinoy-hd.xyz" | ||||||
|     override val lang = "tl" |     override val lang = "tl" | ||||||
|     override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries) |     override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries) | ||||||
|     override val hasDownloadSupport = false |     override val hasDownloadSupport = true | ||||||
|     override val hasMainPage = true |     override val hasMainPage = true | ||||||
|     override val hasQuickSearch = false |     override val hasQuickSearch = false | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     override fun getMainPage(): HomePageResponse { |     override fun getMainPage(): HomePageResponse { | ||||||
|         val all = ArrayList<HomePageList>() |         val all = ArrayList<HomePageList>() | ||||||
|         val html = app.get(mainUrl, referer = mainUrl).text |         val document = app.get(mainUrl, referer = mainUrl).document | ||||||
|         val document = Jsoup.parse(html) |  | ||||||
|         val mainbody = document.getElementsByTag("body") |         val mainbody = document.getElementsByTag("body") | ||||||
| 
 | 
 | ||||||
|         mainbody?.select("div.section-cotent.col-md-12.bordert")?.forEach { row -> |         mainbody?.select("div.section-cotent.col-md-12.bordert")?.forEach { row -> | ||||||
|  | @ -69,32 +70,28 @@ class PinoyHDXyzProvider : MainAPI() { | ||||||
|     override fun search(query: String): List<SearchResponse> { |     override fun search(query: String): List<SearchResponse> { | ||||||
|         val url = "$mainUrl/search/?q=${query.replace(" ", "+")}" |         val url = "$mainUrl/search/?q=${query.replace(" ", "+")}" | ||||||
|         val document = app.get(url).document.select("div.portfolio-thumb") |         val document = app.get(url).document.select("div.portfolio-thumb") | ||||||
|         if (!document.isNullOrEmpty()) { |         return document?.mapNotNull { | ||||||
|             return document.map { |             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 | ||||||
| 
 | 
 | ||||||
|                 val link = it?.select("a")?.firstOrNull()?.attr("href") ?: "" |             MovieSearchResponse( | ||||||
|                 val title = it?.text() ?: "" |                 title, | ||||||
|                 val year = null |                 link, | ||||||
|                 val image = null // site provides no image on search page |                 this.name, | ||||||
| 
 |                 TvType.Movie, | ||||||
|                 MovieSearchResponse( |                 image, | ||||||
|                     title, |                 year | ||||||
|                     link, |             ) | ||||||
|                     this.name, |         }?.distinctBy { c -> c.url } ?: listOf() | ||||||
|                     TvType.Movie, |  | ||||||
|                     image, |  | ||||||
|                     year |  | ||||||
|                 ) |  | ||||||
|             }.filter { a -> a.url.isNotEmpty() } |  | ||||||
|                     .filter { b -> b.name.isNotEmpty() } |  | ||||||
|                     .distinctBy { c -> c.url } |  | ||||||
|         } |  | ||||||
|         return listOf() |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun load(url: String): LoadResponse { |     override 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.info") |         val inner = body?.select("div.info") | ||||||
| 
 | 
 | ||||||
|  | @ -120,32 +117,44 @@ class PinoyHDXyzProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|         var descript = body?.select("div.eText")?.text() |         var descript = body?.select("div.eText")?.text() | ||||||
|         if (!descript.isNullOrEmpty()) { |         if (!descript.isNullOrEmpty()) { | ||||||
|             descript = descript.substring(0, descript.indexOf("_x_Polus1")) |             try { | ||||||
|                 .replace("_x_Polus1", "") |                 descript = descript.substring(0, descript.indexOf("_x_Polus1")) | ||||||
|  |                     .replace("_x_Polus1", "") | ||||||
|  |             } catch (e: java.lang.Exception) {  } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Video links |         // Video links | ||||||
|         val listOfLinks: MutableList<String> = mutableListOf() |         val listOfLinks: MutableList<String> = mutableListOf() | ||||||
|         val linkMain = body?.select("div.tabcontent > iframe")?.attr("src") |         body?.select("div.tabcontent > iframe")?.forEach { | ||||||
|         if (!linkMain.isNullOrEmpty()) { |             val linkMain = it?.attr("src") | ||||||
|             listOfLinks.add(linkMain) |             if (!linkMain.isNullOrEmpty()) { | ||||||
|         } |                 listOfLinks.add(linkMain) | ||||||
|         var extraLinks = body?.select("div.tabcontent.hide")?.text() |                 //Log.i(this.name, "Result => (linkMain) $linkMain") | ||||||
|         if (!extraLinks.isNullOrEmpty()) { |  | ||||||
|             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) { |  | ||||||
|                 if (item.contains("https://")) { |  | ||||||
|                     val lnkurl = item.substring(item.indexOf("https://")).trim() |  | ||||||
|                     listOfLinks.add(lnkurl) |  | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         val streamlinks = listOfLinks.toString() |         body?.select("div.tabcontent.hide > iframe")?.forEach { | ||||||
|         //Log.i(this.name, "Result => (streamlinks) ${streamlinks}") |             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>")) | ||||||
|  |                 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) { } | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         // Parse episodes if series |         // Parse episodes if series | ||||||
|         if (tvtype == TvType.TvSeries) { |         if (tvtype == TvType.TvSeries) { | ||||||
|  | @ -160,43 +169,40 @@ class PinoyHDXyzProvider : MainAPI() { | ||||||
|                     epListText = epListText.substring(indexStart.length, epListText.indexOf(")")) |                     epListText = epListText.substring(indexStart.length, epListText.indexOf(")")) | ||||||
|                         .trim().trim('\'') |                         .trim().trim('\'') | ||||||
|                     //Log.i(this.name, "Result => (epListText) ${epListText}") |                     //Log.i(this.name, "Result => (epListText) ${epListText}") | ||||||
|                     val epList = epListText.split(',') |                     var count = 0 | ||||||
|                     //Log.i(this.name, "Result => (epLinks) ${epLinks}") |                     epListText.split(',').forEach { ep -> | ||||||
|                     if (!epList.isNullOrEmpty()) { |                         count++ | ||||||
|                         var count = 0 |                         val listEpStream = listOf(ep.trim()).toJson() | ||||||
|                         epList.forEach { ep -> |                         //Log.i(this.name, "Result => (ep $count) $listEpStream") | ||||||
|                             count++ |                         episodeList.add( | ||||||
|                             val epTitle = " Episode $count" |                             TvSeriesEpisode( | ||||||
|                             //Log.i(this.name, "Result => (epLinks href) ${href}") |                                 name = null, | ||||||
|                             episodeList.add( |                                 season = null, | ||||||
|                                 TvSeriesEpisode( |                                 episode = count, | ||||||
|                                     name = name + epTitle, |                                 data = listEpStream, | ||||||
|                                     season = null, |                                 posterUrl = poster, | ||||||
|                                     episode = count, |                                 date = null | ||||||
|                                     data = ep.trim(), |  | ||||||
|                                     posterUrl = poster, |  | ||||||
|                                     date = null |  | ||||||
|                                 ) |  | ||||||
|                             ) |                             ) | ||||||
|                         } |  | ||||||
|                         return TvSeriesLoadResponse( |  | ||||||
|                             title, |  | ||||||
|                             url, |  | ||||||
|                             this.name, |  | ||||||
|                             tvtype, |  | ||||||
|                             episodeList, |  | ||||||
|                             poster, |  | ||||||
|                             year, |  | ||||||
|                             descript, |  | ||||||
|                             null, |  | ||||||
|                             null, |  | ||||||
|                             null |  | ||||||
|                         ) |                         ) | ||||||
|                     } |                     } | ||||||
|  |                     return TvSeriesLoadResponse( | ||||||
|  |                         title, | ||||||
|  |                         url, | ||||||
|  |                         this.name, | ||||||
|  |                         tvtype, | ||||||
|  |                         episodeList, | ||||||
|  |                         poster, | ||||||
|  |                         year, | ||||||
|  |                         descript, | ||||||
|  |                         null, | ||||||
|  |                         null, | ||||||
|  |                         null | ||||||
|  |                     ) | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         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( |     override fun loadLinks( | ||||||
|  | @ -205,19 +211,16 @@ class PinoyHDXyzProvider : MainAPI() { | ||||||
|         subtitleCallback: (SubtitleFile) -> Unit, |         subtitleCallback: (SubtitleFile) -> Unit, | ||||||
|         callback: (ExtractorLink) -> Unit |         callback: (ExtractorLink) -> Unit | ||||||
|     ): Boolean { |     ): Boolean { | ||||||
|         if (data == "about:blank") return false |  | ||||||
|         if (data.isEmpty()) return false |         if (data.isEmpty()) return false | ||||||
|         try { |         if (data == "about:blank") return false | ||||||
|             data.trim('[').trim(']').split(',').map { item -> |         if (data == "[]") return false | ||||||
|                 if (item.isNotEmpty()) { | 
 | ||||||
|                     val url = item.trim() |         mapper.readValue<List<String>>(data).forEach { item -> | ||||||
|                     loadExtractor(url, url, callback) |             if (item.isNotEmpty()) { | ||||||
|                 } |                 val url = item.trim() | ||||||
|  |                 loadExtractor(url, mainUrl, callback) | ||||||
|             } |             } | ||||||
|         } catch (e: Exception) { |  | ||||||
|             e.printStackTrace() |  | ||||||
|             Log.i(this.name, "Result => (e) $e") |  | ||||||
|         } |         } | ||||||
|         return false |         return true | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -1,11 +1,12 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import android.util.Log | import android.util.Log | ||||||
|  | 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.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 java.lang.Exception | import java.lang.Exception | ||||||
| 
 | 
 | ||||||
| class PinoyMoviePediaProvider : MainAPI() { | class PinoyMoviePediaProvider : MainAPI() { | ||||||
|  | @ -19,8 +20,7 @@ class PinoyMoviePediaProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|     override fun getMainPage(): HomePageResponse { |     override 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") | ||||||
|         // All rows will be hardcoded bc of the nature of the site |         // All rows will be hardcoded bc of the nature of the site | ||||||
|         val rows: List<Pair<String, String>> = listOf( |         val rows: List<Pair<String, String>> = listOf( | ||||||
|  | @ -33,87 +33,78 @@ class PinoyMoviePediaProvider : MainAPI() { | ||||||
|             Pair("Family", "genre_family") |             Pair("Family", "genre_family") | ||||||
|             //Pair("Adult +18", "genre_pinay-sexy-movies") |             //Pair("Adult +18", "genre_pinay-sexy-movies") | ||||||
|         ) |         ) | ||||||
|         for (item in rows) { |         rows.forEach { item -> | ||||||
|             val title = item.first |             val title = item.first | ||||||
|             val inner = mainbody?.select("div#${item.second} > article") |             val inner = mainbody?.select("div#${item.second} > article") | ||||||
|             if (inner != null) { |  | ||||||
|                 val elements: List<SearchResponse> = inner.map { |  | ||||||
|                     // Get inner div from article |  | ||||||
|                     val urlTitle = it?.select("div.data") |  | ||||||
|                     // Fetch details |  | ||||||
|                     val link = urlTitle?.select("a")?.attr("href") ?: "" |  | ||||||
|                     val name = urlTitle?.text() ?: "" |  | ||||||
|                     val image = it?.select("div.poster > img")?.attr("src") |  | ||||||
|                     // Get Year from Title |  | ||||||
|                     val rex = Regex("\\((\\d+)") |  | ||||||
|                     val yearRes = rex.find(name)?.value ?: "" |  | ||||||
|                     val year = yearRes.replace("(", "").toIntOrNull() |  | ||||||
| 
 | 
 | ||||||
|                     val tvType = TvType.Movie |             val elements: List<SearchResponse> = inner?.mapNotNull { | ||||||
|                     MovieSearchResponse( |                 if (it == null) { | ||||||
|                         name, |                     return@mapNotNull null | ||||||
|                         link, |                 } | ||||||
|                         this.name, |                 // Get inner div from article | ||||||
|                         tvType, |                 val urlTitle = it.select("div.data") ?: return@mapNotNull null | ||||||
|                         image, |                 // Fetch details | ||||||
|                         year, |                 val link = fixUrlNull(urlTitle.select("a")?.attr("href")) ?: return@mapNotNull null | ||||||
|                         null, |                 val name = urlTitle.text() ?: "" | ||||||
|                     ) |                 val image = it.select("div.poster > img")?.attr("src") | ||||||
|                 }.filter { a -> a.url.isNotEmpty() } |                 // Get Year from Title | ||||||
|                         .filter { b -> b.name.isNotEmpty() } |                 val year = try { | ||||||
|                         .distinctBy { c -> c.url } |                     val rex = Regex("\\((\\d+)") | ||||||
|                 // Add |                     rex.find(name)?.value?.replace("(", "")?.toIntOrNull() | ||||||
|                 all.add( |                 } catch (e: Exception) { null } | ||||||
|                     HomePageList( | 
 | ||||||
|                         title, elements |                 val tvType = TvType.Movie | ||||||
|                     ) |                 MovieSearchResponse( | ||||||
|  |                     name, | ||||||
|  |                     link, | ||||||
|  |                     this.name, | ||||||
|  |                     tvType, | ||||||
|  |                     image, | ||||||
|  |                     year, | ||||||
|  |                     null, | ||||||
|                 ) |                 ) | ||||||
|             } |             }?.distinctBy { c -> c.url } ?: listOf() | ||||||
|  |             // Add | ||||||
|  |             all.add( | ||||||
|  |                 HomePageList( | ||||||
|  |                     title, elements | ||||||
|  |                 ) | ||||||
|  |             ) | ||||||
|         } |         } | ||||||
|         return HomePageResponse(all) |         return HomePageResponse(all.filter { a -> a.list.isNotEmpty() }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun search(query: String): List<SearchResponse> { |     override fun search(query: String): List<SearchResponse> { | ||||||
|         val url = "$mainUrl/?s=${query}" |         val url = "$mainUrl/?s=${query}" | ||||||
|         val html = app.get(url).text |         val document = app.get(url).document.selectFirst("div.search-page") | ||||||
|         val document = Jsoup.parse(html).select("div.search-page")?.firstOrNull() |  | ||||||
|             ?.select("div.result-item") |             ?.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() ?: "" |         return document?.mapNotNull { | ||||||
|                 val link: String = when (href != "") { |             val inner = it.select("article") ?: return@mapNotNull null | ||||||
|                     true -> fixUrl(href) |             val details = inner.select("div.details") ?: return@mapNotNull null | ||||||
|                     false -> "" |             val link = fixUrlNull(details.select("div.title > a")?.attr("href")) ?: return@mapNotNull null | ||||||
|                 } |  | ||||||
|                 val year = details?.select("div.meta > span.year")?.text()?.toIntOrNull() |  | ||||||
|                 val image = inner.select("div.image > div > a > img")?.attr("src") |  | ||||||
| 
 | 
 | ||||||
|                 MovieSearchResponse( |             val title = details.select("div.title")?.text() ?: "" | ||||||
|                     title, |             val year = details.select("div.meta > span.year")?.text()?.toIntOrNull() | ||||||
|                     link, |             val image = inner.select("div.image > div > a > img")?.attr("src") | ||||||
|                     this.name, | 
 | ||||||
|                     TvType.Movie, |             MovieSearchResponse( | ||||||
|                     image, |                 title, | ||||||
|                     year |                 link, | ||||||
|                 ) |                 this.name, | ||||||
|             }.filter { a -> a.url.isNotEmpty() } |                 TvType.Movie, | ||||||
|                     .filter { b -> b.name.isNotEmpty() } |                 image, | ||||||
|                     .distinctBy { c -> c.url } |                 year | ||||||
|         } |             ) | ||||||
|         return listOf() |         }?.distinctBy { c -> c.url } ?: listOf() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun load(url: String): LoadResponse { |     override 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 |         // 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 |         // Video details | ||||||
|         val poster = inner?.select("div.poster > img")?.attr("src") |         val poster = inner?.select("div.poster > img")?.attr("src") | ||||||
|  | @ -125,56 +116,60 @@ class PinoyMoviePediaProvider : MainAPI() { | ||||||
|         val year = yearRes.replace("(", "").toIntOrNull() |         val year = yearRes.replace("(", "").toIntOrNull() | ||||||
| 
 | 
 | ||||||
|         // Video links |         // Video links | ||||||
|         val linksContainer = body?.select("div#playcontainer") |         val playcontainer = body?.select("div#playcontainer") | ||||||
|         val streamlinks = linksContainer?.toString() ?: "" |         val listOfLinks: MutableList<String> = mutableListOf() | ||||||
|         //Log.i(this.name, "Result => (streamlinks) ${streamlinks}") |         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 |         // Parse episodes if series | ||||||
|         if (isTvSeries) { |         if (isTvSeries) { | ||||||
|             val episodeList = ArrayList<TvSeriesEpisode>() |             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}") |             //Log.i(this.name, "Result => (epList) ${epList}") | ||||||
|             val epLinks = linksContainer?.select("div > div > div.source-box") |             body?.select("div#playeroptions > ul > li")?.forEach { ep -> | ||||||
|             //Log.i(this.name, "Result => (epLinks) ${epLinks}") |                 val epTitle = ep.select("span.title")?.text() | ||||||
|             if (epList != null) { |                 if (!epTitle.isNullOrEmpty()) { | ||||||
|                 for (ep in epList) { |                     val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull() | ||||||
|                     val epTitle = ep.select("span.title")?.text() ?: "" |                     //Log.i(this.name, "Result => (epNum) ${epNum}") | ||||||
|                     if (epTitle.isNotEmpty()) { |                     val href = when (epNum != null && !epLinks.isNullOrEmpty()) { | ||||||
|                         val epNum = epTitle.lowercase().replace("episode", "").trim().toIntOrNull() |                         true -> epLinks.select("div#source-player-$epNum") | ||||||
|                         //Log.i(this.name, "Result => (epNum) ${epNum}") |                             ?.select("iframe")?.attr("src") ?: "" | ||||||
|                         val href = when (epNum != null && epLinks != null) { |                         false -> "" | ||||||
|                             true -> epLinks.select("div#source-player-${epNum}") |  | ||||||
|                                 ?.select("iframe")?.attr("src") ?: "" |  | ||||||
|                             false -> "" |  | ||||||
|                         } |  | ||||||
|                         //Log.i(this.name, "Result => (epLinks href) ${href}") |  | ||||||
|                         episodeList.add( |  | ||||||
|                             TvSeriesEpisode( |  | ||||||
|                                 "Episode $epNum", |  | ||||||
|                                 null, |  | ||||||
|                                 epNum, |  | ||||||
|                                 href, |  | ||||||
|                                 poster, |  | ||||||
|                                 null |  | ||||||
|                             ) |  | ||||||
|                         ) |  | ||||||
|                     } |                     } | ||||||
|  |                     val streamEpLink = listOf(href.trim()).toJson() | ||||||
|  |                     //Log.i(this.name, "Result => (streamEpLink $epNum) $streamEpLink") | ||||||
|  |                     episodeList.add( | ||||||
|  |                         TvSeriesEpisode( | ||||||
|  |                             name = null, | ||||||
|  |                             season = null, | ||||||
|  |                             episode = epNum, | ||||||
|  |                             data = streamEpLink, | ||||||
|  |                             posterUrl = poster, | ||||||
|  |                             date = null | ||||||
|  |                         ) | ||||||
|  |                     ) | ||||||
|                 } |                 } | ||||||
|                 return TvSeriesLoadResponse( |  | ||||||
|                     title, |  | ||||||
|                     url, |  | ||||||
|                     this.name, |  | ||||||
|                     TvType.TvSeries, |  | ||||||
|                     episodeList, |  | ||||||
|                     poster, |  | ||||||
|                     year, |  | ||||||
|                     descript, |  | ||||||
|                     null, |  | ||||||
|                     null, |  | ||||||
|                     null |  | ||||||
|                 ) |  | ||||||
|             } |             } | ||||||
|  |             return TvSeriesLoadResponse( | ||||||
|  |                 title, | ||||||
|  |                 url, | ||||||
|  |                 this.name, | ||||||
|  |                 TvType.TvSeries, | ||||||
|  |                 episodeList, | ||||||
|  |                 poster, | ||||||
|  |                 year, | ||||||
|  |                 descript, | ||||||
|  |                 null, | ||||||
|  |                 null, | ||||||
|  |                 null | ||||||
|  |             ) | ||||||
|         } |         } | ||||||
|  |         val streamlinks = listOfLinks.distinct().toJson() | ||||||
|         return MovieLoadResponse(title, url, this.name, TvType.Movie, streamlinks, poster, year, descript, null, null) |         return MovieLoadResponse(title, url, this.name, TvType.Movie, streamlinks, poster, year, descript, null, null) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -184,42 +179,22 @@ class PinoyMoviePediaProvider : MainAPI() { | ||||||
|         subtitleCallback: (SubtitleFile) -> Unit, |         subtitleCallback: (SubtitleFile) -> Unit, | ||||||
|         callback: (ExtractorLink) -> Unit |         callback: (ExtractorLink) -> Unit | ||||||
|     ): Boolean { |     ): Boolean { | ||||||
|         if (data == "about:blank") return false |  | ||||||
|         if (data.isEmpty()) return false |         if (data.isEmpty()) return false | ||||||
|         val sources = mutableListOf<ExtractorLink>() |         if (data == "[]") return false | ||||||
|  |         if (data == "about:blank") return false | ||||||
| 
 | 
 | ||||||
|         // parse movie servers |         // parse movie servers | ||||||
|         if (data.contains("playcontainer")) { |         mapper.readValue<List<String>>(data).forEach { link -> | ||||||
|             Jsoup.parse(data).select("div")?.map { item -> |             if (link.contains("fembed.com")) { | ||||||
|                 val url = item.select("iframe")?.attr("src") |                 val extractor = FEmbed() | ||||||
|                 if (!url.isNullOrEmpty()) { |                 extractor.domainUrl = "diasfem.com" | ||||||
|                     //Log.i(this.name, "Result => (url) ${url}") |                 extractor.getUrl(data).forEach { | ||||||
|                     loadExtractor(url, url, callback) |                     callback.invoke(it) | ||||||
|                 } |                 } | ||||||
|             } |             } else { | ||||||
|         } else { |                 loadExtractor(link, mainUrl, callback) | ||||||
|             // parse single link |  | ||||||
|             try { |  | ||||||
|                 if (data.contains("fembed.com")) { |  | ||||||
|                     val extractor = FEmbed() |  | ||||||
|                     extractor.domainUrl = "diasfem.com" |  | ||||||
|                     val src = extractor.getUrl(data) |  | ||||||
|                     if (src.isNotEmpty()) { |  | ||||||
|                         sources.addAll(src) |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } catch (e: Exception) { |  | ||||||
|                 Log.i(this.name, "Result => (exception) $e") |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         // Invoke sources |         return true | ||||||
|         if (sources.isNotEmpty()) { |  | ||||||
|             for (source in sources) { |  | ||||||
|                 callback.invoke(source) |  | ||||||
|                 //Log.i(this.name, "Result => (source) ${source.url}") |  | ||||||
|                 return true |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         return false |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue