diff --git a/client/components/modals/podcast/ViewEpisode.vue b/client/components/modals/podcast/ViewEpisode.vue index 5a520ef4..b4358c5d 100644 --- a/client/components/modals/podcast/ViewEpisode.vue +++ b/client/components/modals/podcast/ViewEpisode.vue @@ -16,7 +16,7 @@
{{ title }}
- +{{ $strings.MessageNoDescription }}
@@ -68,7 +68,7 @@ export default { return this.episode.title || 'No Episode Title' }, description() { - return this.episode.description || '' + return this.parseDescription(this.episode.description || '') }, media() { return this.libraryItem?.media || {} @@ -94,7 +94,41 @@ export default { return this.$store.getters['libraries/getBookCoverAspectRatio'] } }, - methods: {}, + methods: { + handleDescriptionClick(e) { + if (e.target.matches('span.time-marker')) { + const time = parseInt(e.target.dataset.time) + if (!isNaN(time)) { + this.$eventBus.$emit('play-item', { + episodeId: this.episodeId, + libraryItemId: this.libraryItem.id, + startTime: time + }) + } + e.preventDefault() + } + }, + parseDescription(description) { + const timeMarkerLinkRegex = /(.*?)<\/a>/g + const timeMarkerRegex = /\b\d{1,2}:\d{1,2}(?::\d{1,2})?\b/g + + function convertToSeconds(time) { + const timeParts = time.split(':').map(Number) + return timeParts.reduce((acc, part, index) => acc * 60 + part, 0) + } + + return description + .replace(timeMarkerLinkRegex, (match, href, displayTime) => { + const time = displayTime.match(timeMarkerRegex)[0] + const seekTimeInSeconds = convertToSeconds(time) + return `${displayTime}` + }) + .replace(timeMarkerRegex, (match) => { + const seekTimeInSeconds = convertToSeconds(match) + return `${match}` + }) + } + }, mounted() {} }