diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4d04a357625..137d0b08b72 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -32,7 +32,7 @@ jobs: # run: ./gradlew library:checkKotlinAbi - name: Run Gradle - run: ./gradlew assemblePrereleaseDebug + run: ./gradlew assemblePrereleaseDebug lint check - name: Upload Artifact uses: actions/upload-artifact@v7 diff --git a/app/src/main/java/com/lagradost/cloudstream3/CloudStreamApp.kt b/app/src/main/java/com/lagradost/cloudstream3/CloudStreamApp.kt index a9cd9c01edd..4b8e2457931 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CloudStreamApp.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CloudStreamApp.kt @@ -121,7 +121,7 @@ class CloudStreamApp : Application(), SingletonImageLoader.Factory { } fun setKeyClass(path: String, value: T) { - context?.setKey(path, value) + context?.setKey(path, value) } fun removeKeys(folder: String): Int? { @@ -132,6 +132,11 @@ class CloudStreamApp : Application(), SingletonImageLoader.Factory { context?.setKey(path, value) } + @JvmName("setKeyReified") + inline fun setKey(path: String, value: T) { + context?.setKey(path, value) + } + fun setKey(folder: String, path: String, value: T) { context?.setKey(folder, path, value) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt index 02ee697911f..9510c31b7c5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStore.kt @@ -7,6 +7,7 @@ import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.CloudStreamApp.Companion.getKeyClass import com.lagradost.cloudstream3.CloudStreamApp.Companion.removeKey import com.lagradost.cloudstream3.CloudStreamApp.Companion.setKeyClass +import com.lagradost.cloudstream3.InternalAPI import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.AppUtils.toJsonLiteral @@ -170,22 +171,34 @@ object DataStore { } } - fun Context.setKey(path: String, value: T) { + @InternalAPI + fun Context.putStringKey(path: String, value: String?) { try { getSharedPrefs().edit { - putString(path, value?.toJsonLiteral()) + putString(path, value) } } catch (e: Exception) { logError(e) } } + /** Non-reified fallback for binary compat. Prefer the reified overload where possible. */ + fun Context.setKey(path: String, value: T) { + putStringKey(path, value?.toJsonLiteral()) + } + + /** Reified overload, prevents type erasure for generic types. */ + @JvmName("setKeyReified") + inline fun Context.setKey(path: String, value: T) { + putStringKey(path, value.toJsonLiteral()) + } + fun Context.getKey(path: String, valueType: Class): T? { - try { + return try { val json: String = getSharedPrefs().getString(path, null) ?: return null - return parseJson(json, valueType.kotlin) - } catch (e: Exception) { - return null + parseJson(json, valueType.kotlin) + } catch (_: Exception) { + null } } @@ -193,21 +206,37 @@ object DataStore { setKey(getFolderName(folder, path), value) } + @Deprecated( + message = "Use parseJson(this) directly instead.", + level = DeprecationLevel.ERROR, + replaceWith = ReplaceWith( + expression = "parseJson(this)", + imports = ["com.lagradost.cloudstream3.utils.AppUtils.parseJson"], + ), + ) inline fun String.toKotlinObject(): T { return parseJson(this) } + @Deprecated( + message = "Use parseJson(this) directly instead.", + level = DeprecationLevel.ERROR, + replaceWith = ReplaceWith( + expression = "parseJson(this)", + imports = ["com.lagradost.cloudstream3.utils.AppUtils.parseJson"], + ), + ) fun String.toKotlinObject(valueType: Class): T { return parseJson(this, valueType.kotlin) } // GET KEY GIVEN PATH AND DEFAULT VALUE, NULL IF ERROR inline fun Context.getKey(path: String, defVal: T?): T? { - try { + return try { val json: String = getSharedPrefs().getString(path, null) ?: return defVal - return json.toKotlinObject() - } catch (e: Exception) { - return null + parseJson(json) + } catch (_: Exception) { + null } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt index f3866408833..58aae29d348 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/downloader/DownloadQueueManager.kt @@ -53,7 +53,7 @@ object DownloadQueueManager { fun init(context: Context) { ioSafe { _queue.collect { queue -> - setKey(QUEUE_KEY, queue) + setKey>(QUEUE_KEY, queue) } } @@ -247,4 +247,4 @@ object DownloadQueueManager { localQueue.copyOf() } } -} \ No newline at end of file +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 52ceb5c6cde..42d0df92af7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,7 +26,7 @@ junit = "4.13.2" junitKtx = "1.3.0" junitVersion = "1.3.0" juniversalchardet = "2.5.0" -kotlinGradlePlugin = "2.3.20" +kotlinGradlePlugin = "2.4.0" kotlinxAtomicfu = "0.33.0" kotlinxCollectionsImmutable = "0.4.0" kotlinxCoroutines = "1.11.0" diff --git a/library/build.gradle.kts b/library/build.gradle.kts index aa460164ea2..979e09844f7 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -87,18 +87,6 @@ kotlin { androidMain { dependsOn(jvmCommonMain) } jvmMain { dependsOn(jvmCommonMain) } } - - @OptIn(org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation::class) - // https://kotlinlang.org/docs/gradle-binary-compatibility-validation.html - abiValidation { - enabled.set(true) - this.filters { - exclude { - annotatedWith.add("com.lagradost.cloudstream3.Prerelease") - annotatedWith.add("com.lagradost.cloudstream3.InternalAPI") - } - } - } } tasks.withType { diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Blogger.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Blogger.kt index 4fc2ac6c7de..125d74c0c83 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Blogger.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Blogger.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson @@ -39,8 +40,9 @@ open class Blogger : ExtractorApi() { return sources } + @Serializable private data class ResponseSource( - @JsonProperty("play_url") val play_url: String, - @JsonProperty("format_id") val format_id: Int + @SerialName("play_url") val play_url: String, + @SerialName("format_id") val format_id: Int ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt index 5248a886102..7208c9179dc 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByseSX.kt @@ -1,6 +1,8 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.JsonElement import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.base64DecodeArray @@ -128,59 +130,65 @@ open class ByseSX : ExtractorApi() { } } +@Serializable data class DetailsRoot( val id: Long, val code: String, val title: String, - @JsonProperty("poster_url") + @SerialName("poster_url") val posterUrl: String, val description: String, - @JsonProperty("created_at") + @SerialName("created_at") val createdAt: String, - @JsonProperty("owner_private") + @SerialName("owner_private") val ownerPrivate: Boolean, - @JsonProperty("embed_frame_url") + @SerialName("embed_frame_url") val embedFrameUrl: String, ) +@Serializable data class PlaybackRoot( val playback: Playback, ) +@Serializable data class Playback( val algorithm: String, val iv: String, val payload: String, - @JsonProperty("key_parts") + @SerialName("key_parts") val keyParts: List, - @JsonProperty("expires_at") + @SerialName("expires_at") val expiresAt: String, - @JsonProperty("decrypt_keys") + @SerialName("decrypt_keys") val decryptKeys: DecryptKeys, val iv2: String, val payload2: String, ) +@Serializable data class DecryptKeys( - @JsonProperty("edge_1") + @SerialName("edge_1") val edge1: String, - @JsonProperty("edge_2") + @SerialName("edge_2") val edge2: String, - @JsonProperty("legacy_fallback") + @SerialName("legacy_fallback") val legacyFallback: String, ) +@Serializable data class PlaybackDecrypt( val sources: List, ) +@Serializable data class PlaybackDecryptSource( val quality: String, val label: String, - @JsonProperty("mime_type") + @SerialName("mime_type") val mimeType: String, val url: String, - @JsonProperty("bitrate_kbps") + @SerialName("bitrate_kbps") val bitrateKbps: Long, - val height: Any?, + val height: JsonElement?, ) diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GUpload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GUpload.kt index f995f010fc0..d8d895cde48 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GUpload.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GUpload.kt @@ -1,6 +1,8 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.JsonElement import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.base64Decode @@ -39,14 +41,15 @@ open class GUpload: ExtractorApi() { ) } + @Serializable private data class VideoInfo( - @JsonProperty("videoUrl") val videoUrl: String, - @JsonProperty("posterUrl") val posterUrl: String? = null, - @JsonProperty("videoId") val videoId: String? = null, - @JsonProperty("primaryColor") val primaryColor: String? = null, - @JsonProperty("audioTracks") val audioTracks: List = emptyList(), - @JsonProperty("subtitleTracks") val subtitleTracks: List = emptyList(), - @JsonProperty("vastFallbackList") val vastFallbackList: List = emptyList(), - @JsonProperty("videoOwnerId") val videoOwnerId: Long = 0, + @SerialName("videoUrl") val videoUrl: String, + @SerialName("posterUrl") val posterUrl: String? = null, + @SerialName("videoId") val videoId: String? = null, + @SerialName("primaryColor") val primaryColor: String? = null, + @SerialName("audioTracks") val audioTracks: List = emptyList(), + @SerialName("subtitleTracks") val subtitleTracks: List = emptyList(), + @SerialName("vastFallbackList") val vastFallbackList: List = emptyList(), + @SerialName("videoOwnerId") val videoOwnerId: Long = 0, ) -} \ No newline at end of file +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt index 38b90cdb34c..d3a80be5d76 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.fleeksoft.ksoup.nodes.Element import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.extractors.helper.AesHelper.cryptoAESHandler @@ -118,9 +119,10 @@ open class Gdriveplayer : ExtractorApi() { } } + @Serializable data class Tracks( - @JsonProperty("file") val file: String, - @JsonProperty("kind") val kind: String, - @JsonProperty("label") val label: String, + @SerialName("file") val file: String, + @SerialName("kind") val kind: String, + @SerialName("label") val label: String, ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gofile.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gofile.kt index c21a9c44cba..9f66ed14ab8 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gofile.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gofile.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorApi @@ -84,26 +85,31 @@ open class Gofile : ExtractorApi() { } } + @Serializable data class AccountResponse( - @JsonProperty("data") val data: AccountData? = null + @SerialName("data") val data: AccountData? = null ) + @Serializable data class AccountData( - @JsonProperty("token") val token: String? = null + @SerialName("token") val token: String? = null ) + @Serializable data class GofileResponse( - @JsonProperty("data") val data: GofileData? = null + @SerialName("data") val data: GofileData? = null ) + @Serializable data class GofileData( - @JsonProperty("children") val children: Map? = null + @SerialName("children") val children: Map? = null ) + @Serializable data class GofileFile( - @JsonProperty("type") val type: String? = null, - @JsonProperty("name") val name: String? = null, - @JsonProperty("link") val link: String? = null, - @JsonProperty("size") val size: Long? = 0L + @SerialName("type") val type: String? = null, + @SerialName("name") val name: String? = null, + @SerialName("link") val link: String? = null, + @SerialName("size") val size: Long? = 0L ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt index 3fc1ed0f562..9587c616800 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt @@ -2,10 +2,11 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.extractors.helper.AesHelper +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.AppUtils.parseJson @@ -60,11 +61,12 @@ open class HDMomPlayer : ExtractorApi() { ) } + @Serializable data class Track( - @JsonProperty("file") val file: String?, - @JsonProperty("label") val label: String?, - @JsonProperty("kind") val kind: String?, - @JsonProperty("language") val language: String?, - @JsonProperty("default") val default: String? + @SerialName("file") val file: String?, + @SerialName("label") val label: String?, + @SerialName("kind") val kind: String?, + @SerialName("language") val language: String?, + @SerialName("default") val default: String? ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt index 9cff2049fac..a88fb9af04f 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt @@ -5,7 +5,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable open class HDPlayerSystem : ExtractorApi() { override val name = "HDPlayerSystem" @@ -48,10 +49,11 @@ open class HDPlayerSystem : ExtractorApi() { ) } + @Serializable data class SystemResponse( - @JsonProperty("hls") val hls: String, - @JsonProperty("videoImage") val videoImage: String? = null, - @JsonProperty("videoSource") val videoSource: String, - @JsonProperty("securedLink") val securedLink: String + @SerialName("hls") val hls: String, + @SerialName("videoImage") val videoImage: String? = null, + @SerialName("videoSource") val videoSource: String, + @SerialName("securedLink") val securedLink: String ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jeniusplay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jeniusplay.kt index c9a9aadae2f..64404a568bf 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jeniusplay.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jeniusplay.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.extractors.helper.JwPlayerHelper @@ -45,9 +46,10 @@ open class Jeniusplay : ExtractorApi() { } } + @Serializable data class ResponseSource( - @JsonProperty("hls") val hls: Boolean, - @JsonProperty("videoSource") val videoSource: String, - @JsonProperty("securedLink") val securedLink: String?, + @SerialName("hls") val hls: Boolean, + @SerialName("videoSource") val videoSource: String, + @SerialName("securedLink") val securedLink: String?, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Linkbox.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Linkbox.kt index bfa94326aae..415f3d92528 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Linkbox.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Linkbox.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorApi @@ -36,22 +37,26 @@ open class Linkbox : ExtractorApi() { } } + @Serializable data class Resolutions( - @JsonProperty("url") val url: String? = null, - @JsonProperty("resolution") val resolution: String? = null, + @SerialName("url") val url: String? = null, + @SerialName("resolution") val resolution: String? = null, ) + @Serializable data class ItemInfo( - @JsonProperty("resolutionList") val resolutionList: ArrayList? = arrayListOf(), + @SerialName("resolutionList") val resolutionList: ArrayList? = arrayListOf(), ) + @Serializable data class Data( - @JsonProperty("itemInfo") val itemInfo: ItemInfo? = null, - @JsonProperty("itemId") val itemId: String? = null, + @SerialName("itemInfo") val itemInfo: ItemInfo? = null, + @SerialName("itemId") val itemId: String? = null, ) + @Serializable data class Responses( - @JsonProperty("data") val data: Data? = null, + @SerialName("data") val data: Data? = null, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt index f1fd1288caf..437052a4732 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt @@ -5,7 +5,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable open class MailRu : ExtractorApi() { override val name = "MailRu" @@ -40,13 +41,15 @@ open class MailRu : ExtractorApi() { } } + @Serializable data class MailRuData( - @JsonProperty("provider") val provider: String, - @JsonProperty("videos") val videos: List + @SerialName("provider") val provider: String, + @SerialName("videos") val videos: List ) + @Serializable data class MailRuVideoData( - @JsonProperty("url") val url: String, - @JsonProperty("key") val key: String + @SerialName("url") val url: String, + @SerialName("key") val key: String ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt index 0a88639f450..5621117c657 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt @@ -2,7 +2,8 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.ErrorLoadingException import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.USER_AGENT @@ -66,8 +67,9 @@ open class Odnoklassniki : ExtractorApi() { } } + @Serializable data class OkRuVideo( - @JsonProperty("name") val name: String, - @JsonProperty("url") val url: String, + @SerialName("name") val name: String, + @SerialName("url") val url: String, ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt index 4efd20589be..7a10aadbed1 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt @@ -5,7 +5,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable open class PeaceMakerst : ExtractorApi() { override val name = "PeaceMakerst" @@ -60,29 +61,34 @@ open class PeaceMakerst : ExtractorApi() { ) } + @Serializable data class PeaceResponse( - @JsonProperty("videoImage") val videoImage: String?, - @JsonProperty("videoSources") val videoSources: List, - @JsonProperty("sIndex") val sIndex: String, - @JsonProperty("sourceList") val sourceList: Map + @SerialName("videoImage") val videoImage: String?, + @SerialName("videoSources") val videoSources: List, + @SerialName("sIndex") val sIndex: String, + @SerialName("sourceList") val sourceList: Map ) + @Serializable data class VideoSource( - @JsonProperty("file") val file: String, - @JsonProperty("label") val label: String, - @JsonProperty("type") val type: String + @SerialName("file") val file: String, + @SerialName("label") val label: String, + @SerialName("type") val type: String ) + @Serializable data class Teve2ApiResponse( - @JsonProperty("Media") val media: Teve2Media + @SerialName("Media") val media: Teve2Media ) + @Serializable data class Teve2Media( - @JsonProperty("Link") val link: Teve2Link + @SerialName("Link") val link: Teve2Link ) + @Serializable data class Teve2Link( - @JsonProperty("ServiceUrl") val serviceUrl: String, - @JsonProperty("SecurePath") val securePath: String + @SerialName("ServiceUrl") val serviceUrl: String, + @SerialName("SecurePath") val securePath: String ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt index a5ecfb5d83a..eb9098f95d9 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt @@ -1,7 +1,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.api.Log -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson @@ -11,8 +12,9 @@ open class PlayLtXyz: ExtractorApi() { override val mainUrl: String = "https://play.playlt.xyz" override val requiresReferer = true + @Serializable private data class ResponseData( - @JsonProperty("data") val data: String? = null + @SerialName("data") val data: String? = null ) override suspend fun getUrl(url: String, referer: String?): List { @@ -57,7 +59,7 @@ open class PlayLtXyz: ExtractorApi() { if (data.isSuccessful) { val itemstr = data.text() Log.i(this.name, "Result => (data) $itemstr") - tryParseJson(itemstr)?.let { item -> + tryParseJson(itemstr)?.let { item -> val linkUrl = item.data ?: "" if (linkUrl.isNotBlank()) { extractedLinksList.add( @@ -77,4 +79,4 @@ open class PlayLtXyz: ExtractorApi() { } return extractedLinksList } -} \ No newline at end of file +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Rabbitstream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Rabbitstream.kt index 8eddeacb9d3..40ed3af5109 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Rabbitstream.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Rabbitstream.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.ErrorLoadingException import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app @@ -172,26 +173,30 @@ open class Rabbitstream : ExtractorApi() { return decryptedData.decodeToString() } + @Serializable data class Tracks( - @JsonProperty("file") val file: String? = null, - @JsonProperty("label") val label: String? = null, - @JsonProperty("kind") val kind: String? = null, + @SerialName("file") val file: String? = null, + @SerialName("label") val label: String? = null, + @SerialName("kind") val kind: String? = null, ) + @Serializable data class Sources( - @JsonProperty("file") val file: String? = null, - @JsonProperty("type") val type: String? = null, - @JsonProperty("label") val label: String? = null, + @SerialName("file") val file: String? = null, + @SerialName("type") val type: String? = null, + @SerialName("label") val label: String? = null, ) + @Serializable data class SourcesResponses( - @JsonProperty("sources") val sources: List? = emptyList(), - @JsonProperty("tracks") val tracks: List? = emptyList(), + @SerialName("sources") val sources: List? = emptyList(), + @SerialName("tracks") val tracks: List? = emptyList(), ) + @Serializable data class SourcesEncrypted( - @JsonProperty("sources") val sources: String? = null, - @JsonProperty("encrypted") val encrypted: Boolean? = null, - @JsonProperty("tracks") val tracks: List? = emptyList(), + @SerialName("sources") val sources: String? = null, + @SerialName("encrypted") val encrypted: Boolean? = null, + @SerialName("tracks") val tracks: List? = emptyList(), ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SobreatsesuypExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SobreatsesuypExtractor.kt index 1ac5a104fe2..42eb8835d34 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SobreatsesuypExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SobreatsesuypExtractor.kt @@ -4,7 +4,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable open class Sobreatsesuyp : ExtractorApi() { override val name = "Sobreatsesuyp" @@ -45,8 +46,9 @@ open class Sobreatsesuyp : ExtractorApi() { } } + @Serializable data class SobreatsesuypVideoData( - @JsonProperty("title") val title: String? = null, - @JsonProperty("file") val file: String? = null + @SerialName("title") val title: String? = null, + @SerialName("file") val file: String? = null ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamEmbed.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamEmbed.kt index 7b2846d6bbf..57d25392047 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamEmbed.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamEmbed.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.AppUtils.parseJson @@ -30,14 +31,15 @@ open class StreamEmbed : ExtractorApi() { ).forEach(callback) } + @Serializable private data class Details( - @JsonProperty("id") val id: String, - @JsonProperty("uid") val uid: String, - @JsonProperty("slug") val slug: String, - @JsonProperty("title") val title: String, - @JsonProperty("quality") val quality: String, - @JsonProperty("type") val type: String, - @JsonProperty("status") val status: String, - @JsonProperty("md5") val md5: String, + @SerialName("id") val id: String, + @SerialName("uid") val uid: String, + @SerialName("slug") val slug: String, + @SerialName("title") val title: String, + @SerialName("quality") val quality: String, + @SerialName("type") val type: String, + @SerialName("status") val status: String, + @SerialName("md5") val md5: String, ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamSB.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamSB.kt index 67cf1f8da9c..6695e7718b7 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamSB.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamSB.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.newSubtitleFile @@ -189,25 +190,28 @@ open class StreamSB : ExtractorApi() { } } + @Serializable data class Subs ( - @JsonProperty("file") val file: String? = null, - @JsonProperty("label") val label: String? = null, + @SerialName("file") val file: String? = null, + @SerialName("label") val label: String? = null, ) + @Serializable data class StreamData ( - @JsonProperty("file") val file: String, - @JsonProperty("cdn_img") val cdnImg: String, - @JsonProperty("hash") val hash: String, - @JsonProperty("subs") val subs: ArrayList? = arrayListOf(), - @JsonProperty("length") val length: String, - @JsonProperty("id") val id: String, - @JsonProperty("title") val title: String, - @JsonProperty("backup") val backup: String, + @SerialName("file") val file: String, + @SerialName("cdn_img") val cdnImg: String, + @SerialName("hash") val hash: String, + @SerialName("subs") val subs: ArrayList? = arrayListOf(), + @SerialName("length") val length: String, + @SerialName("id") val id: String, + @SerialName("title") val title: String, + @SerialName("backup") val backup: String, ) + @Serializable data class Main ( - @JsonProperty("stream_data") val streamData: StreamData, - @JsonProperty("status_code") val statusCode: Int, + @SerialName("stream_data") val streamData: StreamData, + @SerialName("status_code") val statusCode: Int, ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamlare.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamlare.kt index da2dd62bef5..d5455a28c76 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamlare.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamlare.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink @@ -26,18 +27,20 @@ open class Slmaxed : ExtractorApi() { val embedRegex = Regex("""/e/([^/]*)""") + @Serializable data class JsonResponse( - @JsonProperty val status: String? = null, - @JsonProperty val message: String? = null, - @JsonProperty val type: String? = null, - @JsonProperty val token: String? = null, - @JsonProperty val result: Map? = null + @SerialName("status") val status: String? = null, + @SerialName("message") val message: String? = null, + @SerialName("type") val type: String? = null, + @SerialName("token") val token: String? = null, + @SerialName("result") val result: Map? = null ) + @Serializable data class Result( - @JsonProperty val label: String? = null, - @JsonProperty val file: String? = null, - @JsonProperty val type: String? = null + @SerialName("label") val label: String? = null, + @SerialName("file") val file: String? = null, + @SerialName("type") val type: String? = null ) override suspend fun getUrl(url: String, referer: String?): List? { @@ -66,4 +69,4 @@ open class Slmaxed : ExtractorApi() { } } } -} \ No newline at end of file +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamplay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamplay.kt index a8dac673734..e1526ee7455 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamplay.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamplay.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.APIHolder.getCaptchaToken import com.lagradost.cloudstream3.ErrorLoadingException import com.lagradost.cloudstream3.SubtitleFile @@ -72,9 +73,10 @@ open class Streamplay : ExtractorApi() { } + @Serializable data class Source( - @JsonProperty("file") val file: String? = null, - @JsonProperty("label") val label: String? = null, + @SerialName("file") val file: String? = null, + @SerialName("label") val label: String? = null, ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt index 1345da96cdf..332d9ccca06 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt @@ -5,7 +5,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable open class TRsTX : ExtractorApi() { override val name = "TRsTX" @@ -62,8 +63,9 @@ open class TRsTX : ExtractorApi() { } } + @Serializable data class TrstxVideoData( - @JsonProperty("title") val title: String? = null, - @JsonProperty("file") val file: String? = null + @SerialName("title") val title: String? = null, + @SerialName("file") val file: String? = null ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tantifilm.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tantifilm.kt index 2ac30d2c69b..c3162ebcf77 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tantifilm.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tantifilm.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.AppUtils.parseJson @@ -12,17 +13,19 @@ open class Tantifilm : ExtractorApi() { override var mainUrl = "https://cercafilm.net" override val requiresReferer = false + @Serializable data class TantifilmJsonData ( - @JsonProperty("success") val success : Boolean, - @JsonProperty("data") val data : List, - @JsonProperty("captions")val captions : List, - @JsonProperty("is_vr") val is_vr : Boolean + @SerialName("success") val success : Boolean, + @SerialName("data") val data : List, + @SerialName("captions")val captions : List, + @SerialName("is_vr") val is_vr : Boolean ) + @Serializable data class TantifilmData ( - @JsonProperty("file") val file : String, - @JsonProperty("label") val label : String, - @JsonProperty("type") val type : String + @SerialName("file") val file : String, + @SerialName("label") val label : String, + @SerialName("type") val type : String ) override suspend fun getUrl(url: String, referer: String?): List? { diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt index 1c9cce2a834..810e23d86dc 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt @@ -5,7 +5,8 @@ package com.lagradost.cloudstream3.extractors import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable open class TauVideo : ExtractorApi() { override val name = "TauVideo" @@ -33,12 +34,14 @@ open class TauVideo : ExtractorApi() { } } + @Serializable data class TauVideoUrls( - @JsonProperty("urls") val urls: List + @SerialName("urls") val urls: List ) + @Serializable data class TauVideoData( - @JsonProperty("url") val url: String, - @JsonProperty("label") val label: String, + @SerialName("url") val url: String, + @SerialName("label") val label: String, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uservideo.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uservideo.kt index f6c3002813d..247bd099d42 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uservideo.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uservideo.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.AppUtils @@ -44,10 +45,11 @@ open class Uservideo : ExtractorApi() { } + @Serializable data class Sources( - @JsonProperty("src") val src: String? = null, - @JsonProperty("type") val type: String? = null, - @JsonProperty("label") val label: String? = null, + @SerialName("src") val src: String? = null, + @SerialName("type") val type: String? = null, + @SerialName("label") val label: String? = null, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vicloud.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vicloud.kt index b2b526458a1..d5bd978784d 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vicloud.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vicloud.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.APIHolder.unixTimeMS import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app @@ -42,13 +43,15 @@ open class Vicloud : ExtractorApi() { } + @Serializable private data class Sources( - @JsonProperty("file") val file: String? = null, - @JsonProperty("label") val label: String? = null, + @SerialName("file") val file: String? = null, + @SerialName("label") val label: String? = null, ) + @Serializable private data class Responses( - @JsonProperty("sources") val sources: List? = arrayListOf(), + @SerialName("sources") val sources: List? = arrayListOf(), ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt index 6bbd13d04fa..d6ec5461b85 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt @@ -2,10 +2,11 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson open class VideoSeyred : ExtractorApi() { @@ -47,24 +48,27 @@ open class VideoSeyred : ExtractorApi() { } } + @Serializable data class VideoSeyredSource( - @JsonProperty("image") val image: String, - @JsonProperty("title") val title: String, - @JsonProperty("sources") val sources: List, - @JsonProperty("tracks") val tracks: List + @SerialName("image") val image: String, + @SerialName("title") val title: String, + @SerialName("sources") val sources: List, + @SerialName("tracks") val tracks: List ) + @Serializable data class VSSource( - @JsonProperty("file") val file: String, - @JsonProperty("type") val type: String, - @JsonProperty("default") val default: String + @SerialName("file") val file: String, + @SerialName("type") val type: String, + @SerialName("default") val default: String ) + @Serializable data class VSTrack( - @JsonProperty("file") val file: String, - @JsonProperty("kind") val kind: String, - @JsonProperty("language") val language: String? = null, - @JsonProperty("label") val label: String? = null, - @JsonProperty("default") val default: String? = null + @SerialName("file") val file: String, + @SerialName("kind") val kind: String, + @SerialName("language") val language: String? = null, + @SerialName("label") val label: String? = null, + @SerialName("default") val default: String? = null ) } diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidoza.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidoza.kt index 2a078034000..f945b6caaed 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidoza.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidoza.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.api.Log import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app @@ -53,10 +54,11 @@ open class Vidoza: ExtractorApi() { private class VinovoDataList: ArrayList() + @Serializable private data class VinovoVideoData( - @JsonProperty("src") val source: String, - @JsonProperty("type") val type: String?, - @JsonProperty("label") val label: String?, - @JsonProperty("res") val resolution: String?, + @SerialName("src") val source: String, + @SerialName("type") val type: String?, + @SerialName("label") val label: String?, + @SerialName("res") val resolution: String?, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vinovo.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vinovo.kt index f490390990c..51c1f7b08d4 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vinovo.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vinovo.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.APIHolder import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app @@ -59,8 +60,9 @@ open class VinovoTo : ExtractorApi() { ) } + @Serializable private data class VinovoFileResp( - @JsonProperty("status") val status: String, - @JsonProperty("token") val token: String, + @SerialName("status") val status: String, + @SerialName("token") val token: String, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/XStreamCdn.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/XStreamCdn.kt index 6e3a8126def..2adf01be073 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/XStreamCdn.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/XStreamCdn.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.newSubtitleFile @@ -76,28 +77,32 @@ open class XStreamCdn : ExtractorApi() { override val requiresReferer = false open var domainUrl: String = "embedsito.com" + @Serializable private data class ResponseData( - @JsonProperty("file") val file: String, - @JsonProperty("label") val label: String, + @SerialName("file") val file: String, + @SerialName("label") val label: String, //val type: String // Mp4 ) + @Serializable private data class Player( - @JsonProperty("poster_file") val poster_file: String? = null, + @SerialName("poster_file") val poster_file: String? = null, ) + @Serializable private data class ResponseJson( - @JsonProperty("success") val success: Boolean, - @JsonProperty("player") val player: Player? = null, - @JsonProperty("data") val data: List?, - @JsonProperty("captions") val captions: List?, + @SerialName("success") val success: Boolean, + @SerialName("player") val player: Player? = null, + @SerialName("data") val data: List?, + @SerialName("captions") val captions: List?, ) + @Serializable private data class Captions( - @JsonProperty("id") val id: String, - @JsonProperty("hash") val hash: String, - @JsonProperty("language") val language: String, - @JsonProperty("extension") val extension: String + @SerialName("id") val id: String, + @SerialName("hash") val hash: String, + @SerialName("language") val language: String, + @SerialName("extension") val extension: String ) override fun getExtractorUrl(id: String): String { @@ -117,7 +122,7 @@ open class XStreamCdn : ExtractorApi() { val id = url.trimEnd('/').split("/").last() val newUrl = "https://${domainUrl}/api/source/${id}" app.post(newUrl, headers = headers).let { res -> - val sources = tryParseJson(res.text) + val sources = tryParseJson(res.text) sources?.let { if (it.success && it.data != null) { it.data.map { source -> @@ -146,4 +151,4 @@ open class XStreamCdn : ExtractorApi() { } } } -} \ No newline at end of file +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YourUpload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YourUpload.kt index cdb6deb46ed..80ab128d3c3 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YourUpload.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YourUpload.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.extractors -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.ExtractorApi @@ -42,8 +43,9 @@ open class YourUpload: ExtractorApi() { return sources } + @Serializable private data class ResponseSource( - @JsonProperty("file") val file: String, + @SerialName("file") val file: String, ) } \ No newline at end of file diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt index 89f935da327..77416fe8aa5 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3.metaproviders -import com.fasterxml.jackson.annotation.JsonProperty +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import com.lagradost.cloudstream3.Actor import com.lagradost.cloudstream3.Episode import com.lagradost.cloudstream3.ErrorLoadingException @@ -51,12 +52,13 @@ import java.util.Calendar * episode and season starting from 1 * they are null if movie * */ +@Serializable data class TmdbLink( - @JsonProperty("imdbID") val imdbID: String?, - @JsonProperty("tmdbID") val tmdbID: Int?, - @JsonProperty("episode") val episode: Int?, - @JsonProperty("season") val season: Int?, - @JsonProperty("movieName") val movieName: String? = null, + @SerialName("imdbID") val imdbID: String?, + @SerialName("tmdbID") val tmdbID: Int?, + @SerialName("episode") val episode: Int?, + @SerialName("season") val season: Int?, + @SerialName("movieName") val movieName: String? = null, ) open class TmdbProvider : MainAPI() { diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt index 1c635013fc2..26d5daa6ffc 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import com.lagradost.cloudstream3.InternalAPI import com.lagradost.cloudstream3.json import com.lagradost.cloudstream3.mapper +import com.lagradost.cloudstream3.mvvm.debugPrint import com.lagradost.cloudstream3.mvvm.logError import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.InternalSerializationApi @@ -21,60 +22,89 @@ object AppUtils { return toJsonLiteral() } - /** Sometimes we want to encode as JSON even if it is already a String. */ @InternalAPI - fun Any.toJsonLiteral(): String { - // @Serializable generates a serializer at compile time; contextual serializers are - // registered manually in serializersModule, we need both to support all cases - val serializer = - this::class.serializerOrNull() ?: json.serializersModule.getContextual(this::class) - return if (serializer != null) { + fun Any.toJsonLiteralImpl(serializer: KSerializer?): String { + var fallbackTrace: String? = null + if (serializer != null) { try { - @Suppress("UNCHECKED_CAST") - json.encodeToString(serializer as KSerializer, this) + debugPrint { "AppUtils/toJsonLiteral: using kotlinx serialization for ${this::class.qualifiedName}" } + return json.encodeToString(serializer, this) } catch (e: SerializationException) { logError(e) - mapper.writeValueAsString(this) + fallbackTrace = e.stackTraceToString() + debugPrint { "AppUtils/toJsonLiteral: kotlinx failed, falling back to Jackson for ${this::class.qualifiedName}" } } } else { - mapper.writeValueAsString(this) + fallbackTrace = Exception().stackTraceToString() } + debugPrint { "AppUtils/toJsonLiteral: using Jackson for ${this::class.qualifiedName}\n$fallbackTrace" } + return mapper.writeValueAsString(this) + } + + /** Runtime lookup version, subject to type erasure for generic types. */ + @InternalAPI + fun Any.toJsonLiteral(): String { + val serializer = this::class.serializerOrNull() + ?: json.serializersModule.getContextual(this::class) + @Suppress("UNCHECKED_CAST") + return toJsonLiteralImpl(serializer as KSerializer?) + } + + /** Reified version, preserves full generic type info at call site. */ + @InternalAPI + @JvmName("toJsonLiteralReified") + inline fun T.toJsonLiteral(): String { + val serializer = runCatching { serializer() } + .recoverCatching { json.serializersModule.getContextual(T::class) } + .getOrNull() + @Suppress("UNCHECKED_CAST") + return toJsonLiteralImpl(serializer as KSerializer?) } @InternalAPI fun parseJson(value: String, kClass: KClass): T { val serializer = kClass.serializerOrNull() ?: json.serializersModule.getContextual(kClass) + var fallbackTrace: String? = null if (serializer != null) { try { + debugPrint { "AppUtils/parseJson(kClass): using kotlinx serialization for ${kClass.qualifiedName}" } return json.decodeFromString(serializer, value) } catch (e: SerializationException) { logError(e) + fallbackTrace = e.stackTraceToString() + debugPrint { "AppUtils/parseJson(kClass): kotlinx failed, falling back to Jackson for ${kClass.qualifiedName}" } } + } else { + fallbackTrace = Exception().stackTraceToString() } - + debugPrint { "AppUtils/parseJson(kClass): using Jackson for ${kClass.qualifiedName}\n$fallbackTrace" } return mapper.readValue(value, kClass.java) } // This is inlined code and can easily cause breakage in extensions! // Watch out when editing this to make sure stable also supports all inlined code! inline fun parseJson(value: String): T { - // @Serializable generates a serializer at compile time; contextual serializers are - // registered manually in serializersModule, we need both to support all cases val serializer = runCatching { serializer() } .recoverCatching { json.serializersModule.getContextual(T::class) } .getOrNull() - // Prefer Kotlin Serialization over Jackson + var fallbackTrace: String? = null if (serializer != null) { try { + debugPrint { "AppUtils/parseJson: using kotlinx serialization for ${T::class.qualifiedName}" } return json.decodeFromString(serializer, value) } catch (e: SerializationException) { logError(e) - } catch (_: Throwable) { - // Pass, the above code will trigger a NoSuchMethodError on stable due to our previously undefined json variable + fallbackTrace = e.stackTraceToString() + debugPrint { "AppUtils/parseJson: kotlinx failed, falling back to Jackson for ${T::class.qualifiedName}" } + } catch (e: Throwable) { + fallbackTrace = e.stackTraceToString() + debugPrint { "AppUtils/parseJson: unexpected error for ${T::class.qualifiedName}, falling back to Jackson" } } + } else { + fallbackTrace = Exception().stackTraceToString() } - + debugPrint { "AppUtils/parseJson: using Jackson for ${T::class.qualifiedName}\n$fallbackTrace" } return mapper.readValue(value) } @@ -85,7 +115,6 @@ object AppUtils { replaceWith = ReplaceWith("parseJson(reader.readText())") ) inline fun parseJson(reader: java.io.Reader, valueType: Class): T { - // Reader-based parsing has no kotlinx equivalent, fall back to Jackson return mapper.readValue(reader, valueType) }