Skip to content

Commit

Permalink
fix(route): yuque video (DIYgod#12057)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Mar 7, 2023
1 parent c8f06fe commit 62da7bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/v2/yuque/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ');
Expand Down
4 changes: 4 additions & 0 deletions lib/v2/yuque/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down

0 comments on commit 62da7bf

Please sign in to comment.