mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-26 07:49:03 +01:00
Fix:Embedded chapters with invalid IDs, update chapter ids to always be the index #1783
This commit is contained in:
parent
9c65d655b8
commit
96a7c7f4d1
@ -139,15 +139,16 @@ function isNullOrNaN(val) {
|
||||
*/
|
||||
function parseChapters(chapters) {
|
||||
if (!chapters) return []
|
||||
let index = 0
|
||||
return chapters.map(chap => {
|
||||
var title = chap['TAG:title'] || chap.title || ''
|
||||
if (!title && chap.tags && chap.tags.title) title = chap.tags.title
|
||||
let title = chap['TAG:title'] || chap.title || ''
|
||||
if (!title && chap.tags?.title) title = chap.tags.title
|
||||
|
||||
var timebase = chap.time_base && chap.time_base.includes('/') ? Number(chap.time_base.split('/')[1]) : 1
|
||||
var start = !isNullOrNaN(chap.start_time) ? Number(chap.start_time) : !isNullOrNaN(chap.start) ? Number(chap.start) / timebase : 0
|
||||
var end = !isNullOrNaN(chap.end_time) ? Number(chap.end_time) : !isNullOrNaN(chap.end) ? Number(chap.end) / timebase : 0
|
||||
const timebase = chap.time_base?.includes('/') ? Number(chap.time_base.split('/')[1]) : 1
|
||||
const start = !isNullOrNaN(chap.start_time) ? Number(chap.start_time) : !isNullOrNaN(chap.start) ? Number(chap.start) / timebase : 0
|
||||
const end = !isNullOrNaN(chap.end_time) ? Number(chap.end_time) : !isNullOrNaN(chap.end) ? Number(chap.end) / timebase : 0
|
||||
return {
|
||||
id: chap.id,
|
||||
id: index++,
|
||||
start,
|
||||
end,
|
||||
title
|
||||
|
Loading…
Reference in New Issue
Block a user