This commit is contained in:
Deleted user 2023-12-20 07:34:33 +05:30 committed by GitHub
commit 9f8d11d949
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 3 deletions

View file

@ -1022,6 +1022,7 @@ class GeneratorPlayer : FullScreenPlayer() {
resumeMeta.id,
resumeMeta.episode,
resumeMeta.season,
resumeMeta.dubStatus,
isFromDownload = false
)
}

View file

@ -50,6 +50,7 @@ data class ResultEpisode(
val videoWatchState: VideoWatchState,
/** Sum of all previous season episode counts + episode */
val totalEpisodeIndex: Int? = null,
val dubStatus: DubStatus? = null
)
fun ResultEpisode.getRealPosition(): Long {
@ -85,6 +86,7 @@ fun buildResultEpisode(
tvType: TvType,
parentId: Int,
totalEpisodeIndex: Int? = null,
dubStatus: DubStatus? = null,
): ResultEpisode {
val posDur = getViewPos(id)
val videoWatchState = getVideoWatchState(id) ?: VideoWatchState.None
@ -107,7 +109,8 @@ fun buildResultEpisode(
tvType,
parentId,
videoWatchState,
totalEpisodeIndex
totalEpisodeIndex,
dubStatus
)
}

View file

@ -2245,7 +2245,8 @@ class ResultViewModel2 : ViewModel() {
fillers.getOrDefault(episode, false),
loadResponse.type,
mainId,
totalIndex
totalIndex,
ep.key
)
val season = eps.seasonIndex ?: 0
@ -2294,7 +2295,8 @@ class ResultViewModel2 : ViewModel() {
null,
loadResponse.type,
mainId,
totalIndex
totalIndex,
null
)
val season = ep.seasonIndex ?: 0
@ -2326,6 +2328,7 @@ class ResultViewModel2 : ViewModel() {
null,
loadResponse.type,
mainId,
null,
null
)
)
@ -2349,6 +2352,7 @@ class ResultViewModel2 : ViewModel() {
null,
loadResponse.type,
mainId,
null,
null
)
)
@ -2372,6 +2376,7 @@ class ResultViewModel2 : ViewModel() {
null,
loadResponse.type,
mainId,
null,
null
)
)
@ -2458,9 +2463,30 @@ class ResultViewModel2 : ViewModel() {
)
}
restoreSeasonAndRange(resume)
return ResumeWatchingStatus(progress = progress, isMovie = isMovie, result = episode)
}
private fun restoreSeasonAndRange(resume: VideoDownloadHelper.ResumeWatching) {
// restore season based on resume details
resume.season?.apply {
changeSeason(this)
}
// restore dubStatus based on resume details
resume.dubStatus?.apply {
changeDubStatus(this)
}
// restore range based on resume details
currentRanges[currentIndex]?.first {
it.endEpisode >= resume.episode ?: 0
}?.apply {
changeRange(this)
}
}
private fun loadTrailers(loadResponse: LoadResponse) = ioSafe {
_trailers.postValue(
getTrailers(

View file

@ -360,6 +360,7 @@ object DataStoreHelper {
null,
it.episode,
it.season,
it.dubStatus,
it.isFromDownload,
it.updateTime
)
@ -374,6 +375,7 @@ object DataStoreHelper {
episodeId: Int?,
episode: Int?,
season: Int?,
dubStatus: DubStatus? = null,
isFromDownload: Boolean = false,
updateTime: Long? = null,
) {
@ -386,6 +388,7 @@ object DataStoreHelper {
episodeId,
episode,
season,
dubStatus,
updateTime ?: System.currentTimeMillis(),
isFromDownload
)

View file

@ -1,6 +1,7 @@
package com.lagradost.cloudstream3.utils
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.TvType
object VideoDownloadHelper {
data class DownloadEpisodeCached(
@ -30,6 +31,7 @@ object VideoDownloadHelper {
@JsonProperty("episodeId") val episodeId: Int?,
@JsonProperty("episode") val episode: Int?,
@JsonProperty("season") val season: Int?,
@JsonProperty("dubStatus") val dubStatus: DubStatus?,
@JsonProperty("updateTime") val updateTime: Long,
@JsonProperty("isFromDownload") val isFromDownload: Boolean,
)