mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 05:52:06 +00:00
fix: edge case when release had partial chapters
This commit is contained in:
parent
3f2bc3e6b4
commit
126f767675
2 changed files with 28 additions and 7 deletions
|
|
@ -38,7 +38,7 @@ dependencies:
|
|||
electron-updater: 4.6.5
|
||||
jassub: 1.5.12
|
||||
js-levenshtein: 1.1.6
|
||||
matroska-subtitles: github.com/ThaUnknown/matroska-subtitles/c227b6a679f9bf4243a5e65220e81b72c893a37a
|
||||
matroska-subtitles: github.com/ThaUnknown/matroska-subtitles/6241556509536ff09ba2ea3f050ceb7a3f12190a
|
||||
mime: 3.0.0
|
||||
p2pcf: github.com/ThaUnknown/p2pcf/faefe2854c817315530636a58d07726de7050561
|
||||
perfect-seekbar: 1.1.0
|
||||
|
|
@ -3254,8 +3254,8 @@ packages:
|
|||
version: 2.0.5
|
||||
dev: false
|
||||
|
||||
github.com/ThaUnknown/matroska-subtitles/c227b6a679f9bf4243a5e65220e81b72c893a37a:
|
||||
resolution: {tarball: https://codeload.github.com/ThaUnknown/matroska-subtitles/tar.gz/c227b6a679f9bf4243a5e65220e81b72c893a37a}
|
||||
github.com/ThaUnknown/matroska-subtitles/6241556509536ff09ba2ea3f050ceb7a3f12190a:
|
||||
resolution: {tarball: https://codeload.github.com/ThaUnknown/matroska-subtitles/tar.gz/6241556509536ff09ba2ea3f050ceb7a3f12190a}
|
||||
name: matroska-subtitles
|
||||
version: 3.3.2
|
||||
dependencies:
|
||||
|
|
|
|||
|
|
@ -677,6 +677,30 @@
|
|||
if (time < (chapter.end / 1000) && time >= (chapter.start / 1000)) return chapter
|
||||
}
|
||||
}
|
||||
|
||||
// remaps chapters to what perfect-seekbar uses and adds potentially missing chapters
|
||||
function sanitiseChapters (chapters, safeduration) {
|
||||
const sanitised = []
|
||||
let sum = 0
|
||||
for (const { start, end, text } of chapters) {
|
||||
if (!sanitised.length && start !== 0) {
|
||||
const size = start / 10 / safeduration
|
||||
sum += size
|
||||
sanitised.push({ size })
|
||||
}
|
||||
const size = (end / 10 / safeduration) - (start / 10 / safeduration)
|
||||
sum += size
|
||||
sanitised.push({
|
||||
size,
|
||||
text
|
||||
})
|
||||
}
|
||||
if (sum !== 100) {
|
||||
sanitised.push({ size: 100 - sum })
|
||||
}
|
||||
return sanitised
|
||||
}
|
||||
|
||||
const thumbCanvas = document.createElement('canvas')
|
||||
thumbCanvas.width = 200
|
||||
const thumbnailData = {
|
||||
|
|
@ -943,10 +967,7 @@
|
|||
bind:progress={progress}
|
||||
on:seeking={handleMouseDown}
|
||||
on:seeked={handleMouseUp}
|
||||
chapters={chapters.map(({ start, end, text }) => ({
|
||||
size: (end / 10 / safeduration) - (start / 10 / safeduration),
|
||||
text
|
||||
}))}
|
||||
chapters={sanitiseChapters(chapters, safeduration)}
|
||||
{getThumbnail}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue