2023-01-22 16:05:27 +00:00
|
|
|
package com.hexated
|
|
|
|
|
|
|
|
import android.util.Base64
|
|
|
|
import com.hexated.KickassanimeExtractor.mainUrl
|
|
|
|
import com.lagradost.cloudstream3.app
|
|
|
|
import com.lagradost.cloudstream3.utils.AppUtils
|
|
|
|
import com.lagradost.cloudstream3.utils.SubtitleHelper
|
|
|
|
import java.net.URI
|
|
|
|
import java.net.URLDecoder
|
|
|
|
|
|
|
|
suspend fun String.fixIframe(): List<Pair<String?, String?>> {
|
|
|
|
return when {
|
|
|
|
this.startsWith("${Kickassanime.kaast}/dust/") -> {
|
|
|
|
val document = app.get(this).document
|
|
|
|
document.selectFirst("script:containsData(sources =)")?.data()
|
|
|
|
?.substringAfter("sources = [")?.substringBefore("];")?.let {
|
|
|
|
AppUtils.tryParseJson<List<Kickassanime.Iframe>>("[$it]")?.map { source ->
|
|
|
|
source.name to source.src
|
|
|
|
}
|
|
|
|
} ?: emptyList()
|
|
|
|
}
|
|
|
|
this.startsWith("${Kickassanime.kaast}/axplayer/") -> {
|
|
|
|
val source = decode(
|
|
|
|
this.substringAfter("&data=").substringBefore("&vref=")
|
|
|
|
)
|
2023-02-04 07:44:26 +00:00
|
|
|
listOf("gogo" to source)
|
2023-01-22 16:05:27 +00:00
|
|
|
}
|
|
|
|
else -> {
|
|
|
|
emptyList()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun String.base64Decode(): String {
|
|
|
|
return Base64.decode(this, Base64.DEFAULT).toString(Charsets.UTF_8)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun decode(input: String): String =
|
|
|
|
URLDecoder.decode(input, "utf-8").replace(" ", "%20")
|
|
|
|
|
2023-02-02 14:19:45 +00:00
|
|
|
fun String.createSlug(): String {
|
|
|
|
return this.replace(Regex("[^\\w ]+"), "").replace(" ", "-").lowercase()
|
|
|
|
}
|
|
|
|
|
2023-01-25 10:18:06 +00:00
|
|
|
fun String.getTrackerTitle(): String {
|
|
|
|
val blacklist = arrayOf(
|
|
|
|
"Dub",
|
|
|
|
"Uncensored",
|
|
|
|
"TV",
|
|
|
|
"JPN DUB",
|
|
|
|
"Uncensored"
|
|
|
|
).joinToString("|") { "\\($it\\)" }
|
|
|
|
return this.replace(Regex(blacklist), "").trim()
|
2023-01-22 16:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fun getImageUrl(link: String?): String? {
|
|
|
|
if (link == null) return null
|
|
|
|
return if (link.startsWith(mainUrl)) link else "$mainUrl/uploads/$link"
|
|
|
|
}
|
|
|
|
|
|
|
|
fun getBaseUrl(url: String): String {
|
|
|
|
return URI(url).let {
|
|
|
|
"${it.scheme}://${it.host}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-08 09:17:32 +00:00
|
|
|
|
2023-01-22 16:05:27 +00:00
|
|
|
fun getLanguage(language: String?): String? {
|
|
|
|
return SubtitleHelper.fromTwoLettersToLanguage(language ?: return null)
|
|
|
|
?: SubtitleHelper.fromTwoLettersToLanguage(language.substringBefore("-"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fun fixUrl(url: String, domain: String): String {
|
|
|
|
if (url.startsWith("http")) {
|
|
|
|
return url
|
|
|
|
}
|
|
|
|
if (url.isEmpty()) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
val startsWithNoHttp = url.startsWith("//")
|
|
|
|
if (startsWithNoHttp) {
|
|
|
|
return "https:$url"
|
|
|
|
} else {
|
|
|
|
if (url.startsWith('/')) {
|
|
|
|
return domain + url
|
|
|
|
}
|
|
|
|
return "$domain/$url"
|
|
|
|
}
|
|
|
|
}
|