mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-22 05:57:19 +09:00
28 lines
549 B
TypeScript
28 lines
549 B
TypeScript
import * as URL from 'url';
|
|
const pug = require('pug');
|
|
import Options from '../../options';
|
|
|
|
exports.test = (url: URL.Url) =>
|
|
url.hostname == 'youtube.com' ||
|
|
url.hostname == 'www.youtube.com' ||
|
|
url.hostname == 'youtu.be'
|
|
;
|
|
|
|
exports.compile = async (url: URL.Url, opts: Options) => {
|
|
let videoId: string;
|
|
|
|
switch (url.hostname) {
|
|
case 'www.youtube.com':
|
|
case 'youtube.com':
|
|
videoId = url.query.v;
|
|
break;
|
|
case 'youtu.be':
|
|
videoId = url.pathname;
|
|
break;
|
|
}
|
|
|
|
return pug.renderFile(`${__dirname}/view.pug`, {
|
|
videoId
|
|
});
|
|
};
|