From 96a7c7f4d1829a2fc258d100107917f03eda085e Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 15 Jul 2023 12:46:51 -0500 Subject: [PATCH] Fix:Embedded chapters with invalid IDs, update chapter ids to always be the index #1783 --- server/utils/prober.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/utils/prober.js b/server/utils/prober.js index 8c818d53..17aecfbd 100644 --- a/server/utils/prober.js +++ b/server/utils/prober.js @@ -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