fix Nimegami

This commit is contained in:
alex 2024-01-15 20:04:54 +07:00
parent ee89e90282
commit f79dc0209d
3 changed files with 31 additions and 24 deletions

View file

@ -51,3 +51,32 @@ open class Mitedrive : ExtractorApi() {
)
}
open class Berkasdrive : ExtractorApi() {
override val name = "Berkasdrive"
override val mainUrl = "https://dl.berkasdrive.com"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val res = app.get(url, referer = referer).document
val video = res.select("video#player source").attr("src")
callback.invoke(
ExtractorLink(
this.name,
this.name,
video,
"$mainUrl/",
Qualities.Unknown.value,
INFER_TYPE
)
)
}
}

View file

@ -9,7 +9,6 @@ import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import java.net.URI
class Nimegami : MainAPI() {
override var mainUrl = "https://nimegami.id"
@ -150,7 +149,7 @@ class Nimegami : MainAPI() {
tryParseJson<ArrayList<Sources>>(base64Decode(data))?.map { sources ->
sources.url?.apmap { url ->
loadFixedExtractor(
url.fixIframe(),
url,
sources.format,
"$mainUrl/",
subtitleCallback,
@ -185,32 +184,10 @@ class Nimegami : MainAPI() {
}
}
private fun getBaseUrl(url: String): String {
return URI(url).let {
"${it.scheme}://${it.host}"
}
}
private fun Elements.getContent(css: String): Elements {
return this.select("tr:contains($css) td:last-child")
}
private fun String.fixIframe(): String {
val url = base64Decode(this.substringAfter("url=").substringAfter("id="))
return when {
url.contains("hxfile") -> {
val host = getBaseUrl(url)
val id = url.substringAfterLast("/")
"$host/embed-$id.html"
}
url.startsWith("https://mitedrive.my.id") -> url.replace(
"https://mitedrive.my.id",
"https://mitedrive.com"
)
else -> fixUrl(url)
}
}
data class Sources(
@JsonProperty("format") val format: String? = null,
@JsonProperty("url") val url: ArrayList<String>? = arrayListOf(),

View file

@ -11,5 +11,6 @@ class NimegamiPlugin: Plugin() {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(Nimegami())
registerExtractorAPI(Mitedrive())
registerExtractorAPI(Berkasdrive())
}
}