mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-13 06:51:29 +00:00
Merge branch 'advplyr:master' into auto-generate-chapters-from-timestamps
This commit is contained in:
commit
64fd42ebf4
26 changed files with 197 additions and 67 deletions
|
|
@ -48,6 +48,8 @@ module.exports.AudioMimeType = {
|
|||
AIF: 'audio/x-aiff',
|
||||
WEBM: 'audio/webm',
|
||||
WEBMA: 'audio/webm',
|
||||
// TODO: Switch to `audio/matroska`? marked as deprecated in IANA registry
|
||||
// ref: https://datatracker.ietf.org/doc/html/rfc9559
|
||||
MKA: 'audio/x-matroska',
|
||||
AWB: 'audio/amr-wb',
|
||||
CAF: 'audio/x-caf',
|
||||
|
|
|
|||
|
|
@ -54,6 +54,16 @@ module.exports.isNullOrNaN = (num) => {
|
|||
return num === null || isNaN(num)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number|null|undefined} value
|
||||
* @param {number} max
|
||||
* @returns {number|null}
|
||||
*/
|
||||
module.exports.clampPositiveInt = (value, max) => {
|
||||
if (value == null || !Number.isFinite(value) || value <= 0) return null
|
||||
return Math.min(Math.floor(value), max)
|
||||
}
|
||||
|
||||
const xmlToJSON = (xml) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
parseString(xml, (err, results) => {
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@ function extractEpisodeData(item) {
|
|||
episode[cleanKey] = extractFirstArrayItemString(item, key)
|
||||
})
|
||||
|
||||
if (episode.subtitle) {
|
||||
episode.subtitle = htmlSanitizer.sanitize(episode.subtitle.trim())
|
||||
}
|
||||
|
||||
// Extract psc:chapters if duration is set
|
||||
episode.durationSeconds = episode.duration ? timestampToSeconds(episode.duration) : null
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue