feat: parse language from NFO metadata source

This commit is contained in:
Alex 2024-07-17 11:50:27 -04:00 committed by GitHub
parent 37ad1cced2
commit 9a697f48db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View File

@ -38,6 +38,10 @@ class NfoFileScanner {
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]
} }

View File

@ -81,6 +81,10 @@ function parseNfoMetadata(nfoText) {
case 'isbn-13': case 'isbn-13':
metadata.isbn = value metadata.isbn = value
break break
case 'language':
case 'lang':
metadata.language = value
break
} }
} }
}) })

View File

@ -103,6 +103,16 @@ describe('parseNfoMetadata', () => {
expect(result.asin).to.equal('B08X5JZJLH') expect(result.asin).to.equal('B08X5JZJLH')
}) })
it('parses language', () => {
const nfoText = 'Language: eng'
const result = parseNfoMetadata(nfoText)
expect(result.language).to.equal('eng')
const nfoText2 = 'lang: deu'
const result2 = parseNfoMetadata(nfoText2)
expect(result2.language).to.equal('deu')
})
it('parses description', () => { it('parses description', () => {
const nfoText = 'Book Description\n=========\nThis is a book.\n It\'s good' const nfoText = 'Book Description\n=========\nThis is a book.\n It\'s good'
const result = parseNfoMetadata(nfoText) const result = parseNfoMetadata(nfoText)