Update general.ts

This commit is contained in:
Acid Chicken (硫酸鶏) 2018-08-17 01:23:44 +09:00 committed by GitHub
parent 0c411d9a40
commit a72af04005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { name, version } from '../package.json';
import * as URL from 'url';
import * as request from 'request';
import nullOrEmpty from './utils/null-or-empty';
@ -8,6 +9,9 @@ import { AllHtmlEntities } from 'html-entities';
const entities = new AllHtmlEntities();
import * as client from 'cheerio-httpcli';
client.set('headers', {
'User-Agent': `${name}/${version}`
});
client.set('referer', false);
client.set('timeout', 10000);
client.set('maxDataSize', 1024 * 1024);
@ -50,7 +54,7 @@ export default async (url: URL.Url): Promise<Summary> => {
image = image ? URL.resolve(url.href, image) : null;
const player =
const playerUrl =
$('meta[property="twitter:player"]').attr('content') ||
$('meta[name="twitter:player"]').attr('content');
@ -131,7 +135,11 @@ export default async (url: URL.Url): Promise<Summary> => {
icon: icon || null,
description: description || null,
thumbnail: image || null,
player: player || null,
player: {
url: playerUrl || null,
width: playerWidth || null,
height: playerHeight || null
},
sitename: siteName || null
};
};