Fix #31: List all occurrences of search within video captions

This commit is contained in:
2023-02-14 02:56:11 +01:00
parent 8d34cf33ae
commit e166fdb4e5
2 changed files with 21 additions and 16 deletions

View File

@@ -42,10 +42,10 @@ Progress: <span id="progress"></span> channels
document.getElementById('progress').innerHTML = line.replace('progress:', '');
} else {
var channelsDom = document.getElementById('channels');
var timestamp = null;
if (line.includes('|')) {
const lineParts = line.split('|');
timestamp = parseInt(lineParts[1]);
var timestamp = [];
const lineParts = line.split('|');
if (lineParts.length > 0) {
timestamps = lineParts.slice(1).map(linePart => parseInt(linePart));
line = lineParts[0];
}
const channelFileParts = line.split('/');
@@ -66,10 +66,11 @@ Progress: <span id="progress"></span> channels
var channelFileDom = document.createElement('li');
var a = createA(channelFile, `${channelHref}/${channelFile}`);
channelFileDom.appendChild(a);
if (timestamp != null) {
const id = channelFileParts[2];
for(var timestampsIndex = 0; timestampsIndex < timestamps.length; timestampsIndex++) {
const space = document.createTextNode('\u00A0');
channelFileDom.appendChild(space);
const id = channelFileParts[2];
const timestamp = timestamps[timestampsIndex];
var a = createA(`${timestamp} s`, `https://www.youtube.com/watch?v=${id}&t=${timestamp}`);
channelFileDom.appendChild(a);
}