Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.lagradost.api

actual fun getContext(): Any? = null
actual fun setContext(context: Any?) = Unit
21 changes: 21 additions & 0 deletions library/src/webMain/kotlin/com/lagradost/api/Log.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.lagradost.api

actual object Log {
actual fun d(tag: String, message: String) {
// There is no console.debug in Kotlin/JS (Yet)
// We will switch this when it is added.
console.log("[$tag] $message")
Comment thread
fire-light42 marked this conversation as resolved.
}

actual fun i(tag: String, message: String) {
console.info("[$tag] $message")
}

actual fun w(tag: String, message: String) {
console.warn("[$tag] $message")
}

actual fun e(tag: String, message: String) {
console.error("[$tag] $message")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.lagradost.cloudstream3.extractors

import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink

/**
* Web/JS target shim.
*
* NewPipeExtractor is JVM-only, so the full extraction logic used on
* Android/desktop can't run here. This stub keeps the multiplatform
* source set compiling; it performs no extraction and simply reports
* that no links were found on this target.
*
* If/when a JS-compatible YouTube extraction path exists, replace the
* body of getUrl() with that implementation.
*/
actual open class YoutubeExtractor actual constructor() : ExtractorApi() {

actual override val mainUrl = "https://www.youtube.com"
actual override val name = "YouTube"
actual override val requiresReferer = false

actual override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit,
) {
// No-op on web target: NewPipeExtractor is unavailable here.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.lagradost.cloudstream3.mvvm

actual fun <T> platformThrowAbleToResource(throwable: Throwable): Resource<T> {
val message = throwable.message.orEmpty()
return when {
message.contains("timeout", ignoreCase = true) -> {
Resource.Failure(
true,
"Connection Timeout\nPlease try again later."
)
}

message.contains("NetworkError", ignoreCase = true) ||
message.contains("Failed to fetch", ignoreCase = true) ||
message.contains("ERR_NAME_NOT_RESOLVED", ignoreCase = true) -> {
Resource.Failure(
true,
"Cannot connect to server, try again later.\n${throwable.message}"
)
}

message.contains("SSL", ignoreCase = true) ||
message.contains("certificate", ignoreCase = true) -> {
Resource.Failure(
true,
(throwable.message ?: "SSL error") + "\nTry a VPN or DNS."
)
}

else -> safeFail(throwable)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.lagradost.cloudstream3.utils

import androidx.annotation.AnyThread
import androidx.annotation.MainThread
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers

actual val workerDispatcher: CoroutineDispatcher = Dispatchers.Default
internal actual annotation class WorkerThread()

@AnyThread
actual fun runOnMainThreadNative(@MainThread work: () -> Unit) {
work.invoke()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.lagradost.cloudstream3.utils

import kotlin.test.Ignore

actual typealias IgnoreOnWeb = Ignore