2022-10-10 19:43:56 +00:00
|
|
|
package com.lagradost.cloudstream3.extractors
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty
|
|
|
|
import com.lagradost.cloudstream3.SubtitleFile
|
|
|
|
import com.lagradost.cloudstream3.app
|
|
|
|
import com.lagradost.cloudstream3.utils.*
|
|
|
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
|
|
|
|
|
|
|
class Vidmolyme : Vidmoly() {
|
|
|
|
override val mainUrl = "https://vidmoly.me"
|
|
|
|
}
|
|
|
|
|
|
|
|
open class Vidmoly : ExtractorApi() {
|
|
|
|
override val name = "Vidmoly"
|
|
|
|
override val mainUrl = "https://vidmoly.to"
|
|
|
|
override val requiresReferer = true
|
|
|
|
|
|
|
|
private fun String.addMarks(str: String): String {
|
|
|
|
return this.replace(Regex("\"?$str\"?"), "\"$str\"")
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun getUrl(
|
|
|
|
url: String,
|
|
|
|
referer: String?,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
) {
|
2024-04-21 23:14:36 +00:00
|
|
|
val headers = mapOf(
|
|
|
|
"User-Agent" to "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36",
|
|
|
|
"Sec-Fetch-Dest" to "iframe"
|
|
|
|
)
|
2022-10-10 19:43:56 +00:00
|
|
|
val script = app.get(
|
|
|
|
url,
|
2024-04-21 23:14:36 +00:00
|
|
|
headers = headers,
|
2022-10-10 19:43:56 +00:00
|
|
|
referer = referer,
|
|
|
|
).document.select("script")
|
|
|
|
.find { it.data().contains("sources:") }?.data()
|
|
|
|
val videoData = script?.substringAfter("sources: [")
|
|
|
|
?.substringBefore("],")?.addMarks("file")
|
|
|
|
val subData = script?.substringAfter("tracks: [")?.substringBefore("]")?.addMarks("file")
|
|
|
|
?.addMarks("label")?.addMarks("kind")
|
|
|
|
|
|
|
|
tryParseJson<Source>(videoData)?.file?.let { m3uLink ->
|
|
|
|
M3u8Helper.generateM3u8(
|
|
|
|
name,
|
|
|
|
m3uLink,
|
|
|
|
"$mainUrl/"
|
|
|
|
).forEach(callback)
|
|
|
|
}
|
|
|
|
|
|
|
|
tryParseJson<List<SubSource>>("[${subData}]")
|
|
|
|
?.filter { it.kind == "captions" }?.map {
|
|
|
|
subtitleCallback.invoke(
|
|
|
|
SubtitleFile(
|
|
|
|
it.label.toString(),
|
|
|
|
fixUrl(it.file.toString())
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private data class Source(
|
|
|
|
@JsonProperty("file") val file: String? = null,
|
|
|
|
)
|
|
|
|
|
|
|
|
private data class SubSource(
|
|
|
|
@JsonProperty("file") val file: String? = null,
|
|
|
|
@JsonProperty("label") val label: String? = null,
|
|
|
|
@JsonProperty("kind") val kind: String? = null,
|
|
|
|
)
|
|
|
|
|
2024-04-21 23:14:36 +00:00
|
|
|
}
|