mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-24 04:39:40 +00:00
Add:Support volumes with decimal #196, Change:Time remaining adjusted for current playback rate, Change:Series bookshelf shows shelf label with series name, Fix:Search bookshelf UI, Add:Show current chapter under audio track, Change: Highlight colors for chapters modal
This commit is contained in:
parent
24d2e09724
commit
ad8670aeb4
12 changed files with 101 additions and 44 deletions
|
|
@ -6,7 +6,7 @@ const Audnexus = require('./providers/Audnexus')
|
|||
|
||||
const { downloadFile } = require('./utils/fileUtils')
|
||||
|
||||
class AuthorController {
|
||||
class AuthorFinder {
|
||||
constructor(MetadataPath) {
|
||||
this.MetadataPath = MetadataPath
|
||||
this.AuthorPath = Path.join(MetadataPath, 'authors')
|
||||
|
|
@ -16,7 +16,7 @@ class AuthorController {
|
|||
|
||||
async downloadImage(url, outputPath) {
|
||||
return downloadFile(url, outputPath).then(() => true).catch((error) => {
|
||||
Logger.error('[AuthorController] Failed to download author image', error)
|
||||
Logger.error('[AuthorFinder] Failed to download author image', error)
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ class AuthorController {
|
|||
var success = await this.downloadImage(payload.image, outputPath)
|
||||
if (!success) {
|
||||
await fs.rmdir(authorDir).catch((error) => {
|
||||
Logger.error(`[AuthorController] Failed to remove author dir`, authorDir, error)
|
||||
Logger.error(`[AuthorFinder] Failed to remove author dir`, authorDir, error)
|
||||
})
|
||||
payload.image = null
|
||||
payload.imageFullPath = null
|
||||
|
|
@ -88,7 +88,7 @@ class AuthorController {
|
|||
var success = await this.downloadImage(authorData.image, outputPath)
|
||||
if (!success) {
|
||||
await fs.rmdir(authorDir).catch((error) => {
|
||||
Logger.error(`[AuthorController] Failed to remove author dir`, authorDir, error)
|
||||
Logger.error(`[AuthorFinder] Failed to remove author dir`, authorDir, error)
|
||||
})
|
||||
authorData.image = null
|
||||
authorData.imageFullPath = null
|
||||
|
|
@ -107,4 +107,4 @@ class AuthorController {
|
|||
return author
|
||||
}
|
||||
}
|
||||
module.exports = AuthorController
|
||||
module.exports = AuthorFinder
|
||||
|
|
@ -124,6 +124,8 @@ class FolderWatcher extends EventEmitter {
|
|||
}
|
||||
|
||||
addFileUpdate(libraryId, path, type) {
|
||||
console.log('add file update', libraryId, path, type)
|
||||
return
|
||||
path = path.replace(/\\/g, '/')
|
||||
if (this.pendingFilePaths.includes(path)) return
|
||||
|
||||
|
|
|
|||
33
server/scanner/AuthorScanner.js
Normal file
33
server/scanner/AuthorScanner.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
const AuthorFinder = require('../AuthorFinder')
|
||||
|
||||
class AuthorScanner {
|
||||
constructor(db, MetadataPath) {
|
||||
this.db = db
|
||||
this.MetadataPath = MetadataPath
|
||||
this.authorFinder = new AuthorFinder(MetadataPath)
|
||||
}
|
||||
|
||||
getUniqueAuthors() {
|
||||
var authorFls = this.db.audiobooks.map(b => b.book.authorFL)
|
||||
var authors = []
|
||||
authorFls.forEach((auth) => {
|
||||
authors = authors.concat(auth.split(', ').map(a => a.trim()))
|
||||
})
|
||||
return [...new Set(authors)]
|
||||
}
|
||||
|
||||
async scanAuthors() {
|
||||
var authors = this.getUniqueAuthors()
|
||||
for (let i = 0; i < authors.length; i++) {
|
||||
var authorName = authors[i]
|
||||
var author = await this.authorFinder.getAuthorByName(authorName)
|
||||
if (!author) {
|
||||
return res.status(500).send('Failed to create author')
|
||||
}
|
||||
|
||||
await this.db.insertEntity('author', author)
|
||||
this.emitter('author_added', author.toJSON())
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = AuthorScanner
|
||||
|
|
@ -206,7 +206,8 @@ function getAudiobookDataFromDir(folderPath, dir, parseSubtitle = false) {
|
|||
*/
|
||||
var volumeNumber = null
|
||||
if (series) {
|
||||
var volumeMatch = title.match(/(-? ?)\b((?:Book|Vol.?|Volume) (\d{1,3}))\b( ?-?)/i)
|
||||
// New volume regex to match volumes with decimal (OLD: /(-? ?)\b((?:Book|Vol.?|Volume) (\d{1,3}))\b( ?-?)/i)
|
||||
var volumeMatch = title.match(/(-? ?)\b((?:Book|Vol.?|Volume) (\d{0,3}(?:\.\d{1,2})?))\b( ?-?)/i)
|
||||
if (volumeMatch && volumeMatch.length > 3 && volumeMatch[2] && volumeMatch[3]) {
|
||||
volumeNumber = volumeMatch[3]
|
||||
var replaceChunk = volumeMatch[2]
|
||||
|
|
@ -226,9 +227,6 @@ function getAudiobookDataFromDir(folderPath, dir, parseSubtitle = false) {
|
|||
|
||||
|
||||
var publishYear = null
|
||||
// OLD regex (not matching parentheses)
|
||||
// var publishYearMatch = title.match(/^([0-9]{4}) - (.+)/)
|
||||
|
||||
// If Title is of format 1999 OR (1999) - Title, then use 1999 as publish year
|
||||
var publishYearMatch = title.match(/^(\(?[0-9]{4}\)?) - (.+)/)
|
||||
if (publishYearMatch && publishYearMatch.length > 2 && publishYearMatch[1]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue