Skip to content
Open
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
Expand Up @@ -22,7 +22,10 @@ import com.lagradost.cloudstream3.utils.newExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromCodeToLangTagIETF
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromLanguageToTagIETF
import com.lagradost.cloudstream3.utils.serializers.UriSerializer
import com.lagradost.cloudstream3.utils.txt
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* If you want to support CloudStream 3 as an external player, then this shows how to play any video link
Expand All @@ -49,19 +52,16 @@ class CloudStreamPackage : OpenInAppAction(
const val DURATION_EXTRA: String = "dur" // Duration time in MS (Long)
}

@Serializable
data class MinimalVideoLink(
@JsonProperty("uri")
@JsonProperty("uri") @SerialName("uri")
@Serializable(with = UriSerializer::class)
val uri: Uri?,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've run into the first null issue from #2897

Java.lang.AssertionError: Serialization mismatch for:
com.lagradost.cloudstream3.actions.temp.CloudStreamPackage.MinimalVideoLink

Jackson:
{"uri":null,"url":"YRZOHJ","mimeType":"QSIUJMXEP","name":"NHOIYX","headers":{"UDHQNR":"CZDV","CQTCZKYKWN":"KGRYBRD","DXAOWNP":"XDQXGLZAOC"},"quality":1779}

Kotlinx:
{"url":"YRZOHJ","mimeType":"QSIUJMXEP","name":"NHOIYX","headers":{"UDHQNR":"CZDV","CQTCZKYKWN":"KGRYBRD","DXAOWNP":"XDQXGLZAOC"},"quality":1779}

However, this can be sidestepped by making Instancio create a valid Uri-type (we should really have this for all troublesome types):

val instance = Instancio.of(kClass.java).lenient().supply(all(Uri::class.java), Supplier {
    Uri.parse("https://example.com")
}).create()

But this gives

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle (through reference chain: com.lagradost.cloudstream3.actions.temp.CloudStreamPackage$MinimalVideoLink["uri"]->android.net.Uri$StringUri["canonicalUri"])

Meaning that Jackson actually cannot serialize it properly 😬
Perhaps we also need custom JsonDeserializer for jackson? What do you think is best?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I think the best option here is to add a temporary annotation that can skip certain classes in tests and drop worrying about Jackson for things like this. I feel focusing on fixing Jackson to match kotlinx exactly is a waste of time for things like this when Jackson is being phased out. But it is up to you.

@JsonProperty("url")
val url: String?,
@JsonProperty("mimeType")
val mimeType: String = "video/mp4",
@JsonProperty("name")
val name: String?,
@JsonProperty("headers")
var headers: Map<String, String> = mapOf(),
@JsonProperty("quality")
val quality: Int?,
@JsonProperty("url") @SerialName("url") val url: String?,
@JsonProperty("mimeType") @SerialName("mimeType") val mimeType: String = "video/mp4",
@JsonProperty("name") @SerialName("name") val name: String?,
@JsonProperty("headers") @SerialName("headers") var headers: Map<String, String> = mapOf(),
@JsonProperty("quality") @SerialName("quality") val quality: Int?,
) {
companion object {
fun fromExtractor(link: ExtractorLink): MinimalVideoLink = MinimalVideoLink(
Expand Down Expand Up @@ -97,16 +97,12 @@ class CloudStreamPackage : OpenInAppAction(
}
}


@Serializable
data class MinimalSubtitleLink(
@JsonProperty("url")
val url: String,
@JsonProperty("mimeType")
val mimeType: String = "text/vtt",
@JsonProperty("name")
val name: String?,
@JsonProperty("headers")
var headers: Map<String, String> = mapOf(),
@JsonProperty("url") @SerialName("url") val url: String,
@JsonProperty("mimeType") @SerialName("mimeType") val mimeType: String = "text/vtt",
@JsonProperty("name") @SerialName("name") val name: String?,
@JsonProperty("headers") @SerialName("headers") var headers: Map<String, String> = mapOf(),
) {
companion object {
fun fromSubtitle(sub: SubtitleData): MinimalSubtitleLink = MinimalSubtitleLink(
Expand Down Expand Up @@ -159,4 +155,4 @@ class CloudStreamPackage : OpenInAppAction(
override fun onResult(activity: Activity, intent: Intent?) {
// No results yet
}
}
}