Compare commits

..

3 Commits

Author SHA1 Message Date
1c288ee4dc cache imagesheet 1 min 2024-07-06 11:20:21 -07:00
d7d914c9ca log failed image url 2024-07-06 11:18:02 -07:00
fb14df1ad3 help debug occasional caption error
also caption cache time changed from 6hr to 10min
2024-07-06 11:15:03 -07:00
2 changed files with 12 additions and 4 deletions

View File

@ -32,7 +32,12 @@ async function createImageSheet(images /*[{width, height, url}]*/, legacyMode) {
await Promise.all(images.map(({x, y, w, h, url}) => (async function(){
if (!url) return;
var image = await loadImage(url);
try {
var image = await loadImage(url);
} catch (error) {
console.error("failed to load image", url, error.message);
return;
}
ctx.drawImage(image, x, y, w, h);
})().catch(error => console.error("imageload", error.stack))));
@ -50,7 +55,7 @@ export async function makeImageSheetVrcUrl(pool, images, legacyMode) {
promise.then(() => {
setTimeout(() => {
if (store[key] === promise) delete store[key];
}, 1000*60*10); // 10 mins;
}, 1000*60); // 1 min;
});
promise.catch(error => {
console.error(error.stack);

View File

@ -21,13 +21,16 @@ async function getVideoCaptions(videoId) {
captionTracks = await Promise.all(captionTracks.map(captionTrack => (async () => {
var xml = await gotw(captionTrack.baseUrl, {resolveBodyOnly: true});
var parsed = xmlParser.parse(xml);
if (!parsed.transcript || !parsed.transcript.text) {
console.error("caption missing lines", parsed, xml);
}
var lines = parsed.transcript.text.map(({ "#text": text, "@_start": start, "@_dur": dur }) => ({ start: Number(start), dur: Number(dur), text }));
return {
name: captionTrack.name.simpleText,
id: captionTrack.vssId,
lines
};
})().catch(error => console.error(error.stack))));
})().catch(error => console.error("getVideoCaptions", error.stack))));
return captionTracks;
}
@ -38,7 +41,7 @@ export async function getVideoCaptionsCached(videoId) {
cache[videoId] = getVideoCaptions(videoId);
setTimeout(() => {
delete cache[videoId];
}, 1000*60*60*6); // 6 hours
}, 1000*60*10); // 10 minutes
}
return await cache[videoId];
}