mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-11 00:27:35 +09:00
Add debug
This commit is contained in:
parent
5e3321c03c
commit
f491e40784
@ -13,6 +13,7 @@
|
|||||||
"build": "gulp build"
|
"build": "gulp build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/debug": "0.0.29",
|
||||||
"@types/node": "7.0.4",
|
"@types/node": "7.0.4",
|
||||||
"@types/request": "0.0.39",
|
"@types/request": "0.0.39",
|
||||||
"event-stream": "3.3.4",
|
"event-stream": "3.3.4",
|
||||||
@ -22,6 +23,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio-httpcli": "0.6.10",
|
"cheerio-httpcli": "0.6.10",
|
||||||
|
"debug": "2.6.0",
|
||||||
"escape-regexp": "0.0.1",
|
"escape-regexp": "0.0.1",
|
||||||
"html-entities": "1.2.0",
|
"html-entities": "1.2.0",
|
||||||
"request": "2.79.0",
|
"request": "2.79.0",
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import * as URL from 'url';
|
import * as URL from 'url';
|
||||||
import * as request from 'request';
|
import * as request from 'request';
|
||||||
|
import * as debug from 'debug';
|
||||||
|
|
||||||
|
const log = debug('summaly:plugins:wikipedia');
|
||||||
|
|
||||||
exports.test = (url: URL.Url) =>
|
exports.test = (url: URL.Url) =>
|
||||||
/\.wikipedia\.org$/.test(url.hostname);
|
/\.wikipedia\.org$/.test(url.hostname);
|
||||||
@ -9,7 +12,12 @@ exports.summary = (url: URL.Url) => new Promise((res, rej) => {
|
|||||||
const title = url.pathname.split('/')[2];
|
const title = url.pathname.split('/')[2];
|
||||||
const endpoint = `https://${lang}.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=${title}`;
|
const endpoint = `https://${lang}.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=${title}`;
|
||||||
|
|
||||||
|
log(`lang is ${lang}`);
|
||||||
|
log(`title is ${title}`);
|
||||||
|
log(`endpoint is ${endpoint}`);
|
||||||
|
|
||||||
request(endpoint, (err, _, body) => {
|
request(endpoint, (err, _, body) => {
|
||||||
|
log(body);
|
||||||
body = JSON.parse(body);
|
body = JSON.parse(body);
|
||||||
const info = body.query.pages[Object.keys(body.query.pages)[0]];
|
const info = body.query.pages[Object.keys(body.query.pages)[0]];
|
||||||
res({
|
res({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user