From 54cd44179d04528e7ac03f09c1d5a747f861a4bb Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Tue, 1 Feb 2022 05:01:25 +0800 Subject: [PATCH] Dramasee and WatchAsian fix to support asianload domain. Fixes #526 (#536) * Dramasee and WatchAsian fix to support asianload domain. Fixes #526 * [skip ci] minor edits from PR suggestions. * fix pinoymoviepedia titles on homepage. * fix pinoymovies title on homepage. * Update DramaSeeProvider.kt Co-authored-by: Osten --- .../extractors/helper/AsianEmbedHelper.kt | 23 +++++++++--------- .../movieproviders/DramaSeeProvider.kt | 16 ++++++------- .../movieproviders/PinoyMoviePediaProvider.kt | 24 ++++++++++++------- .../movieproviders/PinoyMoviesEsProvider.kt | 13 +++++++--- .../movieproviders/WatchAsianProvider.kt | 23 ++++++++++++------ 5 files changed, 60 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt index 8b0e36c4..82a07214 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors.helper import android.util.Log +import com.lagradost.cloudstream3.apmap import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor @@ -8,18 +9,16 @@ import com.lagradost.cloudstream3.utils.loadExtractor class AsianEmbedHelper { companion object { suspend fun getUrls(url: String, callback: (ExtractorLink) -> Unit) { - if (url.startsWith("https://asianembed.io")) { - // Fetch links - val doc = app.get(url).document - val links = doc.select("div#list-server-more > ul > li.linkserver") - if (!links.isNullOrEmpty()) { - links.forEach { - val datavid = it.attr("data-video") ?: "" - //Log.i("AsianEmbed", "Result => (datavid) ${datavid}") - if (datavid.isNotEmpty()) { - val res = loadExtractor(datavid, url, callback) - Log.i("AsianEmbed", "Result => ($res) (datavid) ${datavid}") - } + // Fetch links + val doc = app.get(url).document + val links = doc.select("div#list-server-more > ul > li.linkserver") + if (!links.isNullOrEmpty()) { + links.apmap { + val datavid = it.attr("data-video") ?: "" + //Log.i("AsianEmbed", "Result => (datavid) ${datavid}") + if (datavid.isNotEmpty()) { + val res = loadExtractor(datavid, url, callback) + Log.i("AsianEmbed", "Result => ($res) (datavid) $datavid") } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt index d04696bf..b3755a53 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt @@ -96,7 +96,7 @@ class DramaSeeProvider : MainAPI() { // Episodes Links val episodeList = ArrayList() - body?.select("ul.episodes > li.episode-item")?.forEach { ep -> + body?.select("ul.episodes > li")?.forEach { ep -> val innerA = ep.select("a") ?: return@forEach val count = innerA.select("span.episode")?.text()?.toIntOrNull() ?: 0 val epLink = fixUrlNull(innerA.attr("href")) ?: return@forEach @@ -110,13 +110,13 @@ class DramaSeeProvider : MainAPI() { val innerPage = app.get(fixUrl(ajaxUrl), referer = epLink).document val listOfLinks = mutableListOf() innerPage.select("div.player.active > main > div")?.forEach { em -> - val href = em.attr("src") ?: "" + val href = fixUrlNull(em.attr("src")) ?: "" if (href.isNotEmpty()) { listOfLinks.add(href) } } - //Log.i(this.name, "Result => (listOfLinks) ${listOfLinks}") + //Log.i(this.name, "Result => (listOfLinks) ${listOfLinks.toJson()}") episodeList.add( TvSeriesEpisode( name = null, @@ -160,18 +160,16 @@ class DramaSeeProvider : MainAPI() { mapper.readValue>(data).apmap { item -> if (item.isNotEmpty()) { count++ - var url = fixUrl(item.trim()) + val url = fixUrl(item.trim()) //Log.i(this.name, "Result => (url) ${url}") when { - url.startsWith("https://asianembed.io") -> { + url.startsWith("https://asianembed.io") || url.startsWith("https://asianload.io") -> { AsianEmbedHelper.getUrls(url, callback) } url.startsWith("https://embedsito.com") -> { val extractor = XStreamCdn() extractor.domainUrl = "embedsito.com" - extractor.getUrl(url).forEach { link -> - callback.invoke(link) - } + extractor.getSafeUrl(url)?.forEach(callback) } else -> { loadExtractor(url, mainUrl, callback) @@ -181,4 +179,4 @@ class DramaSeeProvider : MainAPI() { } return count > 0 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt index 71874ff5..2b7ed23d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt @@ -36,20 +36,28 @@ class PinoyMoviePediaProvider : MainAPI() { val inner = mainbody?.select("div#${item.second} > article") val elements: List = inner?.mapNotNull { - if (it == null) { - return@mapNotNull null - } + 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 name = urlTitle.text() ?: "" val image = it.select("div.poster > img")?.attr("src") - // Get Year from Title - val year = try { + + // 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() + } + if (year == null) { + // Get year from name val rex = Regex("\\((\\d+)") - rex.find(name)?.value?.replace("(", "")?.toIntOrNull() - } catch (e: Exception) { null } + year = rex.find(name)?.value?.replace("(", "")?.toIntOrNull() + } val tvType = TvType.Movie MovieSearchResponse( diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt index 9b4c98f0..9cd82bcc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt @@ -39,11 +39,18 @@ class PinoyMoviesEsProvider : MainAPI() { } // Fetch details val link = urlTitle?.select("a")?.attr("href") ?: "" - val name = urlTitle?.text() ?: "" - val year = urlTitle?.select("span")?.text()?.toIntOrNull() - //Log.i(this.name, "Result => (link) ${link}") val image = it?.select("div.poster > img")?.attr("data-src") + // Get Title and Year + val name = urlTitle?.select("h3")?.text() ?: "" + 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() + } + MovieSearchResponse( name, link, diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt index f2436812..86581613 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.movieproviders import com.fasterxml.jackson.module.kotlin.readValue import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.extractors.* +import com.lagradost.cloudstream3.extractors.XStreamCdn import com.lagradost.cloudstream3.extractors.helper.AsianEmbedHelper import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.ExtractorLink @@ -144,7 +144,7 @@ class WatchAsianProvider : MainAPI() { //If there's only 1 episode, consider it a movie. if (episodeList.size == 1) { //Clean title - title = title.removeSuffix("Episode 1") + title = title.trim().removeSuffix("Episode 1") val streamlink = getServerLinks(episodeList[0].data) //Log.i(this.name, "Result => (streamlink) $streamlink") return MovieLoadResponse(title, url, this.name, TvType.Movie, streamlink, poster, year, descript, null, null) @@ -178,11 +178,20 @@ class WatchAsianProvider : MainAPI() { count++ val url = fixUrl(item.trim()) //Log.i(this.name, "Result => (url) $url") - if (url.startsWith("https://asianembed.io")) { - // Fetch links - AsianEmbedHelper.getUrls(url, callback) - } else { - loadExtractor(url, mainUrl, callback) + when { + url.startsWith("https://asianembed.io") || url.startsWith("https://asianload.io") -> { + AsianEmbedHelper.getUrls(url, callback) + } + url.startsWith("https://embedsito.com") -> { + val extractor = XStreamCdn() + extractor.domainUrl = "embedsito.com" + extractor.getSafeUrl(url)?.apmap { link -> + callback.invoke(link) + } + } + else -> { + loadExtractor(url, mainUrl, callback) + } } } return count > 0