diff --git a/server/libs/nodeFfprobe/index.js b/server/libs/nodeFfprobe/index.js index bdab89ad0..5b33db6cf 100644 --- a/server/libs/nodeFfprobe/index.js +++ b/server/libs/nodeFfprobe/index.js @@ -15,20 +15,23 @@ module.exports = (function () { proc.stdout.setEncoding('utf8') proc.stderr.setEncoding('utf8') - proc.stdout.on('data', function (data) { probeData.push(data) }) - proc.stderr.on('data', function (data) { errData.push(data) }) + proc.stdout.on('data', function (data) { + probeData.push(data) + }) + proc.stderr.on('data', function (data) { + errData.push(data) + }) - proc.on('exit', code => { exitCode = code }) - proc.on('error', err => reject(err)) + proc.on('error', (err) => reject(err)) proc.on('close', () => { try { - resolve(JSON.parse(probeData.join(''))) + resolve(JSON.parse(probeData.join(''))) } catch (err) { - reject(err); + reject(err) } }) }) } return doProbe -})() \ No newline at end of file +})() diff --git a/server/managers/BackupManager.js b/server/managers/BackupManager.js index a7b531e62..1be370c8c 100644 --- a/server/managers/BackupManager.js +++ b/server/managers/BackupManager.js @@ -112,7 +112,7 @@ class BackupManager { .mv(tempPath) .then(() => true) .catch((error) => { - Logger.error('[BackupManager] Failed to move backup file', path, error) + Logger.error('[BackupManager] Failed to move backup file', tempPath, error) return false }) if (!success) { diff --git a/server/managers/BinaryManager.js b/server/managers/BinaryManager.js index f16d47c0b..17eefa60e 100644 --- a/server/managers/BinaryManager.js +++ b/server/managers/BinaryManager.js @@ -369,8 +369,8 @@ class BinaryManager { * @param {Binary} binary */ async removeBinary(destination, binary) { + const binaryPath = path.join(destination, binary.fileName) try { - const binaryPath = path.join(destination, binary.fileName) if (await fs.pathExists(binaryPath)) { Logger.debug(`[BinaryManager] Removing binary: ${binaryPath}`) await fs.remove(binaryPath) diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index 1cb0c4cb4..8ead98505 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -69,7 +69,7 @@ function extractStringOrStringify(json) { return json[Object.keys(json)[0]][0] } // Handles case where html was included without being wrapped in CDATA - return JSON.stringify(value) + return JSON.stringify(json) } catch { return '' } diff --git a/server/utils/scandir.js b/server/utils/scandir.js index 6dd2d67fe..7148ef06a 100644 --- a/server/utils/scandir.js +++ b/server/utils/scandir.js @@ -149,16 +149,16 @@ module.exports.buildLibraryFile = buildLibraryFile function getBookDataFromDir(relPath, parseSubtitle = false) { const splitDir = relPath.split('/') - var folder = splitDir.pop() // Audio files will always be in the directory named for the title - series = splitDir.length > 1 ? splitDir.pop() : null // If there are at least 2 more directories, next furthest will be the series - author = splitDir.length > 0 ? splitDir.pop() : null // There could be many more directories, but only the top 3 are used for naming /author/series/title/ + const titleFolder = splitDir.pop() // Audio files will always be in the directory named for the title + const series = splitDir.length > 1 ? splitDir.pop() : null // If there are at least 2 more directories, next furthest will be the series + const author = splitDir.length > 0 ? splitDir.pop() : null // There could be many more directories, but only the top 3 are used for naming /author/series/title/ - // The may contain various other pieces of metadata, these functions extract it. - var [folder, asin] = getASIN(folder) - var [folder, narrators] = getNarrator(folder) - var [folder, sequence] = series ? getSequence(folder) : [folder, null] - var [folder, publishedYear] = getPublishedYear(folder) - var [title, subtitle] = parseSubtitle ? getSubtitle(folder) : [folder, null] + // Each extractor strips one piece of metadata and returns the remaining folder name. + const [afterAsin, asin] = getASIN(titleFolder) + const [afterNarrators, narrators] = getNarrator(afterAsin) + const [afterSequence, sequence] = series ? getSequence(afterNarrators) : [afterNarrators, null] + const [afterYear, publishedYear] = getPublishedYear(afterSequence) + const [title, subtitle] = parseSubtitle ? getSubtitle(afterYear) : [afterYear, null] return { title, @@ -180,8 +180,8 @@ module.exports.getBookDataFromDir = getBookDataFromDir * @returns {[string, string]} [folder, narrator] */ function getNarrator(folder) { - let pattern = /^(?