forked from recloudstream/cloudstream
kdramahood: add default source and subtitle (#629)
* kdramahood: add default source and subtitle * applied PR changes
This commit is contained in:
parent
d1278f97e7
commit
56fb9fcb7c
1 changed files with 78 additions and 18 deletions
|
@ -1,11 +1,15 @@
|
||||||
package com.lagradost.cloudstream3.movieproviders
|
package com.lagradost.cloudstream3.movieproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
import android.util.Log
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.extractors.*
|
import com.lagradost.cloudstream3.extractors.*
|
||||||
import com.lagradost.cloudstream3.extractors.helper.AsianEmbedHelper
|
import com.lagradost.cloudstream3.extractors.helper.AsianEmbedHelper
|
||||||
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
|
|
||||||
|
@ -18,6 +22,11 @@ class KdramaHoodProvider : MainAPI() {
|
||||||
override val hasDownloadSupport = true
|
override val hasDownloadSupport = true
|
||||||
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie)
|
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie)
|
||||||
|
|
||||||
|
private data class ResponseDatas(
|
||||||
|
@JsonProperty("label") val label: String,
|
||||||
|
@JsonProperty("file") val file: String
|
||||||
|
)
|
||||||
|
|
||||||
override suspend fun getMainPage(): HomePageResponse {
|
override suspend fun getMainPage(): HomePageResponse {
|
||||||
val doc = app.get("$mainUrl/home2").document
|
val doc = app.get("$mainUrl/home2").document
|
||||||
val home = ArrayList<HomePageList>()
|
val home = ArrayList<HomePageList>()
|
||||||
|
@ -154,6 +163,16 @@ class KdramaHoodProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Fetch default source and subtitles
|
||||||
|
epVidLinkEl.select("div.embed2")?.forEach { defsrc ->
|
||||||
|
if (defsrc == null) { return@forEach }
|
||||||
|
val scriptstring = defsrc.toString()
|
||||||
|
if (scriptstring.contains("sources: [{")) {
|
||||||
|
"(?<=playerInstance2.setup\\()([\\s\\S]*?)(?=\\);)".toRegex().find(scriptstring)?.value?.let { itemjs ->
|
||||||
|
listOfLinks.add("$mainUrl$itemjs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TvSeriesEpisode(
|
TvSeriesEpisode(
|
||||||
name = null,
|
name = null,
|
||||||
|
@ -199,27 +218,68 @@ class KdramaHoodProvider : MainAPI() {
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var count = 0
|
var count = 0
|
||||||
mapper.readValue<List<String>>(data).apmap { item ->
|
parseJson<List<String>>(data).apmap { item ->
|
||||||
if (item.isNotBlank()) {
|
if (item.isNotBlank()) {
|
||||||
count++
|
count++
|
||||||
var url = item.trim()
|
if (item.startsWith(mainUrl)) {
|
||||||
if (url.startsWith("//")) {
|
val text = item.substring(mainUrl.length)
|
||||||
url = "https:$url"
|
//Log.i(this.name, "Result => (text) $text")
|
||||||
}
|
//Find video files
|
||||||
//Log.i(this.name, "Result => (url) ${url}")
|
try {
|
||||||
when {
|
"(?<=sources: )([\\s\\S]*?)(?<=])".toRegex().find(text)?.value?.let { vid ->
|
||||||
url.startsWith("https://asianembed.io") -> {
|
parseJson<List<ResponseDatas>>(vid).forEach { src ->
|
||||||
AsianEmbedHelper.getUrls(url, callback)
|
//Log.i(this.name, "Result => (src) ${src.toJson()}")
|
||||||
}
|
callback(
|
||||||
url.startsWith("https://embedsito.com") -> {
|
ExtractorLink(
|
||||||
val extractor = XStreamCdn()
|
name = "$name ${src.label}",
|
||||||
extractor.domainUrl = "embedsito.com"
|
url = src.file,
|
||||||
extractor.getUrl(url).forEach { link ->
|
quality = getQualityFromName(src.label),
|
||||||
callback.invoke(link)
|
referer = mainUrl,
|
||||||
|
source = name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logError(e)
|
||||||
}
|
}
|
||||||
else -> {
|
//Find subtitles
|
||||||
loadExtractor(url, mainUrl, callback)
|
try {
|
||||||
|
"(?<=tracks: )([\\s\\S]*?)(?<=])".toRegex().find(text)?.value?.let { sub ->
|
||||||
|
val subtext = sub.replace("file:", "\"file\":")
|
||||||
|
.replace("label:", "\"label\":")
|
||||||
|
.replace("kind:", "\"kind\":")
|
||||||
|
parseJson<List<ResponseDatas>>(subtext).forEach { src ->
|
||||||
|
//Log.i(this.name, "Result => (sub) ${src.toJson()}")
|
||||||
|
subtitleCallback(
|
||||||
|
SubtitleFile(
|
||||||
|
lang = src.label,
|
||||||
|
url = src.file
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logError(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
val url = fixUrl(item.trim())
|
||||||
|
//Log.i(this.name, "Result => (url) $url")
|
||||||
|
when {
|
||||||
|
url.startsWith("https://asianembed.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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
loadExtractor(url, mainUrl, callback)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue