diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index 6eabdc4a..c20a7d7f 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -9,7 +9,7 @@

Duration:

-

{{ mediaDuration }}

+

{{ $secondsToTimestamp(mediaDurationRounded) }}

@@ -81,7 +81,7 @@

{{ track.metadata.filename }}

-

{{ track.duration }}

+

{{ $secondsToTimestamp(Math.round(track.duration), false, true) }}

check @@ -107,10 +107,16 @@ Find
-

Duration found: {{ chapterData.runtimeLengthSec }}

-
-

Chapter data invalid duration
Your media duration is shorter than duration found

+
+

+ Duration found: {{ $secondsToTimestamp(chapterData.runtimeLengthSec) }} +

+

+ Your audiobook duration: {{ $secondsToTimestamp(mediaDurationRounded) }} +

+ Your audiobook duration is shorter than duration found + Your audiobook duration is longer than the duration found
Start
@@ -126,7 +132,18 @@
+
+
+
+

Chapter end is after the end of your audiobook

+
+
+
+

Chapter start is after the end of your audiobook

+
+
+ Apply Names Only
Apply Chapters
@@ -197,6 +214,9 @@ export default { mediaDuration() { return this.media.duration }, + mediaDurationRounded() { + return Math.round(this.mediaDuration) + }, chapters() { return this.media.chapters || [] }, @@ -369,6 +389,7 @@ export default { this.$toast.error('Failed to update chapters') }) }, + applyChapterNamesOnly() {}, applyChapterData() { var index = 0 this.newChapters = this.chapterData.chapters diff --git a/client/plugins/utils.js b/client/plugins/utils.js index cb7198c8..6c29682b 100644 --- a/client/plugins/utils.js +++ b/client/plugins/utils.js @@ -27,18 +27,27 @@ Vue.prototype.$elapsedPretty = (seconds, useFullNames = false) => { return `${hours} ${useFullNames ? `hour${hours === 1 ? '' : 's'}` : 'hr'} ${minutes} ${useFullNames ? `minute${minutes === 1 ? '' : 's'}` : 'min'}` } -Vue.prototype.$secondsToTimestamp = (seconds) => { - if (!seconds) return '0:00' +Vue.prototype.$secondsToTimestamp = (seconds, includeMs = false, alwaysIncludeHours = false) => { + if (!seconds) { + return alwaysIncludeHours ? '00:00:00' : '0:00' + } var _seconds = seconds var _minutes = Math.floor(seconds / 60) _seconds -= _minutes * 60 var _hours = Math.floor(_minutes / 60) _minutes -= _hours * 60 + + var ms = _seconds - Math.floor(seconds) _seconds = Math.floor(_seconds) - if (!_hours) { - return `${_minutes}:${_seconds.toString().padStart(2, '0')}` + + var msString = includeMs ? '.' + ms.toFixed(3).split('.')[1] : '' + if (alwaysIncludeHours) { + return `${_hours.toString().padStart(2, '0')}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}${msString}` } - return `${_hours}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}` + if (!_hours) { + return `${_minutes}:${_seconds.toString().padStart(2, '0')}${msString}` + } + return `${_hours}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}${msString}` } Vue.prototype.$elapsedPrettyExtended = (seconds, useDays = true) => {