Fix DramaSeeProvider

This commit is contained in:
Blatzar 2022-07-11 17:37:06 +02:00
parent 4b6d941d4d
commit a4fb12ee88
3 changed files with 89 additions and 92 deletions

View file

@ -92,7 +92,9 @@ class GogoanimeProvider : MainAPI() {
secretDecryptKey: String?, secretDecryptKey: String?,
// This could be removed, but i prefer it verbose // This could be removed, but i prefer it verbose
isUsingAdaptiveKeys: Boolean, isUsingAdaptiveKeys: Boolean,
isUsingAdaptiveData: Boolean isUsingAdaptiveData: Boolean,
// If you don't want to re-fetch the document
iframeDocument: Document? = null
) = safeApiCall { ) = safeApiCall {
// https://github.com/saikou-app/saikou/blob/3e756bd8e876ad7a9318b17110526880525a5cd3/app/src/main/java/ani/saikou/anime/source/extractors/GogoCDN.kt // https://github.com/saikou-app/saikou/blob/3e756bd8e876ad7a9318b17110526880525a5cd3/app/src/main/java/ani/saikou/anime/source/extractors/GogoCDN.kt
// No Licence on the following code // No Licence on the following code
@ -104,9 +106,9 @@ class GogoanimeProvider : MainAPI() {
val id = Regex("id=([^&]+)").find(iframeUrl)!!.value.removePrefix("id=") val id = Regex("id=([^&]+)").find(iframeUrl)!!.value.removePrefix("id=")
var document: Document? = null var document: Document? = iframeDocument
val foundIv = val foundIv =
iv ?: app.get(iframeUrl).document.also { document = it } iv ?: (document ?: app.get(iframeUrl).document.also { document = it })
.select("""div.wrapper[class*=container]""") .select("""div.wrapper[class*=container]""")
.attr("class").split("-").lastOrNull() ?: return@safeApiCall .attr("class").split("-").lastOrNull() ?: return@safeApiCall
val foundKey = secretKey ?: getKey(base64Decode(id) + foundIv) ?: return@safeApiCall val foundKey = secretKey ?: getKey(base64Decode(id) + foundIv) ?: return@safeApiCall

View file

@ -1,11 +1,7 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.animeproviders.GogoanimeProvider.Companion.extractVidstream import com.lagradost.cloudstream3.animeproviders.GogoanimeProvider.Companion.extractVidstream
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 import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
@ -19,25 +15,23 @@ class DramaSeeProvider : MainAPI() {
override val supportedTypes = setOf(TvType.AsianDrama) override val supportedTypes = setOf(TvType.AsianDrama)
override suspend fun getMainPage(): HomePageResponse { override suspend fun getMainPage(): HomePageResponse {
val headers = mapOf("X-Requested-By" to "dramasee.net") val headers = mapOf("X-Requested-By" to mainUrl)
val document = app.get(mainUrl, headers = headers).document val document = app.get(mainUrl, headers = headers).document
val mainbody = document.getElementsByTag("body") val mainbody = document.getElementsByTag("body")
return HomePageResponse( return HomePageResponse(
mainbody?.select("section")?.map { row -> mainbody.select("section.block_area.block_area_home")?.map { main ->
val main = row?.select("main") ?: return@map null val title = main.select("h2.cat-heading").text() ?: "Main"
val title = main.select("div.title > div > h2")?.text() ?: "Main" val inner = main.select("div.flw-item") ?: return@map null
val inner = main.select("li.series-item") ?: return@map null
HomePageList( HomePageList(
title, title,
inner.mapNotNull { inner.mapNotNull {
// 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(it.select("img").attr("data-src")) ?: ""
val name = it?.selectFirst("a.series-name")?.text() ?: "<Untitled>" val name = innerBody?.attr("title") ?: "<Untitled>"
//Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}") //Log.i(this.name, "Result => (innerBody, image) ${innerBody} / ${image}")
MovieSearchResponse( MovieSearchResponse(
name, name,
@ -84,12 +78,12 @@ class DramaSeeProvider : MainAPI() {
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
val doc = app.get(url).document val doc = app.get(url).document
val body = doc.getElementsByTag("body") val body = doc.getElementsByTag("body")
val inner = body?.select("div.series-info") val inner = body?.select("div.anis-content")
// Video details // Video details
val poster = fixUrlNull(inner?.select("div.img > img")?.attr("src")) ?: "" val poster = fixUrlNull(inner?.select("img.film-poster-img")?.attr("src")) ?: ""
//Log.i(this.name, "Result => (imgLinkCode) ${imgLinkCode}") //Log.i(this.name, "Result => (imgLinkCode) ${imgLinkCode}")
val title = inner?.select("h1.series-name")?.text() ?: "" val title = inner?.select("h2.film-name.dynamic-name")?.text() ?: ""
val year = if (title.length > 5) { val year = if (title.length > 5) {
title.substring(title.length - 5) title.substring(title.length - 5)
.trim().trimEnd(')').toIntOrNull() .trim().trimEnd(')').toIntOrNull()
@ -97,15 +91,14 @@ class DramaSeeProvider : MainAPI() {
null null
} }
//Log.i(this.name, "Result => (year) ${title.substring(title.length - 5)}") //Log.i(this.name, "Result => (year) ${title.substring(title.length - 5)}")
val seriesBody = body?.select("div.series-body") val descript = body?.firstOrNull()?.select("div.film-description.m-hide")?.text()
val descript = seriesBody?.firstOrNull()?.select("div.js-content")?.text() val tags = inner?.select("div.item.item-list > a")
val tags = seriesBody?.select("div.series-tags > a")
?.mapNotNull { it?.text()?.trim() ?: return@mapNotNull null } ?.mapNotNull { it?.text()?.trim() ?: return@mapNotNull null }
val recs = body?.select("ul.series > li")?.mapNotNull { val recs = body.select("div.flw-item")?.mapNotNull {
val a = it.select("a.series-img") ?: return@mapNotNull null val a = it.select("a") ?: return@mapNotNull null
val aUrl = fixUrlNull(a.attr("href")) ?: return@mapNotNull null val aUrl = fixUrlNull(a.attr("href")) ?: return@mapNotNull null
val aImg = fixUrlNull(a.select("img")?.attr("src")) val aImg = fixUrlNull(it.select("img")?.attr("data-src"))
val aName = a.select("img")?.attr("alt") ?: return@mapNotNull null val aName = a.attr("title") ?: return@mapNotNull null
val aYear = aName.trim().takeLast(5).removeSuffix(")").toIntOrNull() val aYear = aName.trim().takeLast(5).removeSuffix(")").toIntOrNull()
MovieSearchResponse( MovieSearchResponse(
url = aUrl, url = aUrl,
@ -118,40 +111,41 @@ class DramaSeeProvider : MainAPI() {
} }
// Episodes Links // Episodes Links
val episodeList = ArrayList<Episode>() val episodeUrl = body.select("a.btn.btn-radius.btn-primary.btn-play").attr("href")
body?.select("ul.episodes > li")?.forEach { ep -> val episodeDoc = app.get(episodeUrl).document
val innerA = ep.select("a") ?: return@forEach
val count = innerA.select("span.episode")?.text()?.toIntOrNull() ?: 0
val epLink = fixUrlNull(innerA.attr("href")) ?: return@forEach
//Log.i(this.name, "Result => (epLink) ${epLink}")
if (epLink.isNotBlank()) {
// Fetch video links
val epVidLinkEl = app.get(epLink, referer = mainUrl).document
val ajaxUrl = epVidLinkEl.select("div#js-player")?.attr("embed")
//Log.i(this.name, "Result => (ajaxUrl) ${ajaxUrl}")
if (!ajaxUrl.isNullOrEmpty()) {
val innerPage = app.get(fixUrl(ajaxUrl), referer = epLink).document
val listOfLinks = mutableListOf<String>()
innerPage.select("div.player.active > main > div")?.forEach { em ->
val href = fixUrlNull(em.attr("src")) ?: ""
if (href.isNotBlank()) {
listOfLinks.add(href)
}
}
//Log.i(this.name, "Result => (listOfLinks) ${listOfLinks.toJson()}")
episodeList.add( val episodeList = episodeDoc.select("div.ss-list.ss-list-min > a").mapNotNull { ep ->
val episodeNumber = ep.attr("data-number").toIntOrNull()
val epLink = fixUrlNull(ep.attr("href")) ?: return@mapNotNull null
// if (epLink.isNotBlank()) {
// // Fetch video links
// val epVidLinkEl = app.get(epLink, referer = mainUrl).document
// val ajaxUrl = epVidLinkEl.select("div#js-player")?.attr("embed")
// //Log.i(this.name, "Result => (ajaxUrl) ${ajaxUrl}")
// if (!ajaxUrl.isNullOrEmpty()) {
// val innerPage = app.get(fixUrl(ajaxUrl), referer = epLink).document
// val listOfLinks = mutableListOf<String>()
// innerPage.select("div.player.active > main > div")?.forEach { em ->
// val href = fixUrlNull(em.attr("src")) ?: ""
// if (href.isNotBlank()) {
// listOfLinks.add(href)
// }
// }
//
// //Log.i(this.name, "Result => (listOfLinks) ${listOfLinks.toJson()}")
//
// }
// }
Episode( Episode(
name = null, name = null,
season = null, season = null,
episode = count, episode = episodeNumber,
data = listOfLinks.distinct().toJson(), data = epLink,
posterUrl = poster, posterUrl = null,
date = null date = null
) )
)
}
}
} }
//If there's only 1 episode, consider it a movie. //If there's only 1 episode, consider it a movie.
@ -161,7 +155,7 @@ class DramaSeeProvider : MainAPI() {
url = url, url = url,
apiName = this.name, apiName = this.name,
type = TvType.Movie, type = TvType.Movie,
dataUrl = episodeList[0].data, dataUrl = episodeList.first().data,
posterUrl = poster, posterUrl = poster,
year = year, year = year,
plot = descript, plot = descript,
@ -174,7 +168,7 @@ class DramaSeeProvider : MainAPI() {
url = url, url = url,
apiName = this.name, apiName = this.name,
type = TvType.AsianDrama, type = TvType.AsianDrama,
episodes = episodeList.reversed(), episodes = episodeList,
posterUrl = poster, posterUrl = poster,
year = year, year = year,
plot = descript, plot = descript,
@ -189,33 +183,37 @@ class DramaSeeProvider : MainAPI() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
var count = 0 println("DATATATAT $data")
mapper.readValue<List<String>>(data).apmap { item ->
if (item.isNotEmpty()) { val document = app.get(data).document
count++ val iframeUrl = document.select("iframe").attr("src")
val url = fixUrl(item.trim()) val iframe = app.get(iframeUrl)
//Log.i(this.name, "Result => (url) ${url}") val iframeDoc = iframe.document
when {
url.startsWith("https://asianembed.io") || url.startsWith("https://asianload.io") -> { argamap({
iframeDoc.select(".list-server-items > .linkserver")
.forEach { element ->
val status = element.attr("data-status") ?: return@forEach
if (status != "1") return@forEach
val extractorData = element.attr("data-video") ?: return@forEach
loadExtractor(extractorData, iframe.url, callback)
}
}, {
val iv = "9262859232435825" val iv = "9262859232435825"
val secretKey = "93422192433952489752342908585752" val secretKey = "93422192433952489752342908585752"
extractVidstream(url, this.name, callback, iv, secretKey, secretKey, val secretDecryptKey = "93422192433952489752342908585752"
extractVidstream(
iframe.url,
this.name,
callback,
iv,
secretKey,
secretDecryptKey,
isUsingAdaptiveKeys = false, isUsingAdaptiveKeys = false,
isUsingAdaptiveData = false isUsingAdaptiveData = true,
iframeDocument = iframeDoc
) )
AsianEmbedHelper.getUrls(url, callback) })
} return true
url.startsWith("https://embedsito.com") -> {
val extractor = XStreamCdn()
extractor.domainUrl = "embedsito.com"
extractor.getSafeUrl(url)?.forEach(callback)
}
else -> {
loadExtractor(url, mainUrl, callback)
}
}
}
}
return count > 0
} }
} }

View file

@ -1,12 +1,9 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.select.Elements import org.jsoup.select.Elements
@ -90,7 +87,7 @@ class FilmanProvider : MainAPI() {
val document = Jsoup.parse(response) val document = Jsoup.parse(response)
val documentTitle = document.select("title").text().trim() val documentTitle = document.select("title").text().trim()
if (documentTitle.startsWith("Logowanie")){ if (documentTitle.startsWith("Logowanie")) {
throw RuntimeException("This page seems to be locked behind a login-wall on the website, unable to scrape it. If it is not please report it.") throw RuntimeException("This page seems to be locked behind a login-wall on the website, unable to scrape it. If it is not please report it.")
} }