diff --git a/client/pages/audiobook/_id/chapters.vue b/client/pages/audiobook/_id/chapters.vue index d5351dd5..73f8c537 100644 --- a/client/pages/audiobook/_id/chapters.vue +++ b/client/pages/audiobook/_id/chapters.vue @@ -22,6 +22,16 @@
+
+
+

Overdrive Media Markers Found! Would you like to generate chapter data from them?

+
+ Yes + +
+
+
+
Start
@@ -85,6 +95,7 @@ check
+
@@ -131,6 +142,45 @@ + + + +
+
+ + Find +
+
+

Duration found: {{ chapterData.runtimeLengthSec }}

+
+

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

+
+ +
+
Start
+
Title
+
+
+
+
+

{{ $secondsToTimestamp(chapter.startOffsetSec) }}

+
+
+

{{ chapter.title }}

+
+
+
+
+
+ Apply Chapters +
+
+
+
@@ -168,6 +218,7 @@ export default { asinInput: null, findingChapters: false, showFindChaptersModal: false, + showImportOverdriveMediaMarkersModal: false, chapterData: null } }, @@ -190,13 +241,19 @@ export default { mediaDuration() { return this.media.duration }, + overdriveMediaMarkersExist() { + return (this.overdriveMediaMarkers?.length > 0 ? true : false ) || false + }, + overdriveMediaMarkers() { + return this.audioFiles.map((af) => af.metaTags.tagOverdriveMediaMarker).filter(notUndefined => notUndefined !== undefined) || [] + }, chapters() { return this.media.chapters || [] }, tracks() { return this.media.tracks || [] }, - audioFiles() { + audioFiles() { return this.media.audioFiles || [] }, audioTracks() { @@ -207,6 +264,13 @@ export default { } }, methods: { + checkForOverdriveMediaMarkers() { + if (this.overdriveMediaMarkersExist) { + this.$toast.success('Your book has overdrive media markers!') + } else { + this.$toast.error('Your book DOES NOT have overdrive media markers!') + } + }, editItem() { this.$store.commit('showEditModal', this.libraryItem) }, @@ -392,7 +456,7 @@ export default { this.$toast.error(data.error) this.showFindChaptersModal = false } else { - console.log('Chapter data', data) + console.log('Chapter data', JSON.stringify(data)) this.chapterData = data } }) @@ -402,9 +466,41 @@ export default { this.$toast.error('Failed to find chapters') this.showFindChaptersModal = false }) + }, + // overdrive + generateChaptersFromOverdriveMediaMarkers() { + var parseString = require('xml2js').parseString; + var xml = this.overdriveMediaMarkers[0] + var parsedXML = {} + parseString(xml, function (err, result) { + parsedXML = result + }); + + var index = 0 + var newOChapters = parsedXML.Markers.Marker.map((marker) => { + return { + id: index++, + start: marker.Time[0], + end: 0, + title: marker.Name[0] + } + }) + console.log(newOChapters) + //console.log(this.overdriveMediaMarkers[0]) + // console.log(JSON.stringify(x)) + //console.log(parseString(this.overdriveMediaMarkers[0])) + // { + // id:, + // start: + // end: + // title: + // } + this.overdriveMediaMarkers } }, mounted() { + this.checkForOverdriveMediaMarkers() + var dismissed = false this.asinInput = this.mediaMetadata.asin || null this.newChapters = this.chapters.map((c) => ({ ...c })) if (!this.newChapters.length) {