mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-13 23:11:29 +00:00
Merge 4e808e6770 into 47ea6b5092
This commit is contained in:
commit
f3a220c173
26 changed files with 2441 additions and 304 deletions
|
|
@ -113,7 +113,7 @@ class Task {
|
|||
/**
|
||||
* Set task as finished
|
||||
*
|
||||
* @param {TaskString} [newDescriptionString] update description
|
||||
* @param {TaskString | null} [newDescriptionString] update description
|
||||
* @param {boolean} [clearDescription] clear description
|
||||
*/
|
||||
setFinished(newDescriptionString = null, clearDescription = false) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class AudioFile {
|
|||
constructor(data) {
|
||||
this.index = null
|
||||
this.ino = null
|
||||
this.deviceId = null
|
||||
/** @type {FileMetadata} */
|
||||
this.metadata = null
|
||||
this.addedAt = null
|
||||
|
|
@ -44,6 +45,7 @@ class AudioFile {
|
|||
return {
|
||||
index: this.index,
|
||||
ino: this.ino,
|
||||
deviceId: this.deviceId,
|
||||
metadata: this.metadata.toJSON(),
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt,
|
||||
|
|
@ -69,9 +71,13 @@ class AudioFile {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ index: any; ino: any; deviceId: any; metadata: any; addedAt: any; updatedAt: any; manuallyVerified: any; exclude: any; error: null; trackNumFromMeta: any; discNumFromMeta: any; trackNumFromFilename: any; cdNumFromFilename: undefined; discNumFromFilename: any; format: any; duration: any; bitRate: any; language: any; codec: null; timeBase: any; channels: any; channelLayout: any; chapters: any[]; embeddedCoverArt: null; metaTags: any; }} data
|
||||
*/
|
||||
construct(data) {
|
||||
this.index = data.index
|
||||
this.ino = data.ino
|
||||
this.deviceId = data.deviceId
|
||||
this.metadata = new FileMetadata(data.metadata || {})
|
||||
this.addedAt = data.addedAt
|
||||
this.updatedAt = data.updatedAt
|
||||
|
|
@ -112,6 +118,7 @@ class AudioFile {
|
|||
// New scanner creates AudioFile from AudioFileScanner
|
||||
setDataFromProbe(libraryFile, probeData) {
|
||||
this.ino = libraryFile.ino || null
|
||||
this.deviceId = libraryFile.deviceId || null
|
||||
|
||||
if (libraryFile.metadata instanceof FileMetadata) {
|
||||
this.metadata = libraryFile.metadata.clone()
|
||||
|
|
@ -137,7 +144,7 @@ class AudioFile {
|
|||
|
||||
syncChapters(updatedChapters) {
|
||||
if (this.chapters.length !== updatedChapters.length) {
|
||||
this.chapters = updatedChapters.map(ch => ({ ...ch }))
|
||||
this.chapters = updatedChapters.map((ch) => ({ ...ch }))
|
||||
return true
|
||||
} else if (updatedChapters.length === 0) {
|
||||
if (this.chapters.length > 0) {
|
||||
|
|
@ -154,7 +161,7 @@ class AudioFile {
|
|||
}
|
||||
}
|
||||
if (hasUpdates) {
|
||||
this.chapters = updatedChapters.map(ch => ({ ...ch }))
|
||||
this.chapters = updatedChapters.map((ch) => ({ ...ch }))
|
||||
}
|
||||
return hasUpdates
|
||||
}
|
||||
|
|
@ -164,8 +171,8 @@ class AudioFile {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {AudioFile} scannedAudioFile
|
||||
*
|
||||
* @param {AudioFile} scannedAudioFile
|
||||
* @returns {boolean} true if updates were made
|
||||
*/
|
||||
updateFromScan(scannedAudioFile) {
|
||||
|
|
@ -196,4 +203,4 @@ class AudioFile {
|
|||
return hasUpdated
|
||||
}
|
||||
}
|
||||
module.exports = AudioFile
|
||||
module.exports = AudioFile
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
const FileMetadata = require('../metadata/FileMetadata')
|
||||
|
||||
class EBookFile {
|
||||
/**
|
||||
* @param {{ ino: any; deviceId: any; isSupplementary?: boolean; addedAt?: number; updatedAt?: number; metadata?: { filename: string; ext: string; path: string; relPath: string; size: number; mtimeMs: number; ctimeMs: number; birthtimeMs: number; }; libraryFolderId?: any; libraryId?: any; mediaType?: any; mtimeMs?: any; ctimeMs?: any; birthtimeMs?: any; path?: any; relPath?: any; isFile?: any; mediaMetadata?: any; libraryFiles?: any; }} file
|
||||
*/
|
||||
constructor(file) {
|
||||
this.ino = null
|
||||
this.deviceId = null
|
||||
this.metadata = null
|
||||
this.ebookFormat = null
|
||||
this.addedAt = null
|
||||
|
|
@ -13,8 +17,12 @@ class EBookFile {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ ino: any; deviceId: any; isSupplementary?: boolean | undefined; addedAt: any; updatedAt: any; metadata: any; libraryFolderId?: any; libraryId?: any; mediaType?: any; mtimeMs?: any; ctimeMs?: any; birthtimeMs?: any; path?: any; relPath?: any; isFile?: any; mediaMetadata?: any; libraryFiles?: any; ebookFormat?: any; }} file
|
||||
*/
|
||||
construct(file) {
|
||||
this.ino = file.ino
|
||||
this.deviceId = file.deviceId
|
||||
this.metadata = new FileMetadata(file.metadata)
|
||||
this.ebookFormat = file.ebookFormat || this.metadata.format
|
||||
this.addedAt = file.addedAt
|
||||
|
|
@ -24,6 +32,7 @@ class EBookFile {
|
|||
toJSON() {
|
||||
return {
|
||||
ino: this.ino,
|
||||
deviceId: this.deviceId,
|
||||
metadata: this.metadata.toJSON(),
|
||||
ebookFormat: this.ebookFormat,
|
||||
addedAt: this.addedAt,
|
||||
|
|
@ -37,6 +46,7 @@ class EBookFile {
|
|||
|
||||
setData(libraryFile) {
|
||||
this.ino = libraryFile.ino
|
||||
this.deviceId = libraryFile.deviceId
|
||||
this.metadata = libraryFile.metadata.clone()
|
||||
this.ebookFormat = libraryFile.metadata.format
|
||||
this.addedAt = Date.now()
|
||||
|
|
@ -58,4 +68,4 @@ class EBookFile {
|
|||
return hasUpdated
|
||||
}
|
||||
}
|
||||
module.exports = EBookFile
|
||||
module.exports = EBookFile
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
const Path = require('path')
|
||||
const { getFileTimestampsWithIno, filePathToPOSIX } = require('../../utils/fileUtils')
|
||||
const fileUtils = require('../../utils/fileUtils')
|
||||
const globals = require('../../utils/globals')
|
||||
const FileMetadata = require('../metadata/FileMetadata')
|
||||
|
||||
class LibraryFile {
|
||||
/**
|
||||
* @param {{ ino: any; deviceId: any; metadata?: { filename: any; ext: any; path: any; relPath: any; size: any; mtimeMs: any; ctimeMs: any; birthtimeMs: any; } | { filename: string; ext: string; path: string; relPath: string; size: number; mtimeMs: number; ctimeMs: number; birthtimeMs: number; } | null; isSupplementary?: any; addedAt?: any; updatedAt?: any; fileType?: string; libraryFolderId?: any; libraryId?: any; mediaType?: any; mtimeMs?: any; ctimeMs?: any; birthtimeMs?: any; path?: any; relPath?: any; isFile?: any; mediaMetadata?: any; libraryFiles?: any; } | undefined} [file]
|
||||
*/
|
||||
constructor(file) {
|
||||
this.ino = null
|
||||
this.deviceId = null
|
||||
this.metadata = null
|
||||
this.isSupplementary = null
|
||||
this.addedAt = null
|
||||
|
|
@ -18,6 +22,7 @@ class LibraryFile {
|
|||
|
||||
construct(file) {
|
||||
this.ino = file.ino
|
||||
this.deviceId = file.deviceId
|
||||
this.metadata = new FileMetadata(file.metadata)
|
||||
this.isSupplementary = file.isSupplementary === undefined ? null : file.isSupplementary
|
||||
this.addedAt = file.addedAt
|
||||
|
|
@ -27,7 +32,8 @@ class LibraryFile {
|
|||
toJSON() {
|
||||
return {
|
||||
ino: this.ino,
|
||||
metadata: this.metadata.toJSON(),
|
||||
deviceId: this.deviceId,
|
||||
metadata: this.metadata ? this.metadata.toJSON() : null,
|
||||
isSupplementary: this.isSupplementary,
|
||||
addedAt: this.addedAt,
|
||||
updatedAt: this.updatedAt,
|
||||
|
|
@ -40,11 +46,13 @@ class LibraryFile {
|
|||
}
|
||||
|
||||
get fileType() {
|
||||
if (globals.SupportedImageTypes.includes(this.metadata.format)) return 'image'
|
||||
if (globals.SupportedAudioTypes.includes(this.metadata.format)) return 'audio'
|
||||
if (globals.SupportedEbookTypes.includes(this.metadata.format)) return 'ebook'
|
||||
if (globals.TextFileTypes.includes(this.metadata.format)) return 'text'
|
||||
if (globals.MetadataFileTypes.includes(this.metadata.format)) return 'metadata'
|
||||
if (this.metadata) {
|
||||
if (globals.SupportedImageTypes.includes(this.metadata.format)) return 'image'
|
||||
if (globals.SupportedAudioTypes.includes(this.metadata.format)) return 'audio'
|
||||
if (globals.SupportedEbookTypes.includes(this.metadata.format)) return 'ebook'
|
||||
if (globals.TextFileTypes.includes(this.metadata.format)) return 'text'
|
||||
if (globals.MetadataFileTypes.includes(this.metadata.format)) return 'metadata'
|
||||
}
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
|
|
@ -61,14 +69,15 @@ class LibraryFile {
|
|||
}
|
||||
|
||||
async setDataFromPath(path, relPath) {
|
||||
var fileTsData = await getFileTimestampsWithIno(path)
|
||||
var fileTsData = await fileUtils.getFileTimestampsWithIno(path)
|
||||
var fileMetadata = new FileMetadata()
|
||||
fileMetadata.setData(fileTsData)
|
||||
fileMetadata.filename = Path.basename(relPath)
|
||||
fileMetadata.path = filePathToPOSIX(path)
|
||||
fileMetadata.relPath = filePathToPOSIX(relPath)
|
||||
fileMetadata.path = fileUtils.filePathToPOSIX(path)
|
||||
fileMetadata.relPath = fileUtils.filePathToPOSIX(relPath)
|
||||
fileMetadata.ext = Path.extname(relPath)
|
||||
this.ino = fileTsData.ino
|
||||
this.deviceId = fileTsData.dev
|
||||
this.metadata = fileMetadata
|
||||
this.addedAt = Date.now()
|
||||
this.updatedAt = Date.now()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue