Init sqlite take 2

This commit is contained in:
advplyr 2023-07-04 18:14:44 -05:00
parent d86a3b3dc2
commit cf7fd315b6
88 changed files with 7017 additions and 692 deletions

View file

@ -1,5 +1,6 @@
const date = require('../libs/dateAndTime')
const { getId } = require('../utils/index')
const uuidv4 = require("uuid").v4
const serverVersion = require('../../package.json').version
const BookMetadata = require('./metadata/BookMetadata')
const PodcastMetadata = require('./metadata/PodcastMetadata')
const DeviceInfo = require('./DeviceInfo')
@ -11,6 +12,7 @@ class PlaybackSession {
this.userId = null
this.libraryId = null
this.libraryItemId = null
this.bookId = null
this.episodeId = null
this.mediaType = null
@ -24,6 +26,7 @@ class PlaybackSession {
this.playMethod = null
this.mediaPlayer = null
this.deviceInfo = null
this.serverVersion = null
this.date = null
this.dayOfWeek = null
@ -52,6 +55,7 @@ class PlaybackSession {
userId: this.userId,
libraryId: this.libraryId,
libraryItemId: this.libraryItemId,
bookId: this.bookId,
episodeId: this.episodeId,
mediaType: this.mediaType,
mediaMetadata: this.mediaMetadata?.toJSON() || null,
@ -63,6 +67,7 @@ class PlaybackSession {
playMethod: this.playMethod,
mediaPlayer: this.mediaPlayer,
deviceInfo: this.deviceInfo?.toJSON() || null,
serverVersion: this.serverVersion,
date: this.date,
dayOfWeek: this.dayOfWeek,
timeListening: this.timeListening,
@ -79,6 +84,7 @@ class PlaybackSession {
userId: this.userId,
libraryId: this.libraryId,
libraryItemId: this.libraryItemId,
bookId: this.bookId,
episodeId: this.episodeId,
mediaType: this.mediaType,
mediaMetadata: this.mediaMetadata?.toJSON() || null,
@ -90,6 +96,7 @@ class PlaybackSession {
playMethod: this.playMethod,
mediaPlayer: this.mediaPlayer,
deviceInfo: this.deviceInfo?.toJSON() || null,
serverVersion: this.serverVersion,
date: this.date,
dayOfWeek: this.dayOfWeek,
timeListening: this.timeListening,
@ -108,12 +115,20 @@ class PlaybackSession {
this.userId = session.userId
this.libraryId = session.libraryId || null
this.libraryItemId = session.libraryItemId
this.bookId = session.bookId
this.episodeId = session.episodeId
this.mediaType = session.mediaType
this.duration = session.duration
this.playMethod = session.playMethod
this.mediaPlayer = session.mediaPlayer || null
this.deviceInfo = new DeviceInfo(session.deviceInfo)
if (session.deviceInfo instanceof DeviceInfo) {
this.deviceInfo = new DeviceInfo(session.deviceInfo.toJSON())
} else {
this.deviceInfo = new DeviceInfo(session.deviceInfo)
}
this.serverVersion = session.serverVersion
this.chapters = session.chapters || []
this.mediaMetadata = null
@ -151,7 +166,7 @@ class PlaybackSession {
}
get deviceId() {
return this.deviceInfo?.deviceId
return this.deviceInfo?.id
}
get deviceDescription() {
@ -169,10 +184,11 @@ class PlaybackSession {
}
setData(libraryItem, user, mediaPlayer, deviceInfo, startTime, episodeId = null) {
this.id = getId('play')
this.id = uuidv4()
this.userId = user.id
this.libraryId = libraryItem.libraryId
this.libraryItemId = libraryItem.id
this.bookId = episodeId ? null : libraryItem.media.id
this.episodeId = episodeId
this.mediaType = libraryItem.mediaType
this.mediaMetadata = libraryItem.media.metadata.clone()
@ -189,6 +205,7 @@ class PlaybackSession {
this.mediaPlayer = mediaPlayer
this.deviceInfo = deviceInfo || new DeviceInfo()
this.serverVersion = serverVersion
this.timeListening = 0
this.startTime = startTime