mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 09:51:37 +00:00
Add logging when author normalization is empty
This commit is contained in:
parent
6b97fc0ce6
commit
c814a84b27
3 changed files with 12 additions and 2 deletions
|
|
@ -480,7 +480,10 @@ class Book extends Model {
|
||||||
const authorsAdded = []
|
const authorsAdded = []
|
||||||
for (const authorName of newAuthorNames) {
|
for (const authorName of newAuthorNames) {
|
||||||
const { author, created } = await authorModel.findOrCreateByNameAndLibrary(authorName, libraryId)
|
const { author, created } = await authorModel.findOrCreateByNameAndLibrary(authorName, libraryId)
|
||||||
if (!author) continue
|
if (!author) {
|
||||||
|
Logger.warn(`[Book] "${this.title}" skipped author "${authorName}" because normalized name was empty`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
await bookAuthorModel.create({ bookId: this.id, authorId: author.id })
|
await bookAuthorModel.create({ bookId: this.id, authorId: author.id })
|
||||||
if (created) {
|
if (created) {
|
||||||
SocketAuthority.emitter('author_added', author.toOldJSON())
|
SocketAuthority.emitter('author_added', author.toOldJSON())
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,10 @@ class BookScanner {
|
||||||
for (const authorName of bookMetadata.authors) {
|
for (const authorName of bookMetadata.authors) {
|
||||||
if (!media.authors.some((au) => Database.authorModel.isAuthorNameMatch(au.name, authorName))) {
|
if (!media.authors.some((au) => Database.authorModel.isAuthorNameMatch(au.name, authorName))) {
|
||||||
const { author, created } = await Database.authorModel.findOrCreateByNameAndLibrary(authorName, libraryItemData.libraryId)
|
const { author, created } = await Database.authorModel.findOrCreateByNameAndLibrary(authorName, libraryItemData.libraryId)
|
||||||
|
if (!author) {
|
||||||
|
libraryScan.addLog(LogLevel.WARN, `Skipping author "${authorName}" because normalized name was empty`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (!created) {
|
if (!created) {
|
||||||
await Database.bookAuthorModel.create({
|
await Database.bookAuthorModel.create({
|
||||||
bookId: media.id,
|
bookId: media.id,
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,10 @@ class Scanner {
|
||||||
const existingAuthor = libraryItem.media.authors.find((a) => Database.authorModel.isAuthorNameMatch(a.name, authorName))
|
const existingAuthor = libraryItem.media.authors.find((a) => Database.authorModel.isAuthorNameMatch(a.name, authorName))
|
||||||
if (!existingAuthor) {
|
if (!existingAuthor) {
|
||||||
const { author, created: isCreated } = await Database.authorModel.findOrCreateByNameAndLibrary(authorName, libraryItem.libraryId)
|
const { author, created: isCreated } = await Database.authorModel.findOrCreateByNameAndLibrary(authorName, libraryItem.libraryId)
|
||||||
if (!author) continue
|
if (!author) {
|
||||||
|
libraryScan.addLog(LogLevel.WARN, `Skipping author "${authorName}" because normalized name was empty`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (isCreated) {
|
if (isCreated) {
|
||||||
SocketAuthority.emitter('author_added', author.toOldJSON())
|
SocketAuthority.emitter('author_added', author.toOldJSON())
|
||||||
// Update filter data
|
// Update filter data
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue