From 8781930cedcac1b6b2f36f7c7cb801b48dd109e1 Mon Sep 17 00:00:00 2001 From: Binyamin Blatt Date: Sun, 20 Sep 2026 00:01:56 +0300 Subject: [PATCH 1/6] Fix undeclared variables --- server/utils/scandir.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/utils/scandir.js b/server/utils/scandir.js index 6dd2d67fe..59a0c2427 100644 --- a/server/utils/scandir.js +++ b/server/utils/scandir.js @@ -150,8 +150,8 @@ 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/ + var series = splitDir.length > 1 ? splitDir.pop() : null // If there are at least 2 more directories, next furthest will be the series + var 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) @@ -234,7 +234,7 @@ function getSequence(folder) { function getPublishedYear(folder) { var publishedYear = null - pattern = /^ *\(?([0-9]{4})\)? * - *(.+)/ //Matches #### - title or (####) - title + const pattern = /^ *\(?([0-9]{4})\)? * - *(.+)/ //Matches #### - title or (####) - title var match = folder.match(pattern) if (match) { publishedYear = match[1] From 6acb4b9005ab84ad3b7348e5e21cb1870c3222fa Mon Sep 17 00:00:00 2001 From: Binyamin Blatt Date: Sun, 20 Sep 2026 00:45:24 +0300 Subject: [PATCH 2/6] fix no-undef in BackupManager --- server/managers/BackupManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From 088c4f542fe7b02ce313a6b7949ac0ddc7a7d15f Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 19 Sep 2026 16:47:40 -0500 Subject: [PATCH 3/6] Cleanup scandir variables --- server/utils/scandir.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/server/utils/scandir.js b/server/utils/scandir.js index 59a0c2427..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 - var series = splitDir.length > 1 ? splitDir.pop() : null // If there are at least 2 more directories, next furthest will be the series - var 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 = /^(?.*) \{(?<narrators>.*)\}$/ - let match = folder.match(pattern) + const pattern = /^(?<title>.*) \{(?<narrators>.*)\}$/ + const match = folder.match(pattern) return match ? [match.groups.title, match.groups.narrators] : [folder, null] } @@ -204,12 +204,12 @@ function getNarrator(folder) { */ function getSequence(folder) { // Matches a valid volume string. Also matches a book whose title starts with a 1 to 3 digit number. Will handle that later. - let pattern = /^(?<volumeLabel>vol\.? |volume |book )?(?<sequence>\d{0,3}(?:\.\d{1,2})?)(?<trailingDot>\.?)(?: (?<suffix>.*))?$/i + const pattern = /^(?<volumeLabel>vol\.? |volume |book )?(?<sequence>\d{0,3}(?:\.\d{1,2})?)(?<trailingDot>\.?)(?: (?<suffix>.*))?$/i let volumeNumber = null - let parts = folder.split(' - ') + const parts = folder.split(' - ') for (let i = 0; i < parts.length; i++) { - let match = parts[i].match(pattern) + const match = parts[i].match(pattern) // This excludes '101 Dalmations' but includes '101. Dalmations' if (match && !(match.groups.suffix && !(match.groups.volumeLabel || match.groups.trailingDot))) { volumeNumber = isNaN(match.groups.sequence) ? match.groups.sequence : Number(match.groups.sequence).toString() @@ -232,10 +232,10 @@ function getSequence(folder) { * @returns {[string, string]} [folder, publishedYear] */ function getPublishedYear(folder) { - var publishedYear = null + let publishedYear = null const pattern = /^ *\(?([0-9]{4})\)? * - *(.+)/ //Matches #### - title or (####) - title - var match = folder.match(pattern) + const match = folder.match(pattern) if (match) { publishedYear = match[1] folder = match[2] @@ -252,7 +252,7 @@ function getPublishedYear(folder) { */ function getSubtitle(folder) { // Subtitle is everything after " - " - var splitTitle = folder.split(' - ') + const splitTitle = folder.split(' - ') return [splitTitle.shift(), splitTitle.join(' - ')] } @@ -265,7 +265,7 @@ function getSubtitle(folder) { function getASIN(folder) { let asin = null - let pattern = /(?: |^)\[([A-Z0-9]{10})](?= |$)/ // Matches "[B0015T963C]" + const pattern = /(?: |^)\[([A-Z0-9]{10})](?= |$)/ // Matches "[B0015T963C]" const match = folder.match(pattern) if (match) { asin = match[1] From a3b150d049efbf293dd92b67417b49b7220aa235 Mon Sep 17 00:00:00 2001 From: advplyr <advplyr@protonmail.com> Date: Sat, 19 Sep 2026 16:48:45 -0500 Subject: [PATCH 4/6] Fix undefined var in nodeFfprobe --- server/libs/nodeFfprobe/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 +})() From 608d3ddde8e6b62f35d3c63fdabd39df2fdb6481 Mon Sep 17 00:00:00 2001 From: advplyr <advplyr@protonmail.com> Date: Sat, 19 Sep 2026 16:57:01 -0500 Subject: [PATCH 5/6] Fix undefined binaryPath in BinaryManager --- server/managers/BinaryManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 5077f87e0ca96914aad2e6d558cc6834a4cb1114 Mon Sep 17 00:00:00 2001 From: advplyr <advplyr@protonmail.com> Date: Sat, 19 Sep 2026 16:59:02 -0500 Subject: [PATCH 6/6] Fix undefined variable in podcastUtils --- server/utils/podcastUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 '' }