Update:API endpoint for syncing multiple local sessions. New API endpoint to get current user. Deprecate /me/sync-local-progress endpoint

This commit is contained in:
advplyr
2023-02-05 16:52:17 -06:00
parent debf0f495d
commit f9e6655359
5 changed files with 107 additions and 46 deletions

View File

@@ -141,6 +141,11 @@ class PlaybackSession {
this.updatedAt = session.updatedAt || null
}
get mediaItemId() {
if (this.episodeId) return `${this.libraryItemId}-${this.episodeId}`
return this.libraryItemId
}
get progress() { // Value between 0 and 1
if (!this.duration) return 0
return Math.max(0, Math.min(this.currentTime / this.duration, 1))
@@ -151,6 +156,15 @@ class PlaybackSession {
return this.deviceInfo.deviceDescription
}
get mediaProgressObject() {
return {
duration: this.duration,
currentTime: this.currentTime,
progress: this.progress,
lastUpdate: this.updatedAt
}
}
setData(libraryItem, user, mediaPlayer, deviceInfo, startTime, episodeId = null) {
this.id = getId('play')
this.userId = user.id