feat: replace require with import 7/n
This commit is contained in:
parent
3d33ab1f72
commit
44c9853541
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const url = require('url');
|
||||
import * as url from 'node:url';
|
||||
|
||||
export default async (ctx) => {
|
||||
const id = ctx.req.param('id') || -1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDyArticle } from './utils';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const rootUrl = 'https://news.163.com';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import got from '@/utils/got';
|
|||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { isValidHost } from '@/utils/valid-host';
|
||||
|
||||
const setCookie = function (cookieName, cookieValue, seconds, path, domain, secure) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import got from '@/utils/got';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const bbcode = require('bbcodejs');
|
||||
import bbcode from 'bbcodejs';
|
||||
|
||||
const rootUrl = 'https://instant.1point3acres.com';
|
||||
const apiRootUrl = 'https://api.1point3acres.com';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import got from '@/utils/got';
|
|||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
// http://www.2cycd.com/forum.php?mod=forumdisplay&fid=43&orderby=dateline
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const CryptoJS = require('crypto-js');
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
const rootUrl = 'https://www.36kr.com';
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import timezone from '@/utils/timezone';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
export default async (ctx) => {
|
||||
const id = ctx.req.param('id') ?? '2-1';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
|
||||
import * as path from 'node:path';
|
||||
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
import { CookieJar } from 'tough-cookie';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
import got from '@/utils/got';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import cache from '@/utils/cache';
|
||||
import { load } from 'cheerio';
|
||||
const zlib = require('zlib');
|
||||
import zlib from 'zlib';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const crypto = require('crypto');
|
||||
const CryptoJS = require('crypto-js');
|
||||
const { KJUR, KEYUTIL, hextob64 } = require('jsrsasign');
|
||||
import crypto from 'crypto';
|
||||
import CryptoJS from 'crypto-js';
|
||||
import { KJUR, KEYUTIL, hextob64 } from 'jsrsasign';
|
||||
|
||||
const publicKey =
|
||||
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCARnxLlrhTK28bEV7s2IROjT73KLSjfqpKIvV8L+Yhe4BrF0Ut4oOH728HZlbSF0C3N0vXZjLAFesoS4v1pYOjVCPXl920Lh2seCv82m0cK78WMGuqZTfA44Nv7JsQMHC3+J6IZm8YD53ft2d8mYBFgKektduucjx8sObe7eRyoQIDAQAB';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import got from '@/utils/got';
|
|||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import got from '@/utils/got';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const MarkdownIt = require('markdown-it');
|
||||
import MarkdownIt from 'markdown-it';
|
||||
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import got from '@/utils/got';
|
||||
const url = require('url');
|
||||
import * as url from 'node:url';
|
||||
import { load } from 'cheerio';
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import got from '@/utils/got';
|
||||
const currency = require('currency-symbol-map');
|
||||
import currency from 'currency-symbol-map';
|
||||
export default async (ctx) => {
|
||||
const country = ctx.req.param('country');
|
||||
const type = ctx.req.param('type').toLowerCase() === 'mac' ? 'macapps' : 'apps';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date';
|
|||
import timezone from '@/utils/timezone';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
import { config } from '@/config';
|
||||
|
||||
// Visit https://www.bdys.me for the list of domains
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import cache from './cache';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
export default async (ctx) => {
|
||||
const uid = ctx.req.param('uid');
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.bilibili.com/x/space/article?mid=${uid}&pn=1&ps=10&sort=publish_time&jsonp=jsonp`,
|
||||
|
|
@ -18,7 +18,7 @@ export default async (ctx) => {
|
|||
const description = `${name} 的 bilibili 专栏`;
|
||||
const item = await Promise.all(
|
||||
data.articles.map(async (item) => {
|
||||
const { url: art_url, description: eDescription } = await cache.getArticleDataFromCvid(ctx, item.id, uid);
|
||||
const { url: art_url, description: eDescription } = await cache.getArticleDataFromCvid(item.id, uid);
|
||||
const publishDate = parseDate(item.publish_time * 1000);
|
||||
const single = {
|
||||
title: item.title,
|
||||
|
|
|
|||
|
|
@ -5,253 +5,273 @@ import { load } from 'cheerio';
|
|||
import { config } from '@/config';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default {
|
||||
getCookie: () => {
|
||||
if (Object.keys(config.bilibili.cookies).length > 0) {
|
||||
return config.bilibili.cookies[Object.keys(config.bilibili.cookies)[Math.floor(Math.random() * Object.keys(config.bilibili.cookies).length)]];
|
||||
}
|
||||
const key = 'bili-cookie';
|
||||
return cache.tryGet(key, async () => {
|
||||
// default Referer: https://www.bilibili.com is limited
|
||||
// Bilibili return cookies with multiple set-cookie
|
||||
// let response = await got('https://space.bilibili.com/1');
|
||||
// const setCookie = response.headers['set-cookie']; // should contain buvid3 and b_nut
|
||||
// if (typeof setCookie === 'undefined') {
|
||||
// return '';
|
||||
// }
|
||||
// const cookie = setCookie.map((cookie) => cookie.split(';')[0]);
|
||||
const cookie = [];
|
||||
cookie.push(['b_lsid', utils.lsid()].join('='), ['_uuid', utils._uuid()].join('='), ['b_nut', Date.now().toString()].join('='));
|
||||
let response = await got('https://api.bilibili.com/x/frontend/finger/spi', {
|
||||
const getCookie = () => {
|
||||
if (Object.keys(config.bilibili.cookies).length > 0) {
|
||||
return config.bilibili.cookies[Object.keys(config.bilibili.cookies)[Math.floor(Math.random() * Object.keys(config.bilibili.cookies).length)]];
|
||||
}
|
||||
const key = 'bili-cookie';
|
||||
return cache.tryGet(key, async () => {
|
||||
// default Referer: https://www.bilibili.com is limited
|
||||
// Bilibili return cookies with multiple set-cookie
|
||||
// let response = await got('https://space.bilibili.com/1');
|
||||
// const setCookie = response.headers['set-cookie']; // should contain buvid3 and b_nut
|
||||
// if (typeof setCookie === 'undefined') {
|
||||
// return '';
|
||||
// }
|
||||
// const cookie = setCookie.map((cookie) => cookie.split(';')[0]);
|
||||
const cookie = [];
|
||||
cookie.push(['b_lsid', utils.lsid()].join('='), ['_uuid', utils._uuid()].join('='), ['b_nut', Date.now().toString()].join('='));
|
||||
let response = await got('https://api.bilibili.com/x/frontend/finger/spi', {
|
||||
headers: {
|
||||
Referer: 'https://www.bilibili.com/',
|
||||
Cookie: cookie.join('; '),
|
||||
},
|
||||
});
|
||||
cookie.push(['buvid3', encodeURIComponent(response.data.data.b_3)].join('='), ['bvuid4', encodeURIComponent(response.data.data.b_4)].join('='));
|
||||
const e = Math.floor(Date.now() / 1000);
|
||||
const hexsign = utils.hexsign(e);
|
||||
// await got('https://space.bilibili.com/1', {
|
||||
// headers: {
|
||||
// Referer: 'https://www.bilibili.com/',
|
||||
// Cookie: cookie.join('; '),
|
||||
// },
|
||||
// });
|
||||
try {
|
||||
response = await got.post(`https://api.bilibili.com/bapis/bilibili.api.ticket.v1.Ticket/GenWebTicket?key_id=ec02&hexsign=${hexsign}&context[ts]=${e}&csrf=`, {
|
||||
headers: {
|
||||
Referer: 'https://www.bilibili.com/',
|
||||
Referer: 'https://space.bilibili.com/1',
|
||||
Cookie: cookie.join('; '),
|
||||
},
|
||||
});
|
||||
cookie.push(['buvid3', encodeURIComponent(response.data.data.b_3)].join('='), ['bvuid4', encodeURIComponent(response.data.data.b_4)].join('='));
|
||||
const e = Math.floor(Date.now() / 1000);
|
||||
const hexsign = utils.hexsign(e);
|
||||
// await got('https://space.bilibili.com/1', {
|
||||
// headers: {
|
||||
// Referer: 'https://www.bilibili.com/',
|
||||
// Cookie: cookie.join('; '),
|
||||
// },
|
||||
// });
|
||||
try {
|
||||
response = await got.post(`https://api.bilibili.com/bapis/bilibili.api.ticket.v1.Ticket/GenWebTicket?key_id=ec02&hexsign=${hexsign}&context[ts]=${e}&csrf=`, {
|
||||
cookie.push(['bili_ticket', response.data.data.ticket].join('='), ['bili_ticket_expires', (Number.parseInt(response.data.data.created_at) + Number.parseInt(response.data.data.ttl)).toString()].join('='));
|
||||
} catch {
|
||||
// HTTPError: Response code 429 (Too Many Requests)
|
||||
}
|
||||
|
||||
return cookie.join('; ');
|
||||
});
|
||||
};
|
||||
|
||||
const getWbiVerifyString = () => {
|
||||
const key = 'bili-wbi-verify-string';
|
||||
return cache.tryGet(key, async () => {
|
||||
const cookie = await getCookie();
|
||||
const { data: navResponse } = await got('https://api.bilibili.com/x/web-interface/nav', {
|
||||
headers: {
|
||||
Referer: 'https://www.bilibili.com/',
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const imgUrl = navResponse.data.wbi_img.img_url;
|
||||
const subUrl = navResponse.data.wbi_img.sub_url;
|
||||
const r = imgUrl.substring(imgUrl.lastIndexOf('/') + 1, imgUrl.length).split('.')[0] + subUrl.substring(subUrl.lastIndexOf('/') + 1, subUrl.length).split('.')[0];
|
||||
// const { body: spaceResponse } = await got('https://space.bilibili.com/1', {
|
||||
// headers: {
|
||||
// Referer: 'https://www.bilibili.com/',
|
||||
// Cookie: cookie,
|
||||
// },
|
||||
// });
|
||||
// const jsUrl = 'https:' + spaceResponse.match(/[^"]*9.space[^"]*/);
|
||||
const jsUrl = 'https://s1.hdslb.com/bfs/seed/laputa-header/bili-header.umd.js';
|
||||
const { body: jsResponse } = await got(jsUrl, {
|
||||
headers: {
|
||||
Referer: 'https://space.bilibili.com/1',
|
||||
},
|
||||
});
|
||||
// const array = [
|
||||
// 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57,
|
||||
// 62, 11, 36, 20, 34, 44, 52,
|
||||
// ];
|
||||
const array = JSON.parse(jsResponse.match(/\[(?:\d+,){63}\d+]/));
|
||||
const o = [];
|
||||
for (const t of array) {
|
||||
r.charAt(t) && o.push(r.charAt(t));
|
||||
}
|
||||
return o.join('').slice(0, 32);
|
||||
});
|
||||
};
|
||||
|
||||
const getUsernameFromUID = (uid) => {
|
||||
const key = 'bili-username-from-uid-' + uid;
|
||||
return cache.tryGet(key, async () => {
|
||||
const cookie = await getCookie();
|
||||
const wbiVerifyString = await getWbiVerifyString();
|
||||
// await got(`https://space.bilibili.com/${uid}/`, {
|
||||
// headers: {
|
||||
// Referer: 'https://www.bilibili.com/',
|
||||
// Cookie: cookie,
|
||||
// },
|
||||
// });
|
||||
const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString);
|
||||
const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, {
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
return nameResponse.data ? nameResponse.data.name : undefined;
|
||||
});
|
||||
};
|
||||
|
||||
const getUsernameAndFaceFromUID = async (uid) => {
|
||||
const nameKey = 'bili-username-from-uid-' + uid;
|
||||
const faceKey = 'bili-userface-from-uid-' + uid;
|
||||
let name = await cache.get(nameKey);
|
||||
let face = await cache.get(faceKey);
|
||||
if (!name || !face) {
|
||||
const cookie = await getCookie();
|
||||
const wbiVerifyString = await getWbiVerifyString();
|
||||
// await got(`https://space.bilibili.com/${uid}/`, {
|
||||
// headers: {
|
||||
// Referer: `https://www.bilibili.com/`,
|
||||
// Cookie: cookie,
|
||||
// },
|
||||
// });
|
||||
const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString);
|
||||
const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, {
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
if (nameResponse.data.name) {
|
||||
name = nameResponse.data.name;
|
||||
face = nameResponse.data.face;
|
||||
} else {
|
||||
logger.error(`Error when visiting /x/space/wbi/acc/info: ${JSON.stringify(nameResponse)}`);
|
||||
}
|
||||
cache.set(nameKey, name);
|
||||
cache.set(faceKey, face);
|
||||
}
|
||||
return [name, face];
|
||||
};
|
||||
|
||||
const getLiveIDFromShortID = (shortID) => {
|
||||
const key = `bili-liveID-from-shortID-${shortID}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data: liveIDResponse } = await got(`https://api.live.bilibili.com/room/v1/Room/room_init?id=${shortID}`, {
|
||||
headers: {
|
||||
Referer: `https://live.bilibili.com/${shortID}`,
|
||||
},
|
||||
});
|
||||
return liveIDResponse.data.room_id;
|
||||
});
|
||||
};
|
||||
|
||||
const getUsernameFromLiveID = (liveID) => {
|
||||
const key = `bili-username-from-liveID-${liveID}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data: nameResponse } = await got(`https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${liveID}`, {
|
||||
headers: {
|
||||
Referer: `https://live.bilibili.com/${liveID}`,
|
||||
},
|
||||
});
|
||||
return nameResponse.data.info.uname;
|
||||
});
|
||||
};
|
||||
|
||||
const getVideoNameFromId = (aid, bvid) => {
|
||||
const key = `bili-videoname-from-id-${bvid || aid}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data } = await got(`https://api.bilibili.com/x/web-interface/view`, {
|
||||
searchParams: {
|
||||
aid: aid || undefined,
|
||||
bvid: bvid || undefined,
|
||||
},
|
||||
referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`,
|
||||
});
|
||||
return data.data.title;
|
||||
});
|
||||
};
|
||||
|
||||
const getCidFromId = (aid, pid, bvid) => {
|
||||
const key = `bili-cid-from-id-${bvid || aid}-${pid}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data } = await got(`https://api.bilibili.com/x/web-interface/view?${bvid ? `bvid=${bvid}` : `aid=${aid}`}`, {
|
||||
referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`,
|
||||
});
|
||||
return data.data.pages[pid - 1].cid;
|
||||
});
|
||||
};
|
||||
|
||||
const getAidFromBvid = async (bvid) => {
|
||||
const key = `bili-cid-from-bvid-${bvid}`;
|
||||
let aid = await cache.get(key);
|
||||
if (!aid) {
|
||||
const response = await got(`https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`, {
|
||||
headers: {
|
||||
Referer: `https://www.bilibili.com/video/${bvid}`,
|
||||
},
|
||||
});
|
||||
if (response.data && response.data.data && response.data.data.aid) {
|
||||
aid = response.data.data.aid;
|
||||
}
|
||||
cache.set(key, aid);
|
||||
}
|
||||
return aid;
|
||||
};
|
||||
|
||||
const getArticleDataFromCvid = async (cvid, uid) => {
|
||||
const url = `https://www.bilibili.com/read/cv${cvid}/`;
|
||||
const data = await cache.tryGet(
|
||||
url,
|
||||
async () =>
|
||||
(
|
||||
await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: 'https://space.bilibili.com/1',
|
||||
Cookie: cookie.join('; '),
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
},
|
||||
});
|
||||
cookie.push(['bili_ticket', response.data.data.ticket].join('='), ['bili_ticket_expires', (Number.parseInt(response.data.data.created_at) + Number.parseInt(response.data.data.ttl)).toString()].join('='));
|
||||
} catch {
|
||||
// HTTPError: Response code 429 (Too Many Requests)
|
||||
}
|
||||
})
|
||||
).data
|
||||
);
|
||||
const $ = load(data);
|
||||
let description = $('#read-article-holder').html();
|
||||
if (!description) {
|
||||
try {
|
||||
const newFormatData = JSON.parse(
|
||||
$('script:contains("window.__INITIAL_STATE__")')
|
||||
.text()
|
||||
.match(/window\.__INITIAL_STATE__\s*=\s*(.*?);\(/)[1]
|
||||
);
|
||||
|
||||
return cookie.join('; ');
|
||||
});
|
||||
},
|
||||
getWbiVerifyString: (ctx) => {
|
||||
const key = 'bili-wbi-verify-string';
|
||||
return cache.tryGet(key, async () => {
|
||||
const cookie = await module.exports.getCookie(ctx);
|
||||
const { data: navResponse } = await got('https://api.bilibili.com/x/web-interface/nav', {
|
||||
headers: {
|
||||
Referer: 'https://www.bilibili.com/',
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
const imgUrl = navResponse.data.wbi_img.img_url;
|
||||
const subUrl = navResponse.data.wbi_img.sub_url;
|
||||
const r = imgUrl.substring(imgUrl.lastIndexOf('/') + 1, imgUrl.length).split('.')[0] + subUrl.substring(subUrl.lastIndexOf('/') + 1, subUrl.length).split('.')[0];
|
||||
// const { body: spaceResponse } = await got('https://space.bilibili.com/1', {
|
||||
// headers: {
|
||||
// Referer: 'https://www.bilibili.com/',
|
||||
// Cookie: cookie,
|
||||
// },
|
||||
// });
|
||||
// const jsUrl = 'https:' + spaceResponse.match(/[^"]*9.space[^"]*/);
|
||||
const jsUrl = 'https://s1.hdslb.com/bfs/seed/laputa-header/bili-header.umd.js';
|
||||
const { body: jsResponse } = await got(jsUrl, {
|
||||
headers: {
|
||||
Referer: 'https://space.bilibili.com/1',
|
||||
},
|
||||
});
|
||||
// const array = [
|
||||
// 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57,
|
||||
// 62, 11, 36, 20, 34, 44, 52,
|
||||
// ];
|
||||
const array = JSON.parse(jsResponse.match(/\[(?:\d+,){63}\d+]/));
|
||||
const o = [];
|
||||
for (const t of array) {
|
||||
r.charAt(t) && o.push(r.charAt(t));
|
||||
}
|
||||
return o.join('').slice(0, 32);
|
||||
});
|
||||
},
|
||||
getUsernameFromUID: (ctx, uid) => {
|
||||
const key = 'bili-username-from-uid-' + uid;
|
||||
return cache.tryGet(key, async () => {
|
||||
const cookie = await module.exports.getCookie(ctx);
|
||||
const wbiVerifyString = await module.exports.getWbiVerifyString(ctx);
|
||||
// await got(`https://space.bilibili.com/${uid}/`, {
|
||||
// headers: {
|
||||
// Referer: 'https://www.bilibili.com/',
|
||||
// Cookie: cookie,
|
||||
// },
|
||||
// });
|
||||
const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString);
|
||||
const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, {
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
return nameResponse.data ? nameResponse.data.name : undefined;
|
||||
});
|
||||
},
|
||||
getUsernameAndFaceFromUID: async (ctx, uid) => {
|
||||
const nameKey = 'bili-username-from-uid-' + uid;
|
||||
const faceKey = 'bili-userface-from-uid-' + uid;
|
||||
let name = await cache.get(nameKey);
|
||||
let face = await cache.get(faceKey);
|
||||
if (!name || !face) {
|
||||
const cookie = await module.exports.getCookie(ctx);
|
||||
const wbiVerifyString = await module.exports.getWbiVerifyString(ctx);
|
||||
// await got(`https://space.bilibili.com/${uid}/`, {
|
||||
// headers: {
|
||||
// Referer: `https://www.bilibili.com/`,
|
||||
// Cookie: cookie,
|
||||
// },
|
||||
// });
|
||||
const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString);
|
||||
const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, {
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
Cookie: cookie,
|
||||
},
|
||||
});
|
||||
if (nameResponse.data.name) {
|
||||
name = nameResponse.data.name;
|
||||
face = nameResponse.data.face;
|
||||
} else {
|
||||
logger.error(`Error when visiting /x/space/wbi/acc/info: ${JSON.stringify(nameResponse)}`);
|
||||
}
|
||||
cache.set(nameKey, name);
|
||||
cache.set(faceKey, face);
|
||||
}
|
||||
return [name, face];
|
||||
},
|
||||
getLiveIDFromShortID: (ctx, shortID) => {
|
||||
const key = `bili-liveID-from-shortID-${shortID}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data: liveIDResponse } = await got(`https://api.live.bilibili.com/room/v1/Room/room_init?id=${shortID}`, {
|
||||
headers: {
|
||||
Referer: `https://live.bilibili.com/${shortID}`,
|
||||
},
|
||||
});
|
||||
return liveIDResponse.data.room_id;
|
||||
});
|
||||
},
|
||||
getUsernameFromLiveID: (ctx, liveID) => {
|
||||
const key = `bili-username-from-liveID-${liveID}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data: nameResponse } = await got(`https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${liveID}`, {
|
||||
headers: {
|
||||
Referer: `https://live.bilibili.com/${liveID}`,
|
||||
},
|
||||
});
|
||||
return nameResponse.data.info.uname;
|
||||
});
|
||||
},
|
||||
getVideoNameFromId: (ctx, aid, bvid) => {
|
||||
const key = `bili-videoname-from-id-${bvid || aid}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data } = await got(`https://api.bilibili.com/x/web-interface/view`, {
|
||||
searchParams: {
|
||||
aid: aid || undefined,
|
||||
bvid: bvid || undefined,
|
||||
},
|
||||
referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`,
|
||||
});
|
||||
return data.data.title;
|
||||
});
|
||||
},
|
||||
getCidFromId: (ctx, aid, pid, bvid) => {
|
||||
const key = `bili-cid-from-id-${bvid || aid}-${pid}`;
|
||||
return cache.tryGet(key, async () => {
|
||||
const { data } = await got(`https://api.bilibili.com/x/web-interface/view?${bvid ? `bvid=${bvid}` : `aid=${aid}`}`, {
|
||||
referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`,
|
||||
});
|
||||
return data.data.pages[pid - 1].cid;
|
||||
});
|
||||
},
|
||||
getAidFromBvid: async (ctx, bvid) => {
|
||||
const key = `bili-cid-from-bvid-${bvid}`;
|
||||
let aid = await cache.get(key);
|
||||
if (!aid) {
|
||||
const response = await got(`https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`, {
|
||||
headers: {
|
||||
Referer: `https://www.bilibili.com/video/${bvid}`,
|
||||
},
|
||||
});
|
||||
if (response.data && response.data.data && response.data.data.aid) {
|
||||
aid = response.data.data.aid;
|
||||
}
|
||||
cache.set(key, aid);
|
||||
}
|
||||
return aid;
|
||||
},
|
||||
getArticleDataFromCvid: async (ctx, cvid, uid) => {
|
||||
const url = `https://www.bilibili.com/read/cv${cvid}/`;
|
||||
const data = await cache.tryGet(
|
||||
url,
|
||||
async () =>
|
||||
(
|
||||
await got({
|
||||
method: 'get',
|
||||
url,
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
},
|
||||
})
|
||||
).data
|
||||
);
|
||||
const $ = load(data);
|
||||
let description = $('#read-article-holder').html();
|
||||
if (!description) {
|
||||
try {
|
||||
const newFormatData = JSON.parse(
|
||||
$('script:contains("window.__INITIAL_STATE__")')
|
||||
.text()
|
||||
.match(/window\.__INITIAL_STATE__\s*=\s*(.*?);\(/)[1]
|
||||
);
|
||||
|
||||
if (newFormatData?.readInfo?.opus?.content?.paragraphs) {
|
||||
description = '';
|
||||
for (const element of newFormatData.readInfo.opus.content.paragraphs) {
|
||||
if (element.para_type === 1) {
|
||||
for (const text of element.text.nodes) {
|
||||
if (text?.word?.words) {
|
||||
description += `<p>${text.word.words}</p>`;
|
||||
}
|
||||
if (newFormatData?.readInfo?.opus?.content?.paragraphs) {
|
||||
description = '';
|
||||
for (const element of newFormatData.readInfo.opus.content.paragraphs) {
|
||||
if (element.para_type === 1) {
|
||||
for (const text of element.text.nodes) {
|
||||
if (text?.word?.words) {
|
||||
description += `<p>${text.word.words}</p>`;
|
||||
}
|
||||
}
|
||||
if (element.para_type === 2) {
|
||||
for (const image of element.pic.pics) {
|
||||
description += `<p ><img src="${image.url}@progressive.webp"></p>`;
|
||||
}
|
||||
}
|
||||
if (element.para_type === 3 && element.line?.pic?.url) {
|
||||
description += `<figure><img src="${element.line.pic.url}"></figure>`;
|
||||
}
|
||||
}
|
||||
if (element.para_type === 2) {
|
||||
for (const image of element.pic.pics) {
|
||||
description += `<p ><img src="${image.url}@progressive.webp"></p>`;
|
||||
}
|
||||
}
|
||||
if (element.para_type === 3 && element.line?.pic?.url) {
|
||||
description += `<figure><img src="${element.line.pic.url}"></figure>`;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
return { url, description };
|
||||
},
|
||||
}
|
||||
return { url, description };
|
||||
};
|
||||
|
||||
export default {
|
||||
getCookie,
|
||||
getWbiVerifyString,
|
||||
getUsernameFromUID,
|
||||
getUsernameAndFaceFromUID,
|
||||
getLiveIDFromShortID,
|
||||
getUsernameFromLiveID,
|
||||
getVideoNameFromId,
|
||||
getCidFromId,
|
||||
getAidFromBvid,
|
||||
getArticleDataFromCvid,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export default async (ctx) => {
|
|||
const uid = ctx.req.param('uid');
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const response = await got({
|
||||
url: `https://api.bilibili.com/x/space/coin/video?vmid=${uid}`,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { load } from 'cheerio';
|
||||
import cache from './cache';
|
||||
import got from '@/utils/got';
|
||||
const zlib = require('zlib');
|
||||
import zlib from 'zlib';
|
||||
|
||||
const processFloatTime = (time) => {
|
||||
const totalSeconds = Number.parseInt(time);
|
||||
|
|
@ -20,9 +20,9 @@ export default async (ctx) => {
|
|||
}
|
||||
const pid = Number(ctx.req.param('pid') || 1);
|
||||
const limit = 50;
|
||||
const cid = await cache.getCidFromId(ctx, aid, pid, bvid);
|
||||
const cid = await cache.getCidFromId(aid, pid, bvid);
|
||||
|
||||
const videoName = await cache.getVideoNameFromId(ctx, aid, bvid);
|
||||
const videoName = await cache.getVideoNameFromId(aid, bvid);
|
||||
|
||||
const link = `https://www.bilibili.com/video/${bvid || `av${aid}`}`;
|
||||
const danmakuResponse = await got.get(`https://comment.bilibili.com/${cid}.xml`, {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
const JSONbig = require('json-bigint');
|
||||
import JSONbig from 'json-bigint';
|
||||
import utils from './utils';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { fallback, queryToBoolean } from '@/utils/readable-social';
|
||||
|
|
@ -86,7 +86,7 @@ export default async (ctx) => {
|
|||
});
|
||||
const cards = JSONbig.parse(response.body).data.cards;
|
||||
|
||||
const usernameAndFace = await cacheIn.getUsernameAndFaceFromUID(ctx, uid);
|
||||
const usernameAndFace = await cacheIn.getUsernameAndFaceFromUID(uid);
|
||||
const author = usernameAndFace[0] ?? cards[0]?.desc?.user_profile?.info.uname;
|
||||
const face = usernameAndFace[1] ?? cards[0]?.desc?.user_profile?.info?.face;
|
||||
cache.set(`bili-username-from-uid-${uid}`, author);
|
||||
|
|
@ -217,7 +217,7 @@ export default async (ctx) => {
|
|||
};
|
||||
|
||||
if (data.image_urls && displayArticle) {
|
||||
data_content = (await cacheIn.getArticleDataFromCvid(ctx, data.id, uid)).description;
|
||||
data_content = (await cacheIn.getArticleDataFromCvid(data.id, uid)).description;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default async (ctx) => {
|
|||
throw new Error('缺少对应 loginUid 的 Bilibili 用户登录后的 Cookie 值 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">bilibili 用户关注动态系列路由</a>');
|
||||
}
|
||||
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const countResponse = await got({
|
||||
method: 'get',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { config } from '@/config';
|
|||
|
||||
export default async (ctx) => {
|
||||
const uid = String(ctx.req.param('uid'));
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const cookie = config.bilibili.cookies[uid];
|
||||
if (cookie === undefined) {
|
||||
|
|
@ -27,7 +27,7 @@ export default async (ctx) => {
|
|||
const out = await Promise.all(
|
||||
cards.map(async (card) => {
|
||||
const card_data = JSON.parse(card.card);
|
||||
const { url: link, description } = await cache.getArticleDataFromCvid(ctx, card_data.id, uid);
|
||||
const { url: link, description } = await cache.getArticleDataFromCvid(card_data.id, uid);
|
||||
|
||||
const item = {
|
||||
title: card_data.title,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import got from '@/utils/got';
|
|||
import cache from './cache';
|
||||
import { config } from '@/config';
|
||||
import utils from './utils';
|
||||
const JSONbig = require('json-bigint');
|
||||
import JSONbig from 'json-bigint';
|
||||
import { fallback, queryToBoolean } from '@/utils/readable-social';
|
||||
const querystring = require('querystring');
|
||||
import querystring from 'querystring';
|
||||
|
||||
export default async (ctx) => {
|
||||
const uid = String(ctx.req.param('uid'));
|
||||
|
|
@ -14,7 +14,7 @@ export default async (ctx) => {
|
|||
const disableEmbed = fallback(undefined, queryToBoolean(routeParams.disableEmbed), false);
|
||||
const displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false);
|
||||
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const cookie = config.bilibili.cookies[uid];
|
||||
if (cookie === undefined) {
|
||||
|
|
@ -123,7 +123,7 @@ export default async (ctx) => {
|
|||
}
|
||||
|
||||
if (data.image_urls && displayArticle) {
|
||||
data_content = (await cache.getArticleDataFromCvid(ctx, data.id, uid)).description;
|
||||
data_content = (await cache.getArticleDataFromCvid(data.id, uid)).description;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import utils from './utils';
|
|||
export default async (ctx) => {
|
||||
const uid = String(ctx.req.param('uid'));
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const cookie = config.bilibili.cookies[uid];
|
||||
if (cookie === undefined) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default async (ctx) => {
|
|||
}
|
||||
|
||||
const uid = ctx.req.param('uid');
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const countResponse = await got({
|
||||
method: 'get',
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import cache from './cache';
|
|||
import utils from './utils';
|
||||
|
||||
export default async (ctx) => {
|
||||
const wbiVerifyString = await cache.getWbiVerifyString(ctx);
|
||||
const wbiVerifyString = await cache.getWbiVerifyString();
|
||||
const params = utils.addWbiVerifyInfo('limit=10&platform=web', wbiVerifyString);
|
||||
const url = `https://api.bilibili.com/x/web-interface/wbi/search/square?${params}`;
|
||||
const response = await got({
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export default async (ctx) => {
|
|||
const uid = ctx.req.param('uid');
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const response = await got({
|
||||
url: `https://api.bilibili.com/x/space/like/video?vmid=${uid}`,
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ export default async (ctx) => {
|
|||
|
||||
// 短号查询长号
|
||||
if (Number.parseInt(roomID, 10) < 10000) {
|
||||
roomID = await cache.getLiveIDFromShortID(ctx, roomID);
|
||||
roomID = await cache.getLiveIDFromShortID(roomID);
|
||||
}
|
||||
const name = await cache.getUsernameFromLiveID(ctx, roomID);
|
||||
const name = await cache.getUsernameFromLiveID(roomID);
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export default async (ctx) => {
|
|||
orderTitle = '人气直播';
|
||||
break;
|
||||
}
|
||||
const wbiVerifyString = await cache.getWbiVerifyString(ctx);
|
||||
const wbiVerifyString = await cache.getWbiVerifyString();
|
||||
let params = `__refresh__=true&_extra=&context=&page=1&page_size=42&order=${order}&duration=&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword=${urlEncodedKey}&ad_resource=&source_tag=3&gaia_vtoken=&category_id=&search_type=live&dynamic_offset=0&web_location=1430654`;
|
||||
params = utils.addWbiVerifyInfo(params, wbiVerifyString);
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ export default async (ctx) => {
|
|||
url: `https://api.bilibili.com/x/web-interface/wbi/search/type?${params}`,
|
||||
headers: {
|
||||
Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&from_source=webtop_search&spm_id_from=444.7&search_source=3&search_type=live_room`,
|
||||
Cookie: await cache.getCookie(ctx),
|
||||
Cookie: await cache.getCookie(),
|
||||
},
|
||||
});
|
||||
const data = response.data.data.result.live_room;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { config } from '@/config';
|
|||
|
||||
export default async (ctx) => {
|
||||
const uid = String(ctx.req.param('uid'));
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const cookie = config.bilibili.cookies[uid];
|
||||
if (cookie === undefined) {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ export default async (ctx) => {
|
|||
aid = bvid;
|
||||
bvid = null;
|
||||
}
|
||||
const name = await cache.getVideoNameFromId(ctx, aid, bvid);
|
||||
const name = await cache.getVideoNameFromId(aid, bvid);
|
||||
if (!aid) {
|
||||
aid = await cache.getAidFromBvid(ctx, bvid);
|
||||
aid = await cache.getAidFromBvid(bvid);
|
||||
}
|
||||
|
||||
const link = `https://www.bilibili.com/video/${bvid || `av${aid}`}`;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export default async (ctx) => {
|
|||
const uid = ctx.req.param('uid');
|
||||
const type = Number(ctx.req.param('type') || 1);
|
||||
const type_name = ((t) => ['', 'bangumi', 'cinema'][t])(type);
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export default async (ctx) => {
|
|||
ctx.set('data', notFoundData);
|
||||
return;
|
||||
}
|
||||
const [userName, face] = await cacheIn.getUsernameAndFaceFromUID(ctx, uid);
|
||||
const [userName, face] = await cacheIn.getUsernameAndFaceFromUID(uid);
|
||||
const host = `https://api.bilibili.com/x/series/archives?mid=${uid}&series_id=${sid}&only_normal=true&sort=desc&pn=1&ps=${limit}`;
|
||||
|
||||
const response = await got(host, {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export default async (ctx) => {
|
|||
const limit = ctx.req.query('limit') ?? 25;
|
||||
|
||||
const link = `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`;
|
||||
const [userName, face] = await cache.getUsernameAndFaceFromUID(ctx, uid);
|
||||
const [userName, face] = await cache.getUsernameAndFaceFromUID(uid);
|
||||
const host = `https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=true&page_num=1&page_size=${limit}`;
|
||||
|
||||
const response = await got(host, {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { config } from '@/config';
|
|||
export default async (ctx) => {
|
||||
const uid = ctx.req.param('uid');
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { config } from '@/config';
|
||||
import md5 from '@/utils/md5';
|
||||
const CryptoJS = require('crypto-js');
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
function iframe(aid, page, bvid) {
|
||||
return `<iframe src="https://www.bilibili.com/blackboard/html5mobileplayer.html?${bvid ? `bvid=${bvid}` : `aid=${aid}`}${
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import { parseDate } from '@/utils/parse-date';
|
|||
export default async (ctx) => {
|
||||
const uid = ctx.req.param('uid');
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
const cookie = await cache.getCookie(ctx);
|
||||
const wbiVerifyString = await cache.getWbiVerifyString(ctx);
|
||||
const cookie = await cache.getCookie();
|
||||
const wbiVerifyString = await cache.getWbiVerifyString();
|
||||
const dmImgList = utils.getDmImgList();
|
||||
const [name, face] = await cache.getUsernameAndFaceFromUID(ctx, uid);
|
||||
const [name, face] = await cache.getUsernameAndFaceFromUID(uid);
|
||||
|
||||
await got(`https://space.bilibili.com/${uid}/video?tid=0&page=1&keyword=&order=pubdate`, {
|
||||
headers: {
|
||||
|
|
@ -29,7 +29,7 @@ export default async (ctx) => {
|
|||
const pageTotal = Math.ceil(response.data.data.page.count / response.data.data.page.ps);
|
||||
|
||||
const getPage = async (pageId) => {
|
||||
const cookie = await cache.getCookie(ctx);
|
||||
const cookie = await cache.getCookie();
|
||||
await got(`https://space.bilibili.com/${uid}/video?tid=0&page=${pageId}&keyword=&order=pubdate`, {
|
||||
headers: {
|
||||
Referer: `https://space.bilibili.com/${uid}/`,
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import logger from '@/utils/logger';
|
|||
export default async (ctx) => {
|
||||
const uid = ctx.req.param('uid');
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
const cookie = await cache.getCookie(ctx);
|
||||
const wbiVerifyString = await cache.getWbiVerifyString(ctx);
|
||||
const cookie = await cache.getCookie();
|
||||
const wbiVerifyString = await cache.getWbiVerifyString();
|
||||
const dmImgList = utils.getDmImgList();
|
||||
const [name, face] = await cache.getUsernameAndFaceFromUID(ctx, uid);
|
||||
const [name, face] = await cache.getUsernameAndFaceFromUID(uid);
|
||||
|
||||
// await got(`https://space.bilibili.com/${uid}/video?tid=0&page=1&keyword=&order=pubdate`, {
|
||||
// headers: {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { config } from '@/config';
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import utils from './utils';
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
import { CookieJar } from 'tough-cookie';
|
||||
const cookieJar = new CookieJar();
|
||||
import { queryToBoolean } from '@/utils/readable-social';
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date';
|
|||
export default async (ctx) => {
|
||||
const uid = ctx.req.param('uid');
|
||||
const disableEmbed = ctx.req.param('disableEmbed');
|
||||
const name = await cache.getUsernameFromUID(ctx, uid);
|
||||
const name = await cache.getUsernameFromUID(uid);
|
||||
|
||||
const cookie = config.bilibili.cookies[uid];
|
||||
if (cookie === undefined) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import parser from '@/utils/rss-parser';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const dayjs = require('dayjs');
|
||||
const localizedFormat = require('dayjs/plugin/localizedFormat');
|
||||
require('dayjs/locale/zh-cn');
|
||||
import dayjs from 'dayjs';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { getSubPath } from '@/utils/common-utils';
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import util from './utils';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
export default async (ctx) => {
|
||||
const type = ctx.req.param('type');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import util from './utils';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
export default async (ctx) => {
|
||||
const type = ctx.req.param('type');
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import got from '@/utils/got';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
const asyncPoolAll = async (...args) => {
|
||||
const results = [];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
import cache from '@/utils/cache';
|
||||
import { load } from 'cheerio';
|
||||
import * as path from 'node:path';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import got from '@/utils/got';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import cache from '@/utils/cache';
|
||||
const cherrio = require('cheerio');
|
||||
import cherrio from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import puppeteer from '@/utils/puppeteer';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import got from '@/utils/got';
|
|||
import { load } from 'cheerio';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
export default async (ctx) => {
|
||||
const rootUrl = 'https://www.c114.com.cn';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|||
import cache from '@/utils/cache';
|
||||
import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import cache from '@/utils/cache';
|
||||
const cherrio = require('cheerio');
|
||||
import cherrio from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import got from '@/utils/got';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { load } from 'cheerio';
|
||||
const dayjs = require('dayjs');
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat');
|
||||
import dayjs from 'dayjs';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
dayjs.extend(customParseFormat);
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import got from '@/utils/got';
|
|||
import { load } from 'cheerio';
|
||||
import { parseDate, parseRelativeDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
import { CookieJar } from 'tough-cookie';
|
||||
|
||||
const cookieJar = new CookieJar();
|
||||
const baseUrl = 'https://www.chinathinktanks.org.cn';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import { load } from 'cheerio';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const https = require('https');
|
||||
const crypto = require('crypto');
|
||||
import https from 'https';
|
||||
import crypto from 'crypto';
|
||||
import { config } from '@/config';
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const CryptoJS = require('crypto-js');
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
const rootUrl = 'https://www.cls.cn';
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,15 @@ import got from '@/utils/got';
|
|||
import * as path from 'node:path';
|
||||
import { art } from '@/utils/render';
|
||||
|
||||
const dayjs = require('dayjs');
|
||||
dayjs.extend(require('dayjs/plugin/localizedFormat'));
|
||||
dayjs.extend(require('dayjs/plugin/duration'));
|
||||
dayjs.extend(require('dayjs/plugin/relativeTime'));
|
||||
require('dayjs/locale/zh-cn');
|
||||
import dayjs from 'dayjs';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(duration);
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.locale('zh-cn');
|
||||
|
||||
const sec2str = (sec) => dayjs.duration(Number.parseInt(sec), 'seconds').humanize();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date';
|
|||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
import { config } from '@/config';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
export default async (ctx) => {
|
||||
const id = ctx.req.param('id');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import got from '@/utils/got';
|
||||
const CryptoJS = require('crypto-js');
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
const apiHost = 'https://api.creative-comic.tw';
|
||||
const device = 'web_desktop';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const { inflateSync } = require('zlib');
|
||||
import { inflateSync } from 'zlib';
|
||||
|
||||
const unzip = (b64Data) => {
|
||||
const strData = Buffer.from(b64Data, 'base64').toString('binary');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
export default async (ctx) => {
|
||||
const category = ctx.req.param('category');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const dayjs = require('dayjs');
|
||||
import dayjs from 'dayjs';
|
||||
import got from '@/utils/got';
|
||||
|
||||
const getData = async (graphqlQuery) =>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
const ProcessFeed = async (items, cookies, browser, limit, cache) => {
|
||||
let newCookies = [];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import got from '@/utils/got';
|
|||
import { getData, getList } from './utils';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
const _website = 'dlnews';
|
||||
const topics = {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { load } from 'cheerio';
|
|||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
const dayjs = require('dayjs');
|
||||
import dayjs from 'dayjs';
|
||||
import * as path from 'node:path';
|
||||
|
||||
const rootUrl = 'https://www.dlsite.com';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import got from '@/utils/got';
|
||||
const { JSDOM } = require('jsdom');
|
||||
import { JSDOM } from 'jsdom';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
const { JSDOM } = require('jsdom');
|
||||
import { JSDOM } from 'jsdom';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const ProcessVideo = (content) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const url = require('url');
|
||||
import * as url from 'node:url';
|
||||
|
||||
const host = 'https://www.douban.com/explore/column/';
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import cache from '@/utils/cache';
|
||||
const querystring = require('querystring');
|
||||
import querystring from 'querystring';
|
||||
import got from '@/utils/got';
|
||||
import { fallback, queryToBoolean, queryToInteger } from '@/utils/readable-social';
|
||||
import { config } from '@/config';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import cache from '@/utils/cache';
|
||||
const querystring = require('querystring');
|
||||
import querystring from 'querystring';
|
||||
import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { getCurrentPath } from '@/utils/helpers';
|
|||
const __dirname = getCurrentPath(import.meta.url);
|
||||
|
||||
import got from '@/utils/got';
|
||||
const aesjs = require('aes-js');
|
||||
import aesjs from 'aes-js';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const CryptoJS = require('crypto-js');
|
||||
import CryptoJS from 'crypto-js';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { load } from 'cheerio';
|
|||
import * as path from 'node:path';
|
||||
import { art } from '@/utils/render';
|
||||
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
import { CookieJar } from 'tough-cookie';
|
||||
const cookieJar = new CookieJar();
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { load } from 'cheerio';
|
|||
import * as path from 'node:path';
|
||||
import { art } from '@/utils/render';
|
||||
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
import { CookieJar } from 'tough-cookie';
|
||||
const cookieJar = new CookieJar();
|
||||
|
||||
export default async (ctx) => {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import got from '@/utils/got';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const dayjs = require('dayjs');
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export default async (ctx) => {
|
||||
const locale = ctx.req.param('locale') ?? 'en-US';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import timezone from '@/utils/timezone';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import cache from '@/utils/cache';
|
||||
const CryptoJS = require('crypto-js');
|
||||
import CryptoJS from 'crypto-js';
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
const apiUrl = 'https://api.wfdata.club';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import util from './utils';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
const gbk2utf8 = (s) => iconv.decode(s, 'gbk');
|
||||
const host = 'https://www.flyert.com';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const iconv = require('iconv-lite');
|
||||
import iconv from 'iconv-lite';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
const url = require('url');
|
||||
const iconv = require('iconv-lite');
|
||||
import * as url from 'node:url';
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
const gbk2utf8 = (s) => iconv.decode(s, 'gbk');
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import got from '@/utils/got';
|
|||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import * as path from 'node:path';
|
||||
const zlib = require('zlib');
|
||||
import zlib from 'zlib';
|
||||
|
||||
const constants = {
|
||||
labelHot: '热门',
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import wait from '@/utils/wait';
|
||||
import { load } from 'cheerio';
|
||||
const { CookieJar } = require('tough-cookie');
|
||||
import { CookieJar } from 'tough-cookie';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import timezone from '@/utils/timezone';
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
import asyncPool from 'tiny-async-pool';
|
||||
|
||||
const site = 'https://oas.gdut.edu.cn/seeyon';
|
||||
const typeMap = {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import cache from '@/utils/cache';
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
const md = require('markdown-it')({
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const md = MarkdownIt({
|
||||
html: true,
|
||||
});
|
||||
const rootUrl = 'https://github.com';
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue