cloudstream-extensions-hexated/Minioppai/src/main/kotlin/com/hexated/Extractors.kt

85 lines
2.6 KiB
Kotlin
Raw Normal View History

2023-08-01 23:30:41 +00:00
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.fixTitle
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
2024-01-17 08:20:26 +00:00
import com.lagradost.cloudstream3.utils.Qualities
2023-08-01 23:30:41 +00:00
import com.lagradost.cloudstream3.utils.fixUrl
import com.lagradost.cloudstream3.utils.getAndUnpack
import com.lagradost.cloudstream3.utils.getQualityFromName
2023-08-07 14:17:34 +00:00
class Paistream : Streampai() {
override val name = "Paistream"
override val mainUrl = "https://paistream.my.id"
}
2023-09-03 02:12:38 +00:00
class TvMinioppai : Streampai() {
2023-09-09 12:16:04 +00:00
override val name = "Minioppai"
2023-09-03 02:12:38 +00:00
override val mainUrl = "https://tv.minioppai.org"
}
2023-08-01 23:30:41 +00:00
open class Streampai : ExtractorApi() {
override val name = "Streampai"
override val mainUrl = "https://streampai.my.id"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
2024-01-17 08:20:26 +00:00
val res = app.get(url, referer = referer).document
val data = res.selectFirst("script:containsData(player =)")?.data() ?: return
2023-08-01 23:30:41 +00:00
2024-01-17 12:51:51 +00:00
val sources = data.substringAfter("sources: [").substringBefore("]")
2024-01-17 08:20:26 +00:00
.addMarks("src")
.addMarks("type")
.addMarks("size")
.replace("\'", "\"")
2023-08-01 23:30:41 +00:00
2024-01-17 12:51:51 +00:00
val tracks = data.substringAfter("tracks: [").substringBefore("]")
.replace("\'", "\"")
2023-08-01 23:30:41 +00:00
tryParseJson<List<Responses>>("[$sources]")?.forEach {
callback.invoke(
ExtractorLink(
this.name,
this.name,
2024-01-17 08:20:26 +00:00
fixUrl(it.src),
2023-12-06 04:15:42 +00:00
url,
2024-01-17 08:20:26 +00:00
it.size ?: Qualities.Unknown.value,
2023-08-01 23:30:41 +00:00
headers = mapOf(
"Range" to "bytes=0-",
2024-01-17 08:20:26 +00:00
),
2023-08-01 23:30:41 +00:00
)
)
}
2024-01-17 12:51:51 +00:00
tryParseJson<List<Responses>>("[$tracks]")?.forEach {
subtitleCallback.invoke(
SubtitleFile(
fixTitle(it.label ?: return@forEach),
fixUrl(it.src)
)
)
}
2024-01-17 08:20:26 +00:00
}
2023-08-01 23:30:41 +00:00
2024-01-17 08:20:26 +00:00
private fun String.addMarks(str: String): String {
return this.replace(Regex("\"?$str\"?"), "\"$str\"")
2023-08-01 23:30:41 +00:00
}
data class Responses(
2024-01-17 08:20:26 +00:00
@JsonProperty("src") val src: String,
2023-08-01 23:30:41 +00:00
@JsonProperty("type") val type: String?,
2024-01-17 12:51:51 +00:00
@JsonProperty("label") val label: String?,
2024-01-17 08:20:26 +00:00
@JsonProperty("size") val size: Int?
2023-08-01 23:30:41 +00:00
)
}