Compare commits

...

3 Commits

Author SHA1 Message Date
720640b054 ascii option 2024-01-30 10:22:56 +00:00
1d818bd719 fix 2024-01-30 09:58:07 +00:00
1c38cfc79c flatten debug 2024-01-30 09:48:34 +00:00
2 changed files with 14 additions and 5 deletions

View File

@ -21,7 +21,7 @@ export async function cachedVRCYoutubeSearch(pool, queryOrContinuation, options)
async function VRCYoutubeSearch(pool, query, options = {}) { async function VRCYoutubeSearch(pool, query, options = {}) {
console.debug("search:", query); console.debug("search:", JSON.stringify(query));
var data = {results: []}; var data = {results: []};
var {videos, continuationData} = typeof query == "object" ? await continueYouTubeVideoSearch(query) : await searchYouTubeVideos(query); var {videos, continuationData} = typeof query == "object" ? await continueYouTubeVideoSearch(query) : await searchYouTubeVideos(query);
@ -38,9 +38,13 @@ async function VRCYoutubeSearch(pool, query, options = {}) {
iconUrls = [...iconUrls]; iconUrls = [...iconUrls];
} }
if (thumbnailUrls || iconUrls) { if (thumbnailUrls?.length || iconUrls?.length) {
try {
var {vrcurl: imagesheet_vrcurl, thumbnails, icons} = await makeImageSheetVrcUrl(pool, thumbnailUrls, iconUrls); var {vrcurl: imagesheet_vrcurl, thumbnails, icons} = await makeImageSheetVrcUrl(pool, thumbnailUrls, iconUrls);
data.imagesheet_vrcurl = imagesheet_vrcurl; data.imagesheet_vrcurl = imagesheet_vrcurl;
} catch (error) {
console.error(error.stack);
}
} }
for (let video of videos) { for (let video of videos) {

7
app.js
View File

@ -26,10 +26,15 @@ router.get("/search", async ctx => {
var options = { var options = {
thumbnails: stringToBoolean(ctx.query.thumbnails), thumbnails: stringToBoolean(ctx.query.thumbnails),
icons: stringToBoolean(ctx.query.icons) icons: stringToBoolean(ctx.query.icons),
ascii: stringToBoolean(ctx.query.ascii)
}; };
ctx.body = await cachedVRCYoutubeSearch(ctx.query.pool, query, options); ctx.body = await cachedVRCYoutubeSearch(ctx.query.pool, query, options);
if (options.ascii) {
ctx.body = JSON.stringify(ctx.body).replace(/[\u007F-\uFFFF]/g, chr => "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).slice(-4));
}
}); });