fix(route): yuque video (#12057)
This commit is contained in:
@@ -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(', ');
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user