mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-05 15:04:56 +02:00
Adding chapters and downloading m4b file
This commit is contained in:
parent
07a2a0aefd
commit
299fc95c78
24 changed files with 311 additions and 69 deletions
|
@ -1,4 +1,5 @@
|
|||
const fs = require('fs-extra')
|
||||
const package = require('../../package.json')
|
||||
|
||||
function escapeSingleQuotes(path) {
|
||||
// return path.replace(/'/g, '\'\\\'\'')
|
||||
|
@ -34,4 +35,33 @@ async function writeConcatFile(tracks, outputPath, startTime = 0) {
|
|||
|
||||
return firstTrackStartTime
|
||||
}
|
||||
module.exports.writeConcatFile = writeConcatFile
|
||||
module.exports.writeConcatFile = writeConcatFile
|
||||
|
||||
|
||||
async function writeMetadataFile(audiobook, outputPath) {
|
||||
var inputstrs = [
|
||||
';FFMETADATA1',
|
||||
`title=${audiobook.title}`,
|
||||
`artist=${audiobook.author}`,
|
||||
`date=${audiobook.book.publishYear || ''}`,
|
||||
`comment=AudioBookshelf v${package.version}`,
|
||||
'genre=Audiobook'
|
||||
]
|
||||
|
||||
if (audiobook.chapters) {
|
||||
audiobook.chapters.forEach((chap) => {
|
||||
const chapterstrs = [
|
||||
'[CHAPTER]',
|
||||
'TIMEBASE=1/1000',
|
||||
`START=${Math.round(chap.start * 1000)}`,
|
||||
`END=${Math.round(chap.end * 1000)}`,
|
||||
`title=${chap.title}`
|
||||
]
|
||||
inputstrs = inputstrs.concat(chapterstrs)
|
||||
})
|
||||
}
|
||||
|
||||
await fs.writeFile(outputPath, inputstrs.join('\n'))
|
||||
return inputstrs
|
||||
}
|
||||
module.exports.writeMetadataFile = writeMetadataFile
|
Loading…
Add table
Add a link
Reference in a new issue