Fix ebook url #75, download other files #75, fix book icon disappearing #88, backups #87

This commit is contained in:
advplyr 2021-10-08 17:30:20 -05:00
parent f752c19418
commit e80ec10e8a
32 changed files with 954 additions and 74 deletions

View file

@ -223,6 +223,7 @@ class Audiobook {
audioFiles: (this.audioFiles || []).map(audioFile => audioFile.toJSON()),
otherFiles: (this.otherFiles || []).map(otherFile => otherFile.toJSON()),
ebooks: (this.ebooks || []).map(ebook => ebook.toJSON()),
numEbooks: this.hasEpub ? 1 : 0,
tags: this.tags,
book: this.bookToJSON(),
tracks: this.tracksToJSON(),

75
server/objects/Backup.js Normal file
View file

@ -0,0 +1,75 @@
const Path = require('path')
const date = require('date-and-time')
class Backup {
constructor(data = null) {
this.id = null
this.datePretty = null
this.backupMetadataCovers = null
this.backupDirPath = null
this.filename = null
this.path = null
this.fullPath = null
this.fileSize = null
this.createdAt = null
if (data) {
this.construct(data)
}
}
get detailsString() {
var details = []
details.push(this.id)
details.push(this.backupMetadataCovers ? '1' : '0')
details.push(this.createdAt)
return details.join('\n')
}
construct(data) {
this.id = data.details[0]
this.backupMetadataCovers = data.details[1] === '1'
this.createdAt = Number(data.details[2])
this.datePretty = date.format(new Date(this.createdAt), 'ddd, MMM D YYYY HH:mm')
this.backupDirPath = Path.dirname(data.fullPath)
this.filename = Path.basename(data.fullPath)
this.path = Path.join('backups', this.filename)
this.fullPath = data.fullPath
}
toJSON() {
return {
id: this.id,
backupMetadataCovers: this.backupMetadataCovers,
backupDirPath: this.backupDirPath,
datePretty: this.datePretty,
path: this.path,
fullPath: this.fullPath,
path: this.path,
filename: this.filename,
fileSize: this.fileSize,
createdAt: this.createdAt
}
}
setData(data) {
this.id = date.format(new Date(), 'YYYY-MM-DD[T]HHmm')
this.datePretty = date.format(new Date(), 'ddd, MMM D YYYY HH:mm')
this.backupMetadataCovers = data.backupMetadataCovers
this.backupDirPath = data.backupDirPath
this.filename = this.id + '.audiobookshelf'
this.path = Path.join('backups', this.filename)
this.fullPath = Path.join(this.backupDirPath, this.filename)
console.log('Backup fullpath', this.fullPath)
this.createdAt = Date.now()
}
}
module.exports = Backup

View file

@ -5,14 +5,28 @@ class ServerSettings {
constructor(settings) {
this.id = 'server-settings'
// Misc/Unused
this.autoTagNew = false
this.newTagExpireDays = 15
// Scanner
this.scannerParseSubtitle = false
this.scannerFindCovers = false
// Metadata
this.coverDestination = CoverDestination.METADATA
this.saveMetadataFile = false
// Security/Rate limits
this.rateLimitLoginRequests = 10
this.rateLimitLoginWindow = 10 * 60 * 1000 // 10 Minutes
// Backups
// this.backupSchedule = '0 1 * * *' // If false then auto-backups are disabled (default every day at 1am)
this.backupSchedule = false
this.backupsToKeep = 2
this.backupMetadataCovers = true
this.logLevel = Logger.logLevel
if (settings) {
@ -29,6 +43,11 @@ class ServerSettings {
this.saveMetadataFile = !!settings.saveMetadataFile
this.rateLimitLoginRequests = !isNaN(settings.rateLimitLoginRequests) ? Number(settings.rateLimitLoginRequests) : 10
this.rateLimitLoginWindow = !isNaN(settings.rateLimitLoginWindow) ? Number(settings.rateLimitLoginWindow) : 10 * 60 * 1000 // 10 Minutes
this.backupSchedule = settings.backupSchedule || false
this.backupsToKeep = settings.backupsToKeep || 2
this.backupMetadataCovers = settings.backupMetadataCovers !== false
this.logLevel = settings.logLevel || Logger.logLevel
if (this.logLevel !== Logger.logLevel) {
@ -47,6 +66,9 @@ class ServerSettings {
saveMetadataFile: !!this.saveMetadataFile,
rateLimitLoginRequests: this.rateLimitLoginRequests,
rateLimitLoginWindow: this.rateLimitLoginWindow,
backupSchedule: this.backupSchedule,
backupsToKeep: this.backupsToKeep,
backupMetadataCovers: this.backupMetadataCovers,
logLevel: this.logLevel
}
}