63 lines
2.1 KiB
Kotlin
63 lines
2.1 KiB
Kotlin
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.ExtractorApi
|
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
|
import com.lagradost.cloudstream3.utils.Qualities
|
|
|
|
open class Gofile : ExtractorApi() {
|
|
override val name = "Gofile"
|
|
override val mainUrl = "https://gofile.io"
|
|
override val requiresReferer = false
|
|
private val mainApi = "https://api.gofile.io"
|
|
|
|
override suspend fun getUrl(
|
|
url: String,
|
|
referer: String?,
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
callback: (ExtractorLink) -> Unit
|
|
) {
|
|
val id = Regex("/(?:\\?c=|d/)([\\da-zA-Z-]+)").find(url)?.groupValues?.get(1)
|
|
val token = app.get("$mainApi/createAccount").parsedSafe<Account>()?.data?.get("token")
|
|
val websiteToken = app.get("$mainUrl/dist/js/alljs.js").text.let {
|
|
Regex("fetchData.wt\\s*=\\s*\"([^\"]+)").find(it)?.groupValues?.get(1)
|
|
}
|
|
app.get("$mainApi/getContent?contentId=$id&token=$token&wt=$websiteToken")
|
|
.parsedSafe<Source>()?.data?.contents?.forEach {
|
|
callback.invoke(
|
|
ExtractorLink(
|
|
this.name,
|
|
this.name,
|
|
it.value["link"] ?: return,
|
|
"",
|
|
getQuality(it.value["name"]),
|
|
headers = mapOf(
|
|
"Cookie" to "accountToken=$token"
|
|
)
|
|
)
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
private fun getQuality(str: String?): Int {
|
|
return Regex("(\\d{3,4})[pP]").find(str ?: "")?.groupValues?.getOrNull(1)?.toIntOrNull()
|
|
?: Qualities.Unknown.value
|
|
}
|
|
|
|
data class Account(
|
|
@JsonProperty("data") val data: HashMap<String, String>? = null,
|
|
)
|
|
|
|
data class Data(
|
|
@JsonProperty("contents") val contents: HashMap<String, HashMap<String, String>>? = null,
|
|
)
|
|
|
|
data class Source(
|
|
@JsonProperty("data") val data: Data? = null,
|
|
)
|
|
|
|
}
|