mirror of
https://github.com/sudoxnym/audiobookshelf-atv.git
synced 2026-07-19 10:14:20 +00:00
Update the parse description to identify time marker in anchor links
This commit is contained in:
parent
b833019a14
commit
67d32164d9
1 changed files with 11 additions and 12 deletions
|
|
@ -314,21 +314,20 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
parseDescription(description) {
|
||||
const timeMarkerRegex = /\d{1,2}:\d{1,2}(:\d{1,2})?/g
|
||||
const timeMarkerLinkRegex = /<a href="#([^"]*?\b\d{1,2}:\d{1,2}(?::\d{1,2})?)">(.*?)<\/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 `<span class="time-marker cursor-pointer text-blue-400 hover:text-blue-300" data-time="${seekTimeInSeconds}">${displayTime}</span>`
|
||||
}).replace(timeMarkerRegex, (match) => {
|
||||
const seekTimeInSeconds = convertToSeconds(match)
|
||||
return `<span class="time-marker cursor-pointer text-blue-400 hover:text-blue-300" data-time="${seekTimeInSeconds}">${match}</span>`
|
||||
})
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue