mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-05 00:18:30 +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) {
|
function parseChapters(chapters) {
|
||||||
if (!chapters) return []
|
if (!chapters) return []
|
||||||
|
let index = 0
|
||||||
return chapters.map(chap => {
|
return chapters.map(chap => {
|
||||||
var title = chap['TAG:title'] || chap.title || ''
|
let title = chap['TAG:title'] || chap.title || ''
|
||||||
if (!title && chap.tags && chap.tags.title) title = chap.tags.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
|
const timebase = 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
|
const 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 end = !isNullOrNaN(chap.end_time) ? Number(chap.end_time) : !isNullOrNaN(chap.end) ? Number(chap.end) / timebase : 0
|
||||||
return {
|
return {
|
||||||
id: chap.id,
|
id: index++,
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
title
|
title
|
||||||
|
Loading…
Reference in New Issue
Block a user