fix(route): yuque video (#12057)

This commit is contained in:
Tony
2023-03-07 22:18:12 +08:00
committed by GitHub
parent c8f06fe493
commit 62da7bf91c
2 changed files with 18 additions and 0 deletions
+14
View File
@@ -60,6 +60,20 @@ module.exports = async (ctx) => {
elem.remove();
}
});
// obtain real video src
for await (const v of $('video').toArray()) {
const $v = $(v);
const src = $v.attr('src');
if (src.startsWith('inputs')) {
const { data } = await got(`${baseUrl}/api/video`, {
searchParams: {
video_id: src,
},
});
const { info } = data.data;
$v.replaceWith(`<video controls preload='none' poster='${info.cover}'><source src='${info.url}' type='video/mp4'></video>`);
}
}
item.description = $.html();
item.author = data.contributors.map((c) => c.name).join(', ');
+4
View File
@@ -35,6 +35,10 @@ const card2Html = (elem, link) => {
case 'table':
html = value.html;
break;
case 'video':
// fake video src
html = `<video src='${value.videoId}'></video>`;
break;
default:
throw Error(`Unhandled card on ${link}: ${name}`);
}