mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-04-25 23:06:43 +02:00
Update:Create library endpoint to create using new model, adding additional validation
This commit is contained in:
@@ -45,6 +45,35 @@ class Library extends Model {
|
||||
this.updatedAt
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} mediaType
|
||||
* @returns
|
||||
*/
|
||||
static getDefaultLibrarySettingsForMediaType(mediaType) {
|
||||
if (mediaType === 'podcast') {
|
||||
return {
|
||||
coverAspectRatio: 1, // Square
|
||||
disableWatcher: false,
|
||||
autoScanCronExpression: null,
|
||||
podcastSearchRegion: 'us'
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
coverAspectRatio: 1, // Square
|
||||
disableWatcher: false,
|
||||
autoScanCronExpression: null,
|
||||
skipMatchingMediaWithAsin: false,
|
||||
skipMatchingMediaWithIsbn: false,
|
||||
audiobooksOnly: false,
|
||||
epubsAllowScriptedContent: false,
|
||||
hideSingleBookSeries: false,
|
||||
onlyShowLaterBooksInContinueSeries: false,
|
||||
metadataPrecedence: ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all old libraries
|
||||
* @returns {Promise<oldLibrary[]>}
|
||||
@@ -89,28 +118,6 @@ class Library extends Model {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} oldLibrary
|
||||
* @returns {Library|null}
|
||||
*/
|
||||
static async createFromOld(oldLibrary) {
|
||||
const library = this.getFromOld(oldLibrary)
|
||||
|
||||
library.libraryFolders = oldLibrary.folders.map((folder) => {
|
||||
return {
|
||||
id: folder.id,
|
||||
path: folder.fullPath
|
||||
}
|
||||
})
|
||||
|
||||
return this.create(library, {
|
||||
include: this.sequelize.models.libraryFolder
|
||||
}).catch((error) => {
|
||||
Logger.error(`[Library] Failed to create library ${library.id}`, error)
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Update library and library folders
|
||||
* @param {object} oldLibrary
|
||||
|
||||
Reference in New Issue
Block a user