From a75c41bba4cf10d6d88ecbd1eec8a7d79cf7212d Mon Sep 17 00:00:00 2001 From: Haggai Eran Date: Sat, 4 Feb 2023 17:53:28 +0200 Subject: [PATCH] StreamHistoryEntry: convert to StreamInfoItem Can be used to play history items. --- .../database/history/model/StreamHistoryEntry.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/database/history/model/StreamHistoryEntry.kt b/app/src/main/java/org/schabi/newpipe/database/history/model/StreamHistoryEntry.kt index a93ba1652f6..c0ac751b090 100644 --- a/app/src/main/java/org/schabi/newpipe/database/history/model/StreamHistoryEntry.kt +++ b/app/src/main/java/org/schabi/newpipe/database/history/model/StreamHistoryEntry.kt @@ -3,6 +3,7 @@ package org.schabi.newpipe.database.history.model import androidx.room.ColumnInfo import androidx.room.Embedded import org.schabi.newpipe.database.stream.model.StreamEntity +import org.schabi.newpipe.extractor.stream.StreamInfoItem import java.time.OffsetDateTime data class StreamHistoryEntry( @@ -27,4 +28,14 @@ data class StreamHistoryEntry( return this.streamEntity.uid == other.streamEntity.uid && streamId == other.streamId && accessDate.isEqual(other.accessDate) } + + fun toStreamInfoItem(): StreamInfoItem { + val item = StreamInfoItem(streamEntity.serviceId, streamEntity.url, streamEntity.title, streamEntity.streamType) + item.duration = streamEntity.duration + item.uploaderName = streamEntity.uploader + item.uploaderUrl = streamEntity.uploaderUrl + item.thumbnailUrl = streamEntity.thumbnailUrl + + return item + } }