diff --git a/pages/item/_id/_episode/index.vue b/pages/item/_id/_episode/index.vue index d0ccd69d..c33ee6f4 100644 --- a/pages/item/_id/_episode/index.vue +++ b/pages/item/_id/_episode/index.vue @@ -314,21 +314,20 @@ export default { }, methods: { parseDescription(description) { - const timeMarkerRegex = /\d{1,2}:\d{1,2}(:\d{1,2})?/g + const timeMarkerLinkRegex = /(.*?)<\/a>/g + const timeMarkerRegex = /\b\d{1,2}:\d{1,2}(?::\d{1,2})?\b/g - return description.replace(timeMarkerRegex, (match) => { - const time = match.replace(/[()]/g, '') + function convertToSeconds(time) { const timeParts = time.split(':').map(Number) - let seekTimeInSeconds - - if (timeParts.length === 2) { - const [minutes, seconds] = timeParts - seekTimeInSeconds = minutes * 60 + seconds - } else { - const [hours, minutes, seconds] = timeParts - seekTimeInSeconds = hours * 3600 + minutes * 60 + seconds - } + 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}` }) },