mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 17:24:57 +02:00
Fixes for db migration & local playback sessions
This commit is contained in:
parent
63e5cf2e60
commit
d99b2c25e8
13 changed files with 750 additions and 119 deletions
|
@ -6,6 +6,7 @@ const { filePathToPOSIX } = require('../utils/fileUtils')
|
|||
class Library {
|
||||
constructor(library = null) {
|
||||
this.id = null
|
||||
this.oldLibraryId = null // TODO: Temp
|
||||
this.name = null
|
||||
this.folders = []
|
||||
this.displayOrder = 1
|
||||
|
@ -39,6 +40,7 @@ class Library {
|
|||
|
||||
construct(library) {
|
||||
this.id = library.id
|
||||
this.oldLibraryId = library.oldLibraryId
|
||||
this.name = library.name
|
||||
this.folders = (library.folders || []).map(f => new Folder(f))
|
||||
this.displayOrder = library.displayOrder || 1
|
||||
|
@ -74,6 +76,7 @@ class Library {
|
|||
toJSON() {
|
||||
return {
|
||||
id: this.id,
|
||||
oldLibraryId: this.oldLibraryId,
|
||||
name: this.name,
|
||||
folders: (this.folders || []).map(f => f.toJSON()),
|
||||
displayOrder: this.displayOrder,
|
||||
|
|
|
@ -16,6 +16,7 @@ class LibraryItem {
|
|||
constructor(libraryItem = null) {
|
||||
this.id = null
|
||||
this.ino = null // Inode
|
||||
this.oldLibraryItemId = null
|
||||
|
||||
this.libraryId = null
|
||||
this.folderId = null
|
||||
|
@ -52,6 +53,7 @@ class LibraryItem {
|
|||
construct(libraryItem) {
|
||||
this.id = libraryItem.id
|
||||
this.ino = libraryItem.ino || null
|
||||
this.oldLibraryItemId = libraryItem.oldLibraryItemId
|
||||
this.libraryId = libraryItem.libraryId
|
||||
this.folderId = libraryItem.folderId
|
||||
this.path = libraryItem.path
|
||||
|
@ -97,6 +99,7 @@ class LibraryItem {
|
|||
return {
|
||||
id: this.id,
|
||||
ino: this.ino,
|
||||
oldLibraryItemId: this.oldLibraryItemId,
|
||||
libraryId: this.libraryId,
|
||||
folderId: this.folderId,
|
||||
path: this.path,
|
||||
|
@ -121,6 +124,7 @@ class LibraryItem {
|
|||
return {
|
||||
id: this.id,
|
||||
ino: this.ino,
|
||||
oldLibraryItemId: this.oldLibraryItemId,
|
||||
libraryId: this.libraryId,
|
||||
folderId: this.folderId,
|
||||
path: this.path,
|
||||
|
@ -145,6 +149,7 @@ class LibraryItem {
|
|||
return {
|
||||
id: this.id,
|
||||
ino: this.ino,
|
||||
oldLibraryItemId: this.oldLibraryItemId,
|
||||
libraryId: this.libraryId,
|
||||
folderId: this.folderId,
|
||||
path: this.path,
|
||||
|
|
|
@ -115,13 +115,24 @@ class PlaybackSession {
|
|||
this.userId = session.userId
|
||||
this.libraryId = session.libraryId || null
|
||||
this.libraryItemId = session.libraryItemId
|
||||
this.bookId = session.bookId
|
||||
this.bookId = session.bookId || null
|
||||
this.episodeId = session.episodeId
|
||||
this.mediaType = session.mediaType
|
||||
this.duration = session.duration
|
||||
this.playMethod = session.playMethod
|
||||
this.mediaPlayer = session.mediaPlayer || null
|
||||
|
||||
// Temp do not store old IDs
|
||||
if (this.libraryId?.startsWith('lib_')) {
|
||||
this.libraryId = null
|
||||
}
|
||||
if (this.libraryItemId?.startsWith('li_') || this.libraryItemId?.startsWith('local_')) {
|
||||
this.libraryItemId = null
|
||||
}
|
||||
if (this.episodeId?.startsWith('ep_') || this.episodeId?.startsWith('local_')) {
|
||||
this.episodeId = null
|
||||
}
|
||||
|
||||
if (session.deviceInfo instanceof DeviceInfo) {
|
||||
this.deviceInfo = new DeviceInfo(session.deviceInfo.toJSON())
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,7 @@ class PodcastEpisode {
|
|||
this.libraryItemId = null
|
||||
this.podcastId = null
|
||||
this.id = null
|
||||
this.oldEpisodeId = null
|
||||
this.index = null
|
||||
|
||||
this.season = null
|
||||
|
@ -36,6 +37,7 @@ class PodcastEpisode {
|
|||
this.libraryItemId = episode.libraryItemId
|
||||
this.podcastId = episode.podcastId
|
||||
this.id = episode.id
|
||||
this.oldEpisodeId = episode.oldEpisodeId
|
||||
this.index = episode.index
|
||||
this.season = episode.season
|
||||
this.episode = episode.episode
|
||||
|
@ -59,6 +61,7 @@ class PodcastEpisode {
|
|||
libraryItemId: this.libraryItemId,
|
||||
podcastId: this.podcastId,
|
||||
id: this.id,
|
||||
oldEpisodeId: this.oldEpisodeId,
|
||||
index: this.index,
|
||||
season: this.season,
|
||||
episode: this.episode,
|
||||
|
@ -81,6 +84,7 @@ class PodcastEpisode {
|
|||
libraryItemId: this.libraryItemId,
|
||||
podcastId: this.podcastId,
|
||||
id: this.id,
|
||||
oldEpisodeId: this.oldEpisodeId,
|
||||
index: this.index,
|
||||
season: this.season,
|
||||
episode: this.episode,
|
||||
|
|
|
@ -335,6 +335,11 @@ class Podcast {
|
|||
}
|
||||
|
||||
getEpisode(episodeId) {
|
||||
if (!episodeId) return null
|
||||
|
||||
// Support old episode ids for mobile downloads
|
||||
if (episodeId.startsWith('ep_')) return this.episodes.find(ep => ep.oldEpisodeId == episodeId)
|
||||
|
||||
return this.episodes.find(ep => ep.id == episodeId)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue