mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-17 00:08:55 +01:00
Update:API endpoint for updating book media does not require an id for new series/authors #1540
This commit is contained in:
parent
212b97fa20
commit
9fdc8df8bc
@ -504,11 +504,16 @@ class ApiRouter {
|
|||||||
|
|
||||||
// Create new authors if in payload
|
// Create new authors if in payload
|
||||||
if (mediaMetadata.authors && mediaMetadata.authors.length) {
|
if (mediaMetadata.authors && mediaMetadata.authors.length) {
|
||||||
// TODO: validate authors
|
|
||||||
const newAuthors = []
|
const newAuthors = []
|
||||||
for (let i = 0; i < mediaMetadata.authors.length; i++) {
|
for (let i = 0; i < mediaMetadata.authors.length; i++) {
|
||||||
if (mediaMetadata.authors[i].id.startsWith('new')) {
|
const authorName = (mediaMetadata.authors[i].name || '').trim()
|
||||||
let author = this.db.authors.find(au => au.checkNameEquals(mediaMetadata.authors[i].name))
|
if (!authorName) {
|
||||||
|
Logger.error(`[ApiRouter] Invalid author object, no name`, mediaMetadata.authors[i])
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mediaMetadata.authors[i].id || mediaMetadata.authors[i].id.startsWith('new')) {
|
||||||
|
let author = this.db.authors.find(au => au.checkNameEquals(authorName))
|
||||||
if (!author) {
|
if (!author) {
|
||||||
author = new Author()
|
author = new Author()
|
||||||
author.setData(mediaMetadata.authors[i])
|
author.setData(mediaMetadata.authors[i])
|
||||||
@ -528,11 +533,16 @@ class ApiRouter {
|
|||||||
|
|
||||||
// Create new series if in payload
|
// Create new series if in payload
|
||||||
if (mediaMetadata.series && mediaMetadata.series.length) {
|
if (mediaMetadata.series && mediaMetadata.series.length) {
|
||||||
// TODO: validate series
|
|
||||||
const newSeries = []
|
const newSeries = []
|
||||||
for (let i = 0; i < mediaMetadata.series.length; i++) {
|
for (let i = 0; i < mediaMetadata.series.length; i++) {
|
||||||
if (mediaMetadata.series[i].id.startsWith('new')) {
|
const seriesName = (mediaMetadata.series[i].name || '').trim()
|
||||||
let seriesItem = this.db.series.find(se => se.checkNameEquals(mediaMetadata.series[i].name))
|
if (!seriesName) {
|
||||||
|
Logger.error(`[ApiRouter] Invalid series object, no name`, mediaMetadata.series[i])
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mediaMetadata.series[i].id || mediaMetadata.series[i].id.startsWith('new')) {
|
||||||
|
let seriesItem = this.db.series.find(se => se.checkNameEquals(seriesName))
|
||||||
if (!seriesItem) {
|
if (!seriesItem) {
|
||||||
seriesItem = new Series()
|
seriesItem = new Series()
|
||||||
seriesItem.setData(mediaMetadata.series[i])
|
seriesItem.setData(mediaMetadata.series[i])
|
||||||
|
Loading…
Reference in New Issue
Block a user