mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-07 16:44:16 +01:00
Merge pull request #632 from cassieesposito/getBookDataFromDir-refactor
URGENT: Fix to serious bug
This commit is contained in:
commit
97d4330cda
@ -216,8 +216,9 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) {
|
||||
// The may contain various other pieces of metadata, these functions extract it.
|
||||
var [folder, narrators] = getNarrator(folder)
|
||||
if (series) { var [folder, sequence] = getSequence(folder) }
|
||||
var [folder, sequence] = series ? getSequence(folder) : [folder, null]
|
||||
var [folder, publishedYear] = getPublishedYear(folder)
|
||||
if (parseSubtitle) { var [title, subtitle] = getSubtitle(folder) } // Subtitle can be parsed from the title if user enabled
|
||||
var [title, subtitle] = parseSubtitle ? getSubtitle(folder) : [folder, null]
|
||||
|
||||
return {
|
||||
mediaMetadata: {
|
||||
@ -330,10 +331,12 @@ async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath,
|
||||
var fileItems = []
|
||||
|
||||
if (isSingleMediaItem) { // Single media item in root of folder
|
||||
fileItems = [{
|
||||
fileItems = [
|
||||
{
|
||||
fullpath: libraryItemPath,
|
||||
path: libraryItemDir // actually the relPath (only filename here)
|
||||
}]
|
||||
}
|
||||
]
|
||||
libraryItemData = {
|
||||
path: libraryItemPath, // full path
|
||||
relPath: libraryItemDir, // only filename
|
||||
@ -366,10 +369,10 @@ async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath,
|
||||
for (let i = 0; i < fileItems.length; i++) {
|
||||
var fileItem = fileItems[i]
|
||||
var newLibraryFile = new LibraryFile()
|
||||
// fileItem.path is the relative path
|
||||
// fileItem.path is the relative path
|
||||
await newLibraryFile.setDataFromPath(fileItem.fullpath, fileItem.path)
|
||||
libraryItem.libraryFiles.push(newLibraryFile)
|
||||
}
|
||||
return libraryItem
|
||||
}
|
||||
module.exports.getLibraryItemFileData = getLibraryItemFileData
|
||||
module.exports.getLibraryItemFileData = getLibraryItemFileData
|
||||
|
Loading…
Reference in New Issue
Block a user