2019-04-28 20:43:52 +00:00
|
|
|
package org.schabi.newpipe.database.stream
|
|
|
|
|
|
|
|
import androidx.room.ColumnInfo
|
|
|
|
import androidx.room.Embedded
|
|
|
|
import org.schabi.newpipe.database.LocalItem
|
|
|
|
import org.schabi.newpipe.database.history.model.StreamHistoryEntity
|
|
|
|
import org.schabi.newpipe.database.stream.model.StreamEntity
|
2021-06-07 07:35:40 +00:00
|
|
|
import org.schabi.newpipe.database.stream.model.StreamStateEntity.STREAM_PROGRESS_MILLIS
|
2019-04-28 20:43:52 +00:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
2023-05-02 10:30:27 +00:00
|
|
|
import org.schabi.newpipe.util.image.ImageStrategy
|
2020-11-15 13:08:41 +00:00
|
|
|
import java.time.OffsetDateTime
|
2019-04-28 20:43:52 +00:00
|
|
|
|
|
|
|
class StreamStatisticsEntry(
|
2020-11-15 13:08:41 +00:00
|
|
|
@Embedded
|
2020-05-01 18:13:21 +00:00
|
|
|
val streamEntity: StreamEntity,
|
2019-04-28 20:43:52 +00:00
|
|
|
|
2021-06-07 07:35:40 +00:00
|
|
|
@ColumnInfo(name = STREAM_PROGRESS_MILLIS, defaultValue = "0")
|
|
|
|
val progressMillis: Long,
|
2020-11-15 13:08:41 +00:00
|
|
|
|
|
|
|
@ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID)
|
2020-05-01 18:13:21 +00:00
|
|
|
val streamId: Long,
|
2019-04-28 20:43:52 +00:00
|
|
|
|
2020-11-15 13:08:41 +00:00
|
|
|
@ColumnInfo(name = STREAM_LATEST_DATE)
|
2020-10-18 06:16:55 +00:00
|
|
|
val latestAccessDate: OffsetDateTime,
|
2019-04-28 20:43:52 +00:00
|
|
|
|
2020-11-15 13:08:41 +00:00
|
|
|
@ColumnInfo(name = STREAM_WATCH_COUNT)
|
2020-05-01 18:13:21 +00:00
|
|
|
val watchCount: Long
|
2019-04-28 20:43:52 +00:00
|
|
|
) : LocalItem {
|
|
|
|
fun toStreamInfoItem(): StreamInfoItem {
|
|
|
|
val item = StreamInfoItem(streamEntity.serviceId, streamEntity.url, streamEntity.title, streamEntity.streamType)
|
|
|
|
item.duration = streamEntity.duration
|
|
|
|
item.uploaderName = streamEntity.uploader
|
2021-08-13 08:58:01 +00:00
|
|
|
item.uploaderUrl = streamEntity.uploaderUrl
|
2023-05-02 19:36:11 +00:00
|
|
|
item.thumbnails = ImageStrategy.dbUrlToImageList(streamEntity.thumbnailUrl)
|
2019-04-28 20:43:52 +00:00
|
|
|
|
|
|
|
return item
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getLocalItemType(): LocalItem.LocalItemType {
|
|
|
|
return LocalItem.LocalItemType.STATISTIC_STREAM_ITEM
|
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
const val STREAM_LATEST_DATE = "latestAccess"
|
|
|
|
const val STREAM_WATCH_COUNT = "watchCount"
|
|
|
|
}
|
|
|
|
}
|