本文整理汇总了TypeScript中cli-color.bold.red方法的典型用法代码示例。如果您正苦于以下问题:TypeScript bold.red方法的具体用法?TypeScript bold.red怎么用?TypeScript bold.red使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cli-color.bold
的用法示例。
在下文中一共展示了bold.red方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
const
conn = require(rootDir + 'connections/' + process.env.DB_TYPE + '.js');
// model = require(rootDir + 'models/' + process.env.DB_TYPE + '/Videos.js');
conn.hlen('videos', (err, videos_count) => {
if (err) {
console.log(err);
}
let videoId = 'video' + Number(videos_count + 1);
// let title = body.title.replace(/"/g, '');
let title = body.title.replace(/(^[a-z]|\s[a-z])/g, (p) => {
return p.toUpperCase();
});
let videoUri = yt_id;
let thumb = body.thumbnail_url;
let order = String(videos_count + 1);
// Redis no acepta objetos JSON aun... ¬_¬
// let video_string = '{ "videoId": "' + videoId + '",' +
// '"title": "' + title + '",' +
// '"url": "' + yt_id + '",' +
// '"img": "' + body.thumbnail_url + '",' +
// '"order": ' + String(videos_count + 1) + '}';
let video_string = `{"videoId":"${videoId}","videoInfo":{"videoId":"${videoId}","title":"${title}","url":"${videoUri}","img":"${thumb}"},"order":${order}}`;
conn.hmset('videos', String(videoId), video_string, (err) => {
conn.hget('videos', videoId, (err, video) => {
if (err) {
console.log(err);
} else {
let vid = JSON.parse(video);
console.log(
colors.green.bold(' [OK] Video inserted into Lantube DB!') + '\n' +
colors.green.bold(' Details: ') + '\n' +
colors.green.bold(' videoId: ') + vid.videoId + '\n' +
colors.green.bold(' title: ') + vid.title + '\n' +
colors.green.bold(' url: ') + vid.url + '\n' +
colors.green.bold(' img: ') + vid.img + '\n' +
colors.green.bold(' order: ') + (vid.order + 1)
);
}
});
});
});
} else {
console.log(colors.bold.yellow('│ ') + colors.bold.red(error)) + colors.bold.yellow('│');
console.log(colors.bold.yellow('╰────────────────────────────────────────────────────╯'));
}
});
示例2: require
console.log(colors.bold(' (Other Youtube URL formats should work)\n'));
console.log(colors.bold.yellow('╰────────────────────────────────────────────────────╯'));
process.exit();
}
// Passed video
let v = {
url: process.argv[2].toString()
};
// Extract Youtube video ID
var yt_id = v.url.trim().replace(/http(s?):\/\/(w{3}?)(\.?)youtube\.com\/watch\?v=/, '');
// Check ID
if (yt_id.length !== 11) {
console.log(colors.bold.red('│ ' + 'Invalid Youtube ID.') + colors.bold.yellow(' │'));
console.log(colors.bold.yellow('╰────────────────────────────────────────────────────╯'));
process.exit();
} else {
const
request = require('request');
request({
url: 'http://www.youtube.com/oembed?url=' + v.url + '&format=json',
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
const