Compare commits
3 Commits
7a32e5792e
...
1c288ee4dc
Author | SHA1 | Date | |
---|---|---|---|
1c288ee4dc | |||
d7d914c9ca | |||
fb14df1ad3 |
@ -32,7 +32,12 @@ 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;
|
||||||
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);
|
ctx.drawImage(image, x, y, w, h);
|
||||||
})().catch(error => console.error("imageload", error.stack))));
|
})().catch(error => console.error("imageload", error.stack))));
|
||||||
|
|
||||||
@ -50,7 +55,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*10); // 10 mins;
|
}, 1000*60); // 1 min;
|
||||||
});
|
});
|
||||||
promise.catch(error => {
|
promise.catch(error => {
|
||||||
console.error(error.stack);
|
console.error(error.stack);
|
||||||
|
@ -21,13 +21,16 @@ 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(error.stack))));
|
})().catch(error => console.error("getVideoCaptions", error.stack))));
|
||||||
return captionTracks;
|
return captionTracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +41,7 @@ export async function getVideoCaptionsCached(videoId) {
|
|||||||
cache[videoId] = getVideoCaptions(videoId);
|
cache[videoId] = getVideoCaptions(videoId);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
delete cache[videoId];
|
delete cache[videoId];
|
||||||
}, 1000*60*60*6); // 6 hours
|
}, 1000*60*10); // 10 minutes
|
||||||
}
|
}
|
||||||
return await cache[videoId];
|
return await cache[videoId];
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user