Compare commits

..

No commits in common. "1c288ee4dc9ca6da3e474cd38e7e4c83383e8bca" and "7a32e5792e5655c417e51bf053836de6e40c3dbf" have entirely different histories.

2 changed files with 4 additions and 12 deletions

View File

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

View File

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