2022-09-09 16:09:54 +00:00
|
|
|
package com.hexated
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty
|
|
|
|
import com.lagradost.cloudstream3.*
|
2022-11-01 23:44:15 +00:00
|
|
|
import com.lagradost.cloudstream3.extractors.XStreamCdn
|
2022-09-09 16:09:54 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
|
|
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
|
|
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
|
|
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
|
|
|
import org.jsoup.Jsoup
|
|
|
|
import org.jsoup.nodes.Element
|
|
|
|
|
2023-07-22 07:59:26 +00:00
|
|
|
open class DramaidProvider : MainAPI() {
|
2023-02-21 09:02:45 +00:00
|
|
|
override var mainUrl = "https://dramaid.best"
|
2022-09-09 16:09:54 +00:00
|
|
|
override var name = "DramaId"
|
|
|
|
override val hasMainPage = true
|
|
|
|
override var lang = "id"
|
|
|
|
override val supportedTypes = setOf(TvType.AsianDrama)
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
fun getStatus(t: String): ShowStatus {
|
|
|
|
return when (t) {
|
|
|
|
"Completed" -> ShowStatus.Completed
|
|
|
|
"Ongoing" -> ShowStatus.Ongoing
|
|
|
|
else -> ShowStatus.Completed
|
|
|
|
}
|
|
|
|
}
|
2023-07-22 07:59:26 +00:00
|
|
|
|
|
|
|
fun getType(t: String?): TvType {
|
|
|
|
return when {
|
|
|
|
t?.contains("Movie", true) == true -> TvType.Movie
|
|
|
|
t?.contains("Anime", true) == true -> TvType.Anime
|
|
|
|
else -> TvType.AsianDrama
|
|
|
|
}
|
|
|
|
}
|
2022-09-09 16:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override val mainPage = mainPageOf(
|
|
|
|
"&status=&type=&order=update" to "Drama Terbaru",
|
|
|
|
"&order=latest" to "Baru Ditambahkan",
|
|
|
|
"&status=&type=&order=popular" to "Drama Popular",
|
|
|
|
)
|
|
|
|
|
|
|
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
|
|
|
val document = app.get("$mainUrl/series/?page=$page${request.data}").document
|
|
|
|
val home = document.select("article[itemscope=itemscope]").mapNotNull {
|
|
|
|
it.toSearchResult()
|
|
|
|
}
|
|
|
|
return newHomePageResponse(request.name, home)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun getProperDramaLink(uri: String): String {
|
2023-07-22 07:59:26 +00:00
|
|
|
return if (uri.contains("-episode-")) {
|
2022-09-09 16:09:54 +00:00
|
|
|
"$mainUrl/series/" + Regex("$mainUrl/(.+)-ep.+").find(uri)?.groupValues?.get(1)
|
2023-07-22 07:59:26 +00:00
|
|
|
} else {
|
|
|
|
uri
|
2022-09-09 16:09:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun Element.toSearchResult(): SearchResponse? {
|
|
|
|
val href = getProperDramaLink(this.selectFirst("a.tip")!!.attr("href"))
|
|
|
|
val title = this.selectFirst("h2[itemprop=headline]")?.text()?.trim() ?: return null
|
2023-07-22 07:59:26 +00:00
|
|
|
val posterUrl = fixUrlNull(
|
|
|
|
this.selectFirst("noscript img")?.attr("src") ?: this.selectFirst("img")?.attr("src")
|
|
|
|
)
|
2022-09-09 16:09:54 +00:00
|
|
|
|
|
|
|
return newTvSeriesSearchResponse(title, href, TvType.AsianDrama) {
|
|
|
|
this.posterUrl = posterUrl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun search(query: String): List<SearchResponse> {
|
2023-07-22 07:59:26 +00:00
|
|
|
val document = app.get("$mainUrl/?s=$query").document
|
|
|
|
return document.select("article[itemscope=itemscope]").mapNotNull {
|
|
|
|
it.toSearchResult()
|
2022-09-09 16:09:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun load(url: String): LoadResponse {
|
|
|
|
val document = app.get(url).document
|
|
|
|
|
2023-07-22 07:59:26 +00:00
|
|
|
val title = document.selectFirst("h1.entry-title")?.text()?.trim() ?: ""
|
|
|
|
val poster = fixUrlNull(document.selectFirst("div.thumb noscript img")?.attr("src") ?: document.selectFirst("div.thumb img")?.attr("src"))
|
2022-09-09 16:09:54 +00:00
|
|
|
val tags = document.select(".genxed > a").map { it.text() }
|
2023-07-22 07:59:26 +00:00
|
|
|
val type = document.selectFirst(".info-content .spe span:contains(Tipe:)")?.ownText()
|
2022-09-09 16:09:54 +00:00
|
|
|
val year = Regex("\\d, ([0-9]*)").find(
|
|
|
|
document.selectFirst(".info-content > .spe > span > time")!!.text().trim()
|
|
|
|
)?.groupValues?.get(1).toString().toIntOrNull()
|
|
|
|
val status = getStatus(
|
|
|
|
document.select(".info-content > .spe > span:nth-child(1)")
|
|
|
|
.text().trim().replace("Status: ", "")
|
|
|
|
)
|
|
|
|
val description = document.select(".entry-content > p").text().trim()
|
|
|
|
|
2023-07-22 07:59:26 +00:00
|
|
|
val episodes = document.select(".eplister > ul > li").mapNotNull {
|
|
|
|
val name = it.selectFirst("a > .epl-title")?.text()
|
|
|
|
val link = fixUrl(it.selectFirst("a")?.attr("href") ?: return@mapNotNull null)
|
|
|
|
val epNum = it.selectFirst(".epl-num")?.text()?.toIntOrNull()
|
|
|
|
Episode(
|
|
|
|
link,
|
|
|
|
name,
|
|
|
|
episode = epNum
|
|
|
|
)
|
2022-09-09 16:09:54 +00:00
|
|
|
}.reversed()
|
|
|
|
|
|
|
|
val recommendations =
|
2023-07-22 07:59:26 +00:00
|
|
|
document.select(".listupd > article[itemscope=itemscope]").mapNotNull { rec ->
|
|
|
|
rec.toSearchResult()
|
2022-09-09 16:09:54 +00:00
|
|
|
}
|
|
|
|
|
2023-07-22 07:59:26 +00:00
|
|
|
return newTvSeriesLoadResponse(
|
|
|
|
title,
|
|
|
|
url,
|
|
|
|
getType(type),
|
|
|
|
episodes = episodes
|
|
|
|
) {
|
|
|
|
posterUrl = poster
|
|
|
|
this.year = year
|
|
|
|
showStatus = status
|
|
|
|
plot = description
|
|
|
|
this.tags = tags
|
|
|
|
this.recommendations = recommendations
|
2022-09-09 16:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private data class Sources(
|
|
|
|
@JsonProperty("file") val file: String,
|
|
|
|
@JsonProperty("label") val label: String,
|
|
|
|
@JsonProperty("type") val type: String,
|
|
|
|
@JsonProperty("default") val default: Boolean?
|
|
|
|
)
|
|
|
|
|
|
|
|
private data class Tracks(
|
|
|
|
@JsonProperty("file") val file: String,
|
|
|
|
@JsonProperty("label") val label: String,
|
|
|
|
@JsonProperty("kind") val type: String,
|
|
|
|
@JsonProperty("default") val default: Boolean?
|
|
|
|
)
|
|
|
|
|
|
|
|
private suspend fun invokeDriveSource(
|
|
|
|
url: String,
|
|
|
|
name: String,
|
|
|
|
subCallback: (SubtitleFile) -> Unit,
|
|
|
|
sourceCallback: (ExtractorLink) -> Unit
|
|
|
|
) {
|
|
|
|
val server = app.get(url).document.selectFirst(".picasa")?.nextElementSibling()?.data()
|
|
|
|
|
|
|
|
val source = "[${server!!.substringAfter("sources: [").substringBefore("],")}]".trimIndent()
|
|
|
|
val trackers = server.substringAfter("tracks:[").substringBefore("],")
|
|
|
|
.replace("//language", "")
|
|
|
|
.replace("file", "\"file\"")
|
|
|
|
.replace("label", "\"label\"")
|
|
|
|
.replace("kind", "\"kind\"").trimIndent()
|
|
|
|
|
|
|
|
tryParseJson<List<Sources>>(source)?.map {
|
|
|
|
sourceCallback(
|
|
|
|
ExtractorLink(
|
|
|
|
name,
|
|
|
|
"Drive",
|
|
|
|
fixUrl(it.file),
|
|
|
|
referer = "https://motonews.club/",
|
|
|
|
quality = getQualityFromName(it.label)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
tryParseJson<Tracks>(trackers)?.let {
|
|
|
|
subCallback.invoke(
|
|
|
|
SubtitleFile(
|
|
|
|
if (it.label.contains("Indonesia")) "${it.label}n" else it.label,
|
|
|
|
it.file
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun loadLinks(
|
|
|
|
data: String,
|
|
|
|
isCasting: Boolean,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
|
|
|
val document = app.get(data).document
|
|
|
|
val sources = document.select(".mobius > .mirror > option").mapNotNull {
|
|
|
|
fixUrl(Jsoup.parse(base64Decode(it.attr("value"))).select("iframe").attr("src"))
|
|
|
|
}
|
|
|
|
|
|
|
|
sources.map {
|
|
|
|
it.replace("https://ndrama.xyz", "https://www.fembed.com")
|
|
|
|
}.apmap {
|
|
|
|
when {
|
2023-07-21 13:47:12 +00:00
|
|
|
it.contains("motonews") -> invokeDriveSource(
|
2022-11-01 23:44:15 +00:00
|
|
|
it,
|
|
|
|
this.name,
|
|
|
|
subtitleCallback,
|
|
|
|
callback
|
|
|
|
)
|
2023-07-22 07:59:26 +00:00
|
|
|
|
2022-09-09 16:09:54 +00:00
|
|
|
else -> loadExtractor(it, data, subtitleCallback, callback)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-11-01 23:44:15 +00:00
|
|
|
|
|
|
|
class Vanfem : XStreamCdn() {
|
|
|
|
override val name: String = "Vanfem"
|
|
|
|
override val mainUrl: String = "https://vanfem.com"
|
|
|
|
}
|
|
|
|
|