35 lines
827 B
Kotlin
35 lines
827 B
Kotlin
|
package com.hexated
|
||
|
|
||
|
fun String.fixSourceUrl() : String {
|
||
|
return this.replace("/manifest.json", "").replace("stremio://", "https://")
|
||
|
}
|
||
|
|
||
|
fun getEpisodeSlug(
|
||
|
season: Int? = null,
|
||
|
episode: Int? = null,
|
||
|
): Pair<String, String> {
|
||
|
return if (season == null && episode == null) {
|
||
|
"" to ""
|
||
|
} else {
|
||
|
(if (season!! < 10) "0$season" else "$season") to (if (episode!! < 10) "0$episode" else "$episode")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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"
|
||
|
}
|
||
|
}
|