mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Update Nfo scanner and auto-formatting
This commit is contained in:
parent
71cd86fdd5
commit
4289fe4990
@ -2,7 +2,7 @@ const { parseNfoMetadata } = require('../utils/parsers/parseNfoMetadata')
|
|||||||
const { readTextFile } = require('../utils/fileUtils')
|
const { readTextFile } = require('../utils/fileUtils')
|
||||||
|
|
||||||
class NfoFileScanner {
|
class NfoFileScanner {
|
||||||
constructor() { }
|
constructor() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse metadata from .nfo file found in library scan and update bookMetadata
|
* Parse metadata from .nfo file found in library scan and update bookMetadata
|
||||||
@ -15,11 +15,13 @@ class NfoFileScanner {
|
|||||||
const nfoMetadata = nfoText ? await parseNfoMetadata(nfoText) : null
|
const nfoMetadata = nfoText ? await parseNfoMetadata(nfoText) : null
|
||||||
if (nfoMetadata) {
|
if (nfoMetadata) {
|
||||||
for (const key in nfoMetadata) {
|
for (const key in nfoMetadata) {
|
||||||
if (key === 'tags') { // Add tags only if tags are empty
|
if (key === 'tags') {
|
||||||
|
// Add tags only if tags are empty
|
||||||
if (nfoMetadata.tags.length) {
|
if (nfoMetadata.tags.length) {
|
||||||
bookMetadata.tags = nfoMetadata.tags
|
bookMetadata.tags = nfoMetadata.tags
|
||||||
}
|
}
|
||||||
} else if (key === 'genres') { // Add genres only if genres are empty
|
} else if (key === 'genres') {
|
||||||
|
// Add genres only if genres are empty
|
||||||
if (nfoMetadata.genres.length) {
|
if (nfoMetadata.genres.length) {
|
||||||
bookMetadata.genres = nfoMetadata.genres
|
bookMetadata.genres = nfoMetadata.genres
|
||||||
}
|
}
|
||||||
@ -33,14 +35,12 @@ class NfoFileScanner {
|
|||||||
}
|
}
|
||||||
} else if (key === 'series') {
|
} else if (key === 'series') {
|
||||||
if (nfoMetadata.series) {
|
if (nfoMetadata.series) {
|
||||||
bookMetadata.series = [{
|
bookMetadata.series = [
|
||||||
|
{
|
||||||
name: nfoMetadata.series,
|
name: nfoMetadata.series,
|
||||||
sequence: nfoMetadata.sequence || null
|
sequence: nfoMetadata.sequence || null
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
} else if (key === 'language') {
|
]
|
||||||
if (nfoMetadata.language) {
|
|
||||||
bookMetadata.language = nfoMetadata.language
|
|
||||||
}
|
}
|
||||||
} else if (nfoMetadata[key] && key !== 'sequence') {
|
} else if (nfoMetadata[key] && key !== 'sequence') {
|
||||||
bookMetadata[key] = nfoMetadata[key]
|
bookMetadata[key] = nfoMetadata[key]
|
||||||
|
Loading…
Reference in New Issue
Block a user