mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-13 10:55:05 +02:00
Support for opus audio type, experimental features toggle, epub reader starting point
This commit is contained in:
parent
3dd8dc6dd4
commit
bd336345ee
14 changed files with 880 additions and 72 deletions
|
@ -1,42 +0,0 @@
|
|||
// const express = require('express')
|
||||
// const EPub = require('epub')
|
||||
// const Logger = require('./Logger')
|
||||
|
||||
// class EbookReader {
|
||||
// constructor(db, MetadataPath, AudiobookPath) {
|
||||
// this.db = db
|
||||
// this.MetadataPath = MetadataPath
|
||||
// this.AudiobookPath = AudiobookPath
|
||||
|
||||
// this.router = express()
|
||||
// this.init()
|
||||
// }
|
||||
|
||||
// init() {
|
||||
// this.router.get('/open/:id/:ino', this.openRequest.bind(this))
|
||||
// }
|
||||
|
||||
// openRequest(req, res) {
|
||||
// Logger.info('Open request received', req.params)
|
||||
// var audiobookId = req.params.id
|
||||
// var fileIno = req.params.ino
|
||||
// var audiobook = this.db.audiobooks.find(ab => ab.id === audiobookId)
|
||||
// if (!audiobook) {
|
||||
// return res.sendStatus(404)
|
||||
// }
|
||||
// var ebook = audiobook.ebooks.find(eb => eb.ino === fileIno)
|
||||
// if (!ebook) {
|
||||
// Logger.error('Ebook file not found', fileIno)
|
||||
// return res.sendStatus(404)
|
||||
// }
|
||||
// Logger.info('Ebook found', ebook)
|
||||
// this.open(ebook.fullPath)
|
||||
// res.sendStatus(200)
|
||||
// }
|
||||
|
||||
// open(path) {
|
||||
// var epub = new EPub(path)
|
||||
// console.log('epub', epub)
|
||||
// }
|
||||
// }
|
||||
// module.exports = EbookReader
|
|
@ -18,7 +18,6 @@ const StreamManager = require('./StreamManager')
|
|||
const RssFeeds = require('./RssFeeds')
|
||||
const DownloadManager = require('./DownloadManager')
|
||||
const CoverController = require('./CoverController')
|
||||
// const EbookReader = require('./EbookReader')
|
||||
const Logger = require('./Logger')
|
||||
|
||||
class Server {
|
||||
|
@ -44,8 +43,6 @@ class Server {
|
|||
this.apiController = new ApiController(this.MetadataPath, this.db, this.scanner, this.auth, this.streamManager, this.rssFeeds, this.downloadManager, this.coverController, this.emitter.bind(this), this.clientEmitter.bind(this))
|
||||
this.hlsController = new HlsController(this.db, this.scanner, this.auth, this.streamManager, this.emitter.bind(this), this.streamManager.StreamsPath)
|
||||
|
||||
// this.ebookReader = new EbookReader(this.db, this.MetadataPath, this.AudiobookPath)
|
||||
|
||||
this.server = null
|
||||
this.io = null
|
||||
|
||||
|
@ -277,7 +274,6 @@ class Server {
|
|||
app.use('/hls', this.authMiddleware.bind(this), this.hlsController.router)
|
||||
|
||||
// Incomplete work in progress
|
||||
// app.use('/ebook', this.ebookReader.router)
|
||||
// app.use('/feeds', this.rssFeeds.router)
|
||||
|
||||
app.post('/upload', this.authMiddleware.bind(this), this.handleUpload.bind(this))
|
||||
|
@ -292,6 +288,8 @@ class Server {
|
|||
res.json({ success: true })
|
||||
})
|
||||
|
||||
app.get('/test-fs', this.authMiddleware.bind(this), this.testFileSystem.bind(this))
|
||||
|
||||
// Used in development to set-up streams without authentication
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
app.use('/test-hls', this.hlsController.router)
|
||||
|
@ -440,5 +438,23 @@ class Server {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
testFileSystem(req, res) {
|
||||
Logger.debug(`[Server] Running fs test`)
|
||||
var paths = fs.readdir(global.appRoot)
|
||||
Logger.debug(paths)
|
||||
var pathMap = {}
|
||||
if (paths && paths.length) {
|
||||
for (let i = 0; i < paths.length; i++) {
|
||||
var fullPath = Path.join(global.appRoot, paths[i])
|
||||
Logger.debug('Checking path', fullPath)
|
||||
var _paths = fs.readdir(fullPath)
|
||||
Logger.debug(_paths)
|
||||
pathMap[paths[i]] = _paths
|
||||
}
|
||||
}
|
||||
Logger.debug('Finished fs test')
|
||||
res.json(pathMap)
|
||||
}
|
||||
}
|
||||
module.exports = Server
|
|
@ -115,6 +115,10 @@ class Audiobook {
|
|||
return this.otherFiles.filter(file => file.filetype === 'ebook')
|
||||
}
|
||||
|
||||
get hasEpub() {
|
||||
return this.otherFiles.find(file => file.ext === '.epub')
|
||||
}
|
||||
|
||||
get hasMissingIno() {
|
||||
return !this.ino || this._audioFiles.find(abf => !abf.ino) || this._otherFiles.find(f => !f.ino) || (this.tracks || []).find(t => !t.ino)
|
||||
}
|
||||
|
@ -173,7 +177,8 @@ class Audiobook {
|
|||
hasBookMatch: !!this.book,
|
||||
hasMissingParts: this.missingParts ? this.missingParts.length : 0,
|
||||
hasInvalidParts: this.invalidParts ? this.invalidParts.length : 0,
|
||||
numEbooks: this.ebooks.length,
|
||||
// numEbooks: this.ebooks.length,
|
||||
numEbooks: this.hasEpub ? 1 : 0,
|
||||
numTracks: this.tracks.length,
|
||||
chapters: this.chapters || [],
|
||||
isMissing: !!this.isMissing
|
||||
|
|
|
@ -50,6 +50,11 @@ class Stream extends EventEmitter {
|
|||
return this.audiobook.totalDuration
|
||||
}
|
||||
|
||||
get tracksAudioFileType() {
|
||||
if (!this.tracks.length) return null
|
||||
return this.tracks[0].ext.toLowerCase().slice(1)
|
||||
}
|
||||
|
||||
get hlsSegmentType() {
|
||||
var hasFlac = this.tracks.find(t => t.ext.toLowerCase() === '.flac')
|
||||
return hasFlac ? 'fmp4' : 'mpegts'
|
||||
|
@ -247,7 +252,7 @@ class Stream extends EventEmitter {
|
|||
}
|
||||
|
||||
const logLevel = process.env.NODE_ENV === 'production' ? 'error' : 'warning'
|
||||
const audioCodec = this.hlsSegmentType === 'fmp4' ? 'aac' : 'copy'
|
||||
const audioCodec = (this.hlsSegmentType === 'fmp4' || this.tracksAudioFileType === 'opus') ? 'aac' : 'copy'
|
||||
this.ffmpeg.addOption([
|
||||
`-loglevel ${logLevel}`,
|
||||
'-map 0:a',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const globals = {
|
||||
SupportedImageTypes: ['png', 'jpg', 'jpeg', 'webp'],
|
||||
SupportedAudioTypes: ['m4b', 'mp3', 'm4a', 'flac'],
|
||||
SupportedAudioTypes: ['m4b', 'mp3', 'm4a', 'flac', 'opus'],
|
||||
SupportedEbookTypes: ['epub', 'pdf', 'mobi']
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue