diff --git a/server/utils/scandir.js b/server/utils/scandir.js index 25258d71..d3c73269 100644 --- a/server/utils/scandir.js +++ b/server/utils/scandir.js @@ -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 \ No newline at end of file +module.exports.getLibraryItemFileData = getLibraryItemFileData