mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-14 18:08:25 +01:00
Add logs to playback session manager
This commit is contained in:
parent
b957e1a36b
commit
3383ec2046
@ -47,7 +47,7 @@ class PlaybackSessionManager {
|
|||||||
|
|
||||||
async startSessionRequest(req, res, episodeId) {
|
async startSessionRequest(req, res, episodeId) {
|
||||||
const deviceInfo = this.getDeviceInfo(req)
|
const deviceInfo = this.getDeviceInfo(req)
|
||||||
|
Logger.debug(`[PlaybackSessionManager] startSessionRequest for device ${deviceInfo.deviceDescription}`)
|
||||||
const { user, libraryItem, body: options } = req
|
const { user, libraryItem, body: options } = req
|
||||||
const session = await this.startSession(user, deviceInfo, libraryItem, episodeId, options)
|
const session = await this.startSession(user, deviceInfo, libraryItem, episodeId, options)
|
||||||
res.json(session.toJSONForClient(libraryItem))
|
res.json(session.toJSONForClient(libraryItem))
|
||||||
@ -132,7 +132,7 @@ class PlaybackSessionManager {
|
|||||||
// Close any sessions already open for user
|
// Close any sessions already open for user
|
||||||
const userSessions = this.sessions.filter(playbackSession => playbackSession.userId === user.id)
|
const userSessions = this.sessions.filter(playbackSession => playbackSession.userId === user.id)
|
||||||
for (const session of userSessions) {
|
for (const session of userSessions) {
|
||||||
Logger.info(`[PlaybackSessionManager] startSession: Closing open session "${session.displayTitle}" for user "${user.username}"`)
|
Logger.info(`[PlaybackSessionManager] startSession: Closing open session "${session.displayTitle}" for user "${user.username}" (Device: ${session.deviceDescription})`)
|
||||||
await this.closeSession(user, session, null)
|
await this.closeSession(user, session, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,11 +163,11 @@ class PlaybackSessionManager {
|
|||||||
} else {
|
} else {
|
||||||
let audioTracks = []
|
let audioTracks = []
|
||||||
if (shouldDirectPlay) {
|
if (shouldDirectPlay) {
|
||||||
Logger.debug(`[PlaybackSessionManager] "${user.username}" starting direct play session for item "${libraryItem.id}" with id ${newPlaybackSession.id}`)
|
Logger.debug(`[PlaybackSessionManager] "${user.username}" starting direct play session for item "${libraryItem.id}" with id ${newPlaybackSession.id} (Device: ${newPlaybackSession.deviceDescription})`)
|
||||||
audioTracks = libraryItem.getDirectPlayTracklist(episodeId)
|
audioTracks = libraryItem.getDirectPlayTracklist(episodeId)
|
||||||
newPlaybackSession.playMethod = PlayMethod.DIRECTPLAY
|
newPlaybackSession.playMethod = PlayMethod.DIRECTPLAY
|
||||||
} else {
|
} else {
|
||||||
Logger.debug(`[PlaybackSessionManager] "${user.username}" starting stream session for item "${libraryItem.id}"`)
|
Logger.debug(`[PlaybackSessionManager] "${user.username}" starting stream session for item "${libraryItem.id}" (Device: ${newPlaybackSession.deviceDescription})`)
|
||||||
const stream = new Stream(newPlaybackSession.id, this.StreamsPath, user, libraryItem, episodeId, userStartTime)
|
const stream = new Stream(newPlaybackSession.id, this.StreamsPath, user, libraryItem, episodeId, userStartTime)
|
||||||
await stream.generatePlaylist()
|
await stream.generatePlaylist()
|
||||||
stream.start() // Start transcode
|
stream.start() // Start transcode
|
||||||
@ -177,7 +177,7 @@ class PlaybackSessionManager {
|
|||||||
newPlaybackSession.playMethod = PlayMethod.TRANSCODE
|
newPlaybackSession.playMethod = PlayMethod.TRANSCODE
|
||||||
|
|
||||||
stream.on('closed', () => {
|
stream.on('closed', () => {
|
||||||
Logger.debug(`[PlaybackSessionManager] Stream closed for session "${newPlaybackSession.id}"`)
|
Logger.debug(`[PlaybackSessionManager] Stream closed for session "${newPlaybackSession.id}" (Device: ${newPlaybackSession.deviceDescription})`)
|
||||||
newPlaybackSession.stream = null
|
newPlaybackSession.stream = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ class PlaybackSessionManager {
|
|||||||
|
|
||||||
session.currentTime = syncData.currentTime
|
session.currentTime = syncData.currentTime
|
||||||
session.addListeningTime(syncData.timeListened)
|
session.addListeningTime(syncData.timeListened)
|
||||||
Logger.debug(`[PlaybackSessionManager] syncSession "${session.id}" | Total Time Listened: ${session.timeListening}`)
|
Logger.debug(`[PlaybackSessionManager] syncSession "${session.id}" (Device: ${session.deviceDescription}) | Total Time Listened: ${session.timeListening}`)
|
||||||
|
|
||||||
const itemProgressUpdate = {
|
const itemProgressUpdate = {
|
||||||
duration: syncData.duration,
|
duration: syncData.duration,
|
||||||
|
@ -52,6 +52,14 @@ class DeviceInfo {
|
|||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get deviceDescription() {
|
||||||
|
if (this.model) { // Set from mobile apps
|
||||||
|
if (this.sdkVersion) return `${this.model} SDK ${this.sdkVersion} / v${this.clientVersion}`
|
||||||
|
return `${this.model} / v${this.clientVersion}`
|
||||||
|
}
|
||||||
|
return `${this.osName} ${this.osVersion} / ${this.browserName}`
|
||||||
|
}
|
||||||
|
|
||||||
setData(ip, ua, clientDeviceInfo, serverVersion) {
|
setData(ip, ua, clientDeviceInfo, serverVersion) {
|
||||||
this.ipAddress = ip || null
|
this.ipAddress = ip || null
|
||||||
|
|
||||||
@ -62,7 +70,7 @@ class DeviceInfo {
|
|||||||
this.osVersion = uaObj.os.version || null
|
this.osVersion = uaObj.os.version || null
|
||||||
this.deviceType = uaObj.device.type || null
|
this.deviceType = uaObj.device.type || null
|
||||||
|
|
||||||
var cdi = clientDeviceInfo || {}
|
const cdi = clientDeviceInfo || {}
|
||||||
this.clientVersion = cdi.clientVersion || null
|
this.clientVersion = cdi.clientVersion || null
|
||||||
this.manufacturer = cdi.manufacturer || null
|
this.manufacturer = cdi.manufacturer || null
|
||||||
this.model = cdi.model || null
|
this.model = cdi.model || null
|
||||||
|
@ -146,6 +146,11 @@ class PlaybackSession {
|
|||||||
return Math.max(0, Math.min(this.currentTime / this.duration, 1))
|
return Math.max(0, Math.min(this.currentTime / this.duration, 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get deviceDescription() {
|
||||||
|
if (!this.deviceInfo) return 'No Device Info'
|
||||||
|
return this.deviceInfo.deviceDescription
|
||||||
|
}
|
||||||
|
|
||||||
setData(libraryItem, user, mediaPlayer, deviceInfo, startTime, episodeId = null) {
|
setData(libraryItem, user, mediaPlayer, deviceInfo, startTime, episodeId = null) {
|
||||||
this.id = getId('play')
|
this.id = getId('play')
|
||||||
this.userId = user.id
|
this.userId = user.id
|
||||||
|
Loading…
Reference in New Issue
Block a user