mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
* [Feature][WIP] Add option to download subtitles from Opensubtitles.org (#1082) Co-authored-by: Jace <54625750+Jacekun@users.noreply.github.com> Co-authored-by: Jace <jaceorwell@gmail.com> Co-authored-by: LagradOst <11805592+LagradOst@users.noreply.github.com>
30 lines
No EOL
1.1 KiB
Kotlin
30 lines
No EOL
1.1 KiB
Kotlin
package com.lagradost.cloudstream3.metaproviders
|
|
|
|
import com.lagradost.cloudstream3.ErrorLoadingException
|
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.SyncApis
|
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi
|
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi
|
|
import com.lagradost.cloudstream3.utils.SyncUtil
|
|
|
|
object SyncRedirector {
|
|
val syncApis = SyncApis
|
|
|
|
suspend fun redirect(url: String, preferredUrl: String): String {
|
|
for (api in syncApis) {
|
|
if (url.contains(api.mainUrl)) {
|
|
val otherApi = when (api.name) {
|
|
aniListApi.name -> "anilist"
|
|
malApi.name -> "myanimelist"
|
|
else -> return url
|
|
}
|
|
|
|
return SyncUtil.getUrlsFromId(api.getIdFromUrl(url), otherApi).firstOrNull { realUrl ->
|
|
realUrl.contains(preferredUrl)
|
|
} ?: run {
|
|
throw ErrorLoadingException("Page does not exist on $preferredUrl")
|
|
}
|
|
}
|
|
}
|
|
return url
|
|
}
|
|
} |