-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
StreamItem.kt
48 lines (44 loc) · 1.44 KB
/
StreamItem.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.github.libretube.api.obj
import android.os.Parcelable
import com.github.libretube.db.obj.LocalPlaylistItem
import com.github.libretube.extensions.toID
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable
@Serializable
@Parcelize
data class StreamItem(
val url: String? = null,
val type: String? = null,
var title: String? = null,
var thumbnail: String? = null,
val uploaderName: String? = null,
val uploaderUrl: String? = null,
val uploaderAvatar: String? = null,
val uploadedDate: String? = null,
val duration: Long? = null,
val views: Long? = null,
val uploaderVerified: Boolean? = null,
val uploaded: Long = 0,
val shortDescription: String? = null,
val isShort: Boolean = false
) : Parcelable {
val isLive get() = (duration != null) && (duration <= 0L)
fun toLocalPlaylistItem(playlistId: String): LocalPlaylistItem {
return LocalPlaylistItem(
playlistId = playlistId.toInt(),
videoId = url!!.toID(),
title = title,
thumbnailUrl = thumbnail,
uploader = uploaderName,
uploaderUrl = uploaderUrl,
uploaderAvatar = uploaderAvatar,
uploadDate = uploadedDate,
duration = duration
)
}
companion object {
const val TYPE_STREAM = "stream"
const val TYPE_CHANNEL = "channel"
const val TYPE_PLAYLIST = "playlist"
}
}