Abort backup if it is getting too large #89, support for ebook only book folders #75

This commit is contained in:
advplyr 2021-10-10 16:36:21 -05:00
parent 0c168b3da4
commit 04f92c33c2
18 changed files with 258 additions and 149 deletions

View file

@ -16,11 +16,12 @@ function getPaths(path) {
})
}
function isAudioFile(path) {
function isBookFile(path) {
if (!path) return false
var ext = Path.extname(path)
if (!ext) return false
return globals.SupportedAudioTypes.includes(ext.slice(1).toLowerCase())
var extclean = ext.slice(1).toLowerCase()
return globals.SupportedAudioTypes.includes(extclean) || globals.SupportedEbookTypes.includes(extclean)
}
// Input: array of relative file paths
@ -36,17 +37,18 @@ function groupFilesIntoAudiobookPaths(paths, useAllFileTypes = false) {
return pathsA - pathsB
})
// Step 2.5: Seperate audio files and other files (optional)
var audioFilePaths = []
// Step 2.5: Seperate audio/ebook files and other files (optional)
// - Directories without an audio or ebook file will not be included
var bookFilePaths = []
var otherFilePaths = []
pathsFiltered.forEach(path => {
if (isAudioFile(path) || useAllFileTypes) audioFilePaths.push(path)
if (isBookFile(path) || useAllFileTypes) bookFilePaths.push(path)
else otherFilePaths.push(path)
})
// Step 3: Group audio files in audiobooks
var audiobookGroup = {}
audioFilePaths.forEach((path) => {
bookFilePaths.forEach((path) => {
var dirparts = Path.dirname(path).split(Path.sep)
var numparts = dirparts.length
var _path = ''