diff --git a/lib/v2/0818tuan/index.js b/lib/v2/0818tuan/index.js
index 6cdfdf582..0b2e0d239 100644
--- a/lib/v2/0818tuan/index.js
+++ b/lib/v2/0818tuan/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/12306/index.js b/lib/v2/12306/index.js
index b2d0b2518..4def83708 100644
--- a/lib/v2/12306/index.js
+++ b/lib/v2/12306/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
@@ -18,8 +19,8 @@ async function getJSESSIONID(linkUrl) {
return res.headers['set-cookie'].join(',').match(/JSESSIONID=([^;]+);/)[0];
}
-function getStationInfo(stationName, ctx) {
- return ctx.cache.tryGet(stationName, async () => {
+function getStationInfo(stationName) {
+ return cache.tryGet(stationName, async () => {
const res = await got({
method: 'get',
url: `${rootUrl}/otn/resources/js/framework/station_name.js`,
diff --git a/lib/v2/12306/zxdt.js b/lib/v2/12306/zxdt.js
index 0126a7438..45b3b913a 100644
--- a/lib/v2/12306/zxdt.js
+++ b/lib/v2/12306/zxdt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = require('url');
@@ -29,9 +30,9 @@ module.exports = async (ctx) => {
const date = info.date;
const itemUrl = url.resolve(link, info.link);
- const cache = await ctx.cache.get(itemUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(itemUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got.get(itemUrl);
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
description,
pubDate: new Date(date).toUTCString(),
};
- ctx.cache.set(itemUrl, JSON.stringify(single));
+ cache.set(itemUrl, JSON.stringify(single));
return single;
})
);
diff --git a/lib/v2/163/dy.js b/lib/v2/163/dy.js
index e4d689b9d..81475ff53 100644
--- a/lib/v2/163/dy.js
+++ b/lib/v2/163/dy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
imgsrc: e.imgsrc,
}));
- const items = await Promise.all(list.map((e) => parseDyArticle(charset, e, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((e) => parseDyArticle(charset, e, cache.tryGet)));
ctx.set('data', {
title: `网易号 - ${list[0].author}`,
diff --git a/lib/v2/163/dy2.js b/lib/v2/163/dy2.js
index e51bafddf..c8e9ea3ea 100644
--- a/lib/v2/163/dy2.js
+++ b/lib/v2/163/dy2.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseDyArticle(charset, item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseDyArticle(charset, item, cache.tryGet)));
ctx.set('data', {
title: `${$('head title').text()} - 网易号`,
diff --git a/lib/v2/163/exclusive.js b/lib/v2/163/exclusive.js
index 743274f22..ec3321221 100644
--- a/lib/v2/163/exclusive.js
+++ b/lib/v2/163/exclusive.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -96,7 +97,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
if (item.videoId) {
const detailResponse = await got({
diff --git a/lib/v2/163/news/rank.js b/lib/v2/163/news/rank.js
index 25508b185..b2d453e97 100644
--- a/lib/v2/163/news/rank.js
+++ b/lib/v2/163/news/rank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -110,7 +111,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
let link;
if (category === 'auto' || category === 'house' || category === 'travel') {
diff --git a/lib/v2/163/news/special.js b/lib/v2/163/news/special.js
index 1a431630e..44a5613d6 100644
--- a/lib/v2/163/news/special.js
+++ b/lib/v2/163/news/special.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -91,7 +92,7 @@ module.exports = async (ctx) => {
url = `https://3g.163.com/exclusive/video/${vid[1]}.html`;
}
}
- return ctx.cache.tryGet(url, async () => {
+ return cache.tryGet(url, async () => {
const article_response = await got(url);
const $ = load(article_response.data);
diff --git a/lib/v2/163/open/vip.js b/lib/v2/163/open/vip.js
index 5bc23fc16..c91f2c06d 100644
--- a/lib/v2/163/open/vip.js
+++ b/lib/v2/163/open/vip.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const {
data: { data },
} = await got.post(`${url}/open/trade/pc/course/getCourseInfo.do`, {
diff --git a/lib/v2/163/renjian.js b/lib/v2/163/renjian.js
index 439ce6416..32d4caa81 100644
--- a/lib/v2/163/renjian.js
+++ b/lib/v2/163/renjian.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/163/today.js b/lib/v2/163/today.js
index fa3bbf540..b85570d2b 100644
--- a/lib/v2/163/today.js
+++ b/lib/v2/163/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
if (needContent) {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/18comic/album.js b/lib/v2/18comic/album.js
index 5e8060a22..93b20305f 100644
--- a/lib/v2/18comic/album.js
+++ b/lib/v2/18comic/album.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/18comic/blogs.js b/lib/v2/18comic/blogs.js
index 5d72ec303..82d492a3b 100644
--- a/lib/v2/18comic/blogs.js
+++ b/lib/v2/18comic/blogs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/18comic/utils.js b/lib/v2/18comic/utils.js
index d389a476c..2bc40b32c 100644
--- a/lib/v2/18comic/utils.js
+++ b/lib/v2/18comic/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/19lou/index.js b/lib/v2/19lou/index.js
index 24f477f92..ccdda4047 100644
--- a/lib/v2/19lou/index.js
+++ b/lib/v2/19lou/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/1lou/index.js b/lib/v2/1lou/index.js
index 2d19e29cb..028c44708 100644
--- a/lib/v2/1lou/index.js
+++ b/lib/v2/1lou/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
});
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/1point3acres/category.js b/lib/v2/1point3acres/category.js
index 8c156c7bb..bda8e27b2 100644
--- a/lib/v2/1point3acres/category.js
+++ b/lib/v2/1point3acres/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
@@ -12,6 +13,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: `一亩三分地 - ${id}${types[type]}`,
link: currentUrl,
- item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
+ item: await ProcessThreads(cache.tryGet, apiUrl, order),
});
};
diff --git a/lib/v2/1point3acres/section.js b/lib/v2/1point3acres/section.js
index 1a0ca2072..7031faf80 100644
--- a/lib/v2/1point3acres/section.js
+++ b/lib/v2/1point3acres/section.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
const sections = {
@@ -23,6 +24,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: `一亩三分地 - ${Object.hasOwn(sections, id) ? sections[id] : id}${types[type]}`,
link: currentUrl,
- item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
+ item: await ProcessThreads(cache.tryGet, apiUrl, order),
});
};
diff --git a/lib/v2/1point3acres/thread.js b/lib/v2/1point3acres/thread.js
index 0b9d30136..571706666 100644
--- a/lib/v2/1point3acres/thread.js
+++ b/lib/v2/1point3acres/thread.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
@@ -10,6 +11,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: `一亩三分地 - ${types[type]}`,
link: rootUrl,
- item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
+ item: await ProcessThreads(cache.tryGet, apiUrl, order),
});
};
diff --git a/lib/v2/2048/index.js b/lib/v2/2048/index.js
index 2ef06f643..ea8806f2e 100644
--- a/lib/v2/2048/index.js
+++ b/lib/v2/2048/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const rootUrl = 'https://hjd2048.com';
- const entranceDomain = await ctx.cache.tryGet('2048:entranceDomain', async () => {
+ const entranceDomain = await cache.tryGet('2048:entranceDomain', async () => {
const { data: response } = await got('https://hjd.tw', {
headers: {
accept: '*/*',
@@ -52,7 +53,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/2cycd/index.js b/lib/v2/2cycd/index.js
index d0f2affa1..2a7e12b6f 100644
--- a/lib/v2/2cycd/index.js
+++ b/lib/v2/2cycd/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
// console.log(list);
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
responseType: 'buffer',
});
diff --git a/lib/v2/36kr/hot-list.js b/lib/v2/36kr/hot-list.js
index b76d0eeb7..9b1881685 100644
--- a/lib/v2/36kr/hot-list.js
+++ b/lib/v2/36kr/hot-list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -49,7 +50,7 @@ module.exports = async (ctx) => {
};
});
- items = await Promise.all(items.map((item) => ProcessItem(item, ctx.cache.tryGet)));
+ items = await Promise.all(items.map((item) => ProcessItem(item, cache.tryGet)));
ctx.set('data', {
title: `36氪 - ${categories[category].title}`,
diff --git a/lib/v2/36kr/index.js b/lib/v2/36kr/index.js
index 7f80b5889..cd397cebe 100644
--- a/lib/v2/36kr/index.js
+++ b/lib/v2/36kr/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
});
if (!/^\/(search|newsflashes)/.test(path)) {
- items = await Promise.all(items.map((item) => ProcessItem(item, ctx.cache.tryGet)));
+ items = await Promise.all(items.map((item) => ProcessItem(item, cache.tryGet)));
}
ctx.set('data', {
diff --git a/lib/v2/3dmgame/game.js b/lib/v2/3dmgame/game.js
index 438396cfb..648b8d2b5 100644
--- a/lib/v2/3dmgame/game.js
+++ b/lib/v2/3dmgame/game.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: $('head title').text().split('_')[0],
diff --git a/lib/v2/3dmgame/news-center.js b/lib/v2/3dmgame/news-center.js
index 6cc910ba0..f531c549b 100644
--- a/lib/v2/3dmgame/news-center.js
+++ b/lib/v2/3dmgame/news-center.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
};
});
- const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: '3DM - ' + $('title').text().split('_')[0],
diff --git a/lib/v2/423down/index.js b/lib/v2/423down/index.js
index aed9cc267..21c5972f9 100644
--- a/lib/v2/423down/index.js
+++ b/lib/v2/423down/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -83,7 +84,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
- item = await ctx.cache.tryGet(item.link, async () => {
+ item = await cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/4gamers/category.js b/lib/v2/4gamers/category.js
index ebd3cf488..526002a24 100644
--- a/lib/v2/4gamers/category.js
+++ b/lib/v2/4gamers/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseList, parseItem, getCategories } = require('./utils');
@@ -14,12 +15,12 @@ module.exports = async (ctx) => {
});
const list = parseList(response.data.results);
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
let categories = [];
let categoryName = '最新消息';
if (!isLatest) {
- categories = await getCategories(ctx.cache.tryGet);
+ categories = await getCategories(cache.tryGet);
categoryName = categories.find((c) => c.id === Number.parseInt(category)).name;
}
diff --git a/lib/v2/4gamers/tag.js b/lib/v2/4gamers/tag.js
index 4182f2f89..3ed6513d7 100644
--- a/lib/v2/4gamers/tag.js
+++ b/lib/v2/4gamers/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseList, parseItem } = require('./utils');
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
});
const list = parseList(response.data.results);
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('data', {
title: `4Gamers - #${tag}`,
diff --git a/lib/v2/4gamers/topic.js b/lib/v2/4gamers/topic.js
index 9c8cb062f..d421e6dda 100644
--- a/lib/v2/4gamers/topic.js
+++ b/lib/v2/4gamers/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseList, parseItem } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
});
const list = parseList(response.data.results);
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('data', {
title: `4Gamers - ${topic}`,
diff --git a/lib/v2/4ksj/forum.js b/lib/v2/4ksj/forum.js
index 1c5cc9c21..75f49fc2d 100644
--- a/lib/v2/4ksj/forum.js
+++ b/lib/v2/4ksj/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/500px/tribe-set.js b/lib/v2/500px/tribe-set.js
index 4bea85a00..2e93521db 100644
--- a/lib/v2/500px/tribe-set.js
+++ b/lib/v2/500px/tribe-set.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
const path = require('path');
@@ -8,8 +9,8 @@ module.exports = async (ctx) => {
const { id } = ctx.params;
const limit = Number.parseInt(ctx.req.query('limit')) || 100;
- const { tribe } = await getTribeDetail(id, ctx.cache.tryGet);
- const tribeSets = await getTribeSets(id, limit, ctx.cache.tryGet);
+ const { tribe } = await getTribeDetail(id, cache.tryGet);
+ const tribeSets = await getTribeSets(id, limit, cache.tryGet);
const items = tribeSets.map((item) => ({
title: item.title,
diff --git a/lib/v2/500px/user.js b/lib/v2/500px/user.js
index b98865526..2a1852562 100644
--- a/lib/v2/500px/user.js
+++ b/lib/v2/500px/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';
const path = require('path');
@@ -8,11 +9,11 @@ module.exports = async (ctx) => {
const limit = Number.parseInt(ctx.req.query('limit')) || 100;
if (id.length !== 33) {
- id = (await getUserInfoFromUsername(id, ctx.cache.tryGet)).id;
+ id = (await getUserInfoFromUsername(id, cache.tryGet)).id;
}
- const userInfo = await getUserInfoFromId(id, ctx.cache.tryGet);
- const userWorks = await getUserWorks(id, limit, ctx.cache.tryGet);
+ const userInfo = await getUserInfoFromId(id, cache.tryGet);
+ const userWorks = await getUserWorks(id, limit, cache.tryGet);
const items = userWorks.map((item) => ({
title: item.title || '无题',
diff --git a/lib/v2/50forum/zhuanjia.js b/lib/v2/50forum/zhuanjia.js
index 59e461062..f764412d8 100644
--- a/lib/v2/50forum/zhuanjia.js
+++ b/lib/v2/50forum/zhuanjia.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
out = await Promise.all(
out.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const result = await got(item.link);
const $ = load(result.data);
diff --git a/lib/v2/52hrtt/index.js b/lib/v2/52hrtt/index.js
index 7264fd4c8..14198223e 100644
--- a/lib/v2/52hrtt/index.js
+++ b/lib/v2/52hrtt/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/52hrtt/symposium.js b/lib/v2/52hrtt/symposium.js
index c8eee38e9..1f56d4500 100644
--- a/lib/v2/52hrtt/symposium.js
+++ b/lib/v2/52hrtt/symposium.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/56kog/class.js b/lib/v2/56kog/class.js
index 15525ecba..1b46edff6 100644
--- a/lib/v2/56kog/class.js
+++ b/lib/v2/56kog/class.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, fetchItems } = require('./util');
module.exports = async (ctx) => {
@@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const currentUrl = new URL(`class/${category}.html`, rootUrl).href;
- ctx.set('data', await fetchItems(limit, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await fetchItems(limit, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/56kog/top.js b/lib/v2/56kog/top.js
index d83e1049d..d9ecf05d4 100644
--- a/lib/v2/56kog/top.js
+++ b/lib/v2/56kog/top.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, fetchItems } = require('./util');
module.exports = async (ctx) => {
@@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const currentUrl = new URL(`top/${category.split(/_/)[0]}_1.html`, rootUrl).href;
- ctx.set('data', await fetchItems(limit, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await fetchItems(limit, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/5eplay/index.js b/lib/v2/5eplay/index.js
index 59504c81e..15755d354 100644
--- a/lib/v2/5eplay/index.js
+++ b/lib/v2/5eplay/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
const zlib = require('zlib');
import got from '@/utils/got';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
});
// get acw_sc__v2
- const acw_sc__v2 = await ctx.cache.tryGet(
+ const acw_sc__v2 = await cache.tryGet(
articleUrl,
async () => {
// Zlib Z_BUF_ERROR: unexpected end of file, should close decompress
@@ -52,7 +53,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.list.map((item) =>
- ctx.cache.tryGet(item.jump_link, async () => {
+ cache.tryGet(item.jump_link, async () => {
if (!acw_sc__v2) {
return {
title: item.title,
diff --git a/lib/v2/6park/index.js b/lib/v2/6park/index.js
index 9d1f5d36f..b29db20a1 100644
--- a/lib/v2/6park/index.js
+++ b/lib/v2/6park/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/6park/news.js b/lib/v2/6park/news.js
index aa4849f36..932d151ca 100644
--- a/lib/v2/6park/news.js
+++ b/lib/v2/6park/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items
.filter((item) => /6parknews\.com/.test(item.link))
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/6v123/utils.js b/lib/v2/6v123/utils.js
index e5d0b05b3..d920f53f4 100644
--- a/lib/v2/6v123/utils.js
+++ b/lib/v2/6v123/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const iconv = require('iconv-lite');
import { load } from 'cheerio';
@@ -49,7 +50,7 @@ const utils = {
const itemUrl = 'https://www.hao6v.cc' + link.attr('href');
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const detailInfo = await utils.loadDetailPage(itemUrl);
if (detailInfo.enclosure_urls.length > 1) {
diff --git a/lib/v2/78dm/index.js b/lib/v2/78dm/index.js
index 5039397e4..904eb3f7a 100644
--- a/lib/v2/78dm/index.js
+++ b/lib/v2/78dm/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/7mmtv/index.js b/lib/v2/7mmtv/index.js
index f75cfb6a8..dc93bf03d 100644
--- a/lib/v2/7mmtv/index.js
+++ b/lib/v2/7mmtv/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/81/81rc/index.js b/lib/v2/81/81rc/index.js
index 585089cb0..fa796f5f5 100644
--- a/lib/v2/81/81rc/index.js
+++ b/lib/v2/81/81rc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/8264/list.js b/lib/v2/8264/list.js
index 2cb47525d..aea2a78ec 100644
--- a/lib/v2/8264/list.js
+++ b/lib/v2/8264/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
});
diff --git a/lib/v2/8kcos/cat.js b/lib/v2/8kcos/cat.js
index 7a4555274..52ba9f073 100644
--- a/lib/v2/8kcos/cat.js
+++ b/lib/v2/8kcos/cat.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
item: await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
const { href } = load(e)('h2 > a')[0].attribs;
- return ctx.cache.tryGet(href, () => loadArticle(href));
+ return cache.tryGet(href, () => loadArticle(href));
})
),
});
diff --git a/lib/v2/8kcos/latest.js b/lib/v2/8kcos/latest.js
index a569ca871..c61e8caca 100644
--- a/lib/v2/8kcos/latest.js
+++ b/lib/v2/8kcos/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
(await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
const { href } = load(e)('h2 > a')[0].attribs;
- return ctx.cache.tryGet(href, () => loadArticle(href));
+ return cache.tryGet(href, () => loadArticle(href));
})
)),
});
diff --git a/lib/v2/8kcos/tag.js b/lib/v2/8kcos/tag.js
index 1a48d3960..dabd6e5cc 100644
--- a/lib/v2/8kcos/tag.js
+++ b/lib/v2/8kcos/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
item: await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
const { href } = load(e)('h2 > a')[0].attribs;
- return ctx.cache.tryGet(href, () => loadArticle(href));
+ return cache.tryGet(href, () => loadArticle(href));
})
),
});
diff --git a/lib/v2/8world/index.js b/lib/v2/8world/index.js
index 489ccb546..773a29bb2 100644
--- a/lib/v2/8world/index.js
+++ b/lib/v2/8world/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/91porn/author.js b/lib/v2/91porn/author.js
index ff8da9e35..39cfb82d4 100644
--- a/lib/v2/91porn/author.js
+++ b/lib/v2/91porn/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
+ cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/91porn/index.js b/lib/v2/91porn/index.js
index e58f9dab2..d8eb55a94 100644
--- a/lib/v2/91porn/index.js
+++ b/lib/v2/91porn/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
+ cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/95mm/utils.js b/lib/v2/95mm/utils.js
index 014513352..b50840525 100644
--- a/lib/v2/95mm/utils.js
+++ b/lib/v2/95mm/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -34,7 +35,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/9to5/subsite.js b/lib/v2/9to5/subsite.js
index 77a3d2c06..b74bb0126 100644
--- a/lib/v2/9to5/subsite.js
+++ b/lib/v2/9to5/subsite.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
const utils = require('./utils');
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.splice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10).map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/aamacau/index.js b/lib/v2/aamacau/index.js
index 1faeca5a4..e18ab00e9 100644
--- a/lib/v2/aamacau/index.js
+++ b/lib/v2/aamacau/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/abc/index.js b/lib/v2/abc/index.js
index 2b0339034..c1cd89b2f 100644
--- a/lib/v2/abc/index.js
+++ b/lib/v2/abc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -67,7 +68,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/abskoop/index.js b/lib/v2/abskoop/index.js
index 53ffde703..37566a5a4 100644
--- a/lib/v2/abskoop/index.js
+++ b/lib/v2/abskoop/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
const $detail = load(detailResponse.data);
$detail('article.post-content').find('.lwptoc').remove();
diff --git a/lib/v2/acfun/article.js b/lib/v2/acfun/article.js
index 2f1e029be..391a5367b 100644
--- a/lib/v2/acfun/article.js
+++ b/lib/v2/acfun/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -70,7 +71,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link, {
headers: {
referer: url,
diff --git a/lib/v2/acpaa/index.js b/lib/v2/acpaa/index.js
index c4ea3d68f..c04be5e8c 100644
--- a/lib/v2/acpaa/index.js
+++ b/lib/v2/acpaa/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/acs/journal.js b/lib/v2/acs/journal.js
index 3f408cb64..a54d3c82c 100644
--- a/lib/v2/acs/journal.js
+++ b/lib/v2/acs/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
let title = '';
const browser = await puppeteer();
- const items = await ctx.cache.tryGet(
+ const items = await cache.tryGet(
currentUrl,
async () => {
const page = await browser.newPage();
diff --git a/lib/v2/aeaweb/index.js b/lib/v2/aeaweb/index.js
index b84120f22..35b144c1b 100644
--- a/lib/v2/aeaweb/index.js
+++ b/lib/v2/aeaweb/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/aeon/utils.js b/lib/v2/aeon/utils.js
index 70ef01768..51f42936b 100644
--- a/lib/v2/aeon/utils.js
+++ b/lib/v2/aeon/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { art } from '@/utils/render';
@@ -6,7 +7,7 @@ const path = require('path');
const getData = async (ctx, list) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/agefans/update.js b/lib/v2/agefans/update.js
index 656255f47..e8ac81cfb 100644
--- a/lib/v2/agefans/update.js
+++ b/lib/v2/agefans/update.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { rootUrl } = require('./utils');
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/agirls/index.js b/lib/v2/agirls/index.js
index 532728fef..1833b4ff5 100644
--- a/lib/v2/agirls/index.js
+++ b/lib/v2/agirls/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseArticle } = require('./utils');
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseArticle(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseArticle(item))));
ctx.set('data', {
title: $('head title').text().trim(),
diff --git a/lib/v2/agirls/topic.js b/lib/v2/agirls/topic.js
index 97d0357b1..78c9441eb 100644
--- a/lib/v2/agirls/topic.js
+++ b/lib/v2/agirls/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseArticle } = require('./utils');
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseArticle(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseArticle(item))));
ctx.set('data', {
title: $('head title').text().trim(),
diff --git a/lib/v2/agora0/index.js b/lib/v2/agora0/index.js
index 52f7ea1ec..cf227695f 100644
--- a/lib/v2/agora0/index.js
+++ b/lib/v2/agora0/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/agora0/pen0.js b/lib/v2/agora0/pen0.js
index f7a8f3991..7d445cf45 100644
--- a/lib/v2/agora0/pen0.js
+++ b/lib/v2/agora0/pen0.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
$('h1').remove();
diff --git a/lib/v2/ahjzu/news.js b/lib/v2/ahjzu/news.js
index 395199390..c13ccb056 100644
--- a/lib/v2/ahjzu/news.js
+++ b/lib/v2/ahjzu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/aijishu/utils.js b/lib/v2/aijishu/utils.js
index 14e6c756a..88e9713ec 100644
--- a/lib/v2/aijishu/utils.js
+++ b/lib/v2/aijishu/utils.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseRelativeDate, parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
-const parseArticle = (item, ctx) => {
+const parseArticle = (item) => {
const articleUrl = `https://aijishu.com${item.url || item.object.url}`;
- return ctx.cache.tryGet(articleUrl, async () => {
+ return cache.tryGet(articleUrl, async () => {
const d1 = parseDate(item.createdDate, ['YYYY-MM-DD', 'M-DD']);
const d2 = parseRelativeDate(item.createdDate);
diff --git a/lib/v2/aip/journal-pupp.js b/lib/v2/aip/journal-pupp.js
index 5c39ccb1b..265f50c64 100644
--- a/lib/v2/aip/journal-pupp.js
+++ b/lib/v2/aip/journal-pupp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
const { puppeteerGet, renderDesc } = require('./utils');
import { config } from '@/config';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
// use Puppeteer due to the obstacle by cloudflare challenge
const browser = await puppeteer();
- const { jrnlName, list } = await ctx.cache.tryGet(
+ const { jrnlName, list } = await cache.tryGet(
jrnlUrl,
async () => {
const response = await puppeteerGet(jrnlUrl, browser);
diff --git a/lib/v2/airchina/index.js b/lib/v2/airchina/index.js
index ac5dc0f82..4d3489659 100644
--- a/lib/v2/airchina/index.js
+++ b/lib/v2/airchina/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const buildData = require('@/utils/common-config');
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
await Promise.all(
ctx.state.data.item.map(async (item) => {
const detailLink = baseUrl + item.link;
- item.description = await ctx.cache.tryGet(detailLink, async () => {
+ item.description = await cache.tryGet(detailLink, async () => {
const result = await got(detailLink);
const $ = load(result.data);
return $('.serviceMsg').html();
diff --git a/lib/v2/aisixiang/column.js b/lib/v2/aisixiang/column.js
index 60932744f..1f6e64b0f 100644
--- a/lib/v2/aisixiang/column.js
+++ b/lib/v2/aisixiang/column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
- item: await ProcessFeed(limit, ctx.cache.tryGet, items),
+ item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $('div.tips').text(),
diff --git a/lib/v2/aisixiang/thinktank.js b/lib/v2/aisixiang/thinktank.js
index 491226d2a..7a747291f 100644
--- a/lib/v2/aisixiang/thinktank.js
+++ b/lib/v2/aisixiang/thinktank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
- item: await ProcessFeed(limit, ctx.cache.tryGet, items),
+ item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $('div.thinktank-author-description-box p').text(),
diff --git a/lib/v2/aisixiang/toplist.js b/lib/v2/aisixiang/toplist.js
index e51fae32f..1206a7e15 100644
--- a/lib/v2/aisixiang/toplist.js
+++ b/lib/v2/aisixiang/toplist.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
- item: await ProcessFeed(limit, ctx.cache.tryGet, items),
+ item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
language: 'zh-cn',
diff --git a/lib/v2/aisixiang/zhuanti.js b/lib/v2/aisixiang/zhuanti.js
index 3eb0e8bc5..0cc188bca 100644
--- a/lib/v2/aisixiang/zhuanti.js
+++ b/lib/v2/aisixiang/zhuanti.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
- item: await ProcessFeed(limit, ctx.cache.tryGet, items),
+ item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $('div.tips p').text(),
diff --git a/lib/v2/aliresearch/information.js b/lib/v2/aliresearch/information.js
index 8b097e6c2..6991430d0 100644
--- a/lib/v2/aliresearch/information.js
+++ b/lib/v2/aliresearch/information.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: `${rootUrl}/ch/getArticle`,
diff --git a/lib/v2/aliyun/database-month.js b/lib/v2/aliyun/database-month.js
index 1bf00b0f0..67a2331e6 100644
--- a/lib/v2/aliyun/database-month.js
+++ b/lib/v2/aliyun/database-month.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
list.map((item) => {
const link = item.link;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const itemReponse = await got(link);
const itemElement = load(itemReponse.data);
item.description = itemElement('.content').html();
diff --git a/lib/v2/aliyun/notice.js b/lib/v2/aliyun/notice.js
index 4bc55f695..314a8eb61 100644
--- a/lib/v2/aliyun/notice.js
+++ b/lib/v2/aliyun/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const itemReponse = await got(item.link);
const itemElement = load(itemReponse.data);
item.description = itemElement('#se-knowledge').html();
diff --git a/lib/v2/aljazeera/index.js b/lib/v2/aljazeera/index.js
index f1e00776e..1be46a0fa 100644
--- a/lib/v2/aljazeera/index.js
+++ b/lib/v2/aljazeera/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -55,7 +56,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50).map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ally/rail.js b/lib/v2/ally/rail.js
index 243bfcd9e..2530870fb 100644
--- a/lib/v2/ally/rail.js
+++ b/lib/v2/ally/rail.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -55,7 +56,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
// fix weird format
diff --git a/lib/v2/annualreviews/index.js b/lib/v2/annualreviews/index.js
index 1660afc75..3de8ec86b 100644
--- a/lib/v2/annualreviews/index.js
+++ b/lib/v2/annualreviews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const apiUrl = `${apiRootUrl}/works/${item.doi}`;
const detailResponse = await got({
diff --git a/lib/v2/anquanke/category.js b/lib/v2/anquanke/category.js
index 8303019fa..a38fc8121 100644
--- a/lib/v2/anquanke/category.js
+++ b/lib/v2/anquanke/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
title: item.title,
description:
fulltext === 'fulltext' || fulltext === 'quanwen'
- ? await ctx.cache.tryGet(art_url, async () => {
+ ? await cache.tryGet(art_url, async () => {
const { data: res } = await got(art_url);
const content = load(res);
return content('#js-article').html();
diff --git a/lib/v2/apiseven/blog.js b/lib/v2/apiseven/blog.js
index ddba10149..64c14b633 100644
--- a/lib/v2/apiseven/blog.js
+++ b/lib/v2/apiseven/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const articles = await getArticles();
const items = await Promise.all(
articles.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: res } = await got(item.link);
const $ = load(res);
const json = JSON.parse($('#__NEXT_DATA__').text());
diff --git a/lib/v2/apnews/topics.js b/lib/v2/apnews/topics.js
index e1727ee39..b1abca57f 100644
--- a/lib/v2/apnews/topics.js
+++ b/lib/v2/apnews/topics.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
}))
.filter((e) => typeof e.link === 'string')
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
$('div.Enhancement').remove();
diff --git a/lib/v2/app-center/release.js b/lib/v2/app-center/release.js
index 5daeed79a..3ac4fd3e2 100644
--- a/lib/v2/app-center/release.js
+++ b/lib/v2/app-center/release.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
const md = new MarkdownIt();
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const releaseResponse = await got(item.link);
const releaseInfo = releaseResponse.data;
diff --git a/lib/v2/apple/exchange-repair.js b/lib/v2/apple/exchange-repair.js
index ee34d0402..331ca0c58 100644
--- a/lib/v2/apple/exchange-repair.js
+++ b/lib/v2/apple/exchange-repair.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $$ = load(response.data);
diff --git a/lib/v2/appleinsider/index.js b/lib/v2/appleinsider/index.js
index 8e9091c84..32f0a41e0 100644
--- a/lib/v2/appleinsider/index.js
+++ b/lib/v2/appleinsider/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/aqara/news.js b/lib/v2/aqara/news.js
index 9d521cc47..82591cc74 100644
--- a/lib/v2/aqara/news.js
+++ b/lib/v2/aqara/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/arknights/announce.js b/lib/v2/arknights/announce.js
index edb95a6ff..9153ce5a1 100644
--- a/lib/v2/arknights/announce.js
+++ b/lib/v2/arknights/announce.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
announceList = await Promise.all(
announceList.map((item) =>
- ctx.cache.tryGet(item.webUrl, async () => {
+ cache.tryGet(item.webUrl, async () => {
const { data } = await got({
method: 'get',
url: item.webUrl,
diff --git a/lib/v2/arknights/news.js b/lib/v2/arknights/news.js
index a603783eb..5a29dfcee 100644
--- a/lib/v2/arknights/news.js
+++ b/lib/v2/arknights/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
.map(async (index, item) => {
item = $(item);
const link = `https://ak.hypergryph.com${item.attr('href')}`;
- const description = await ctx.cache.tryGet(link, async () => {
+ const description = await cache.tryGet(link, async () => {
const result = await got(link);
const $ = load(result.data);
return $('.article-content').html();
diff --git a/lib/v2/artstation/user.js b/lib/v2/artstation/user.js
index c2327d9c0..758585e9e 100644
--- a/lib/v2/artstation/user.js
+++ b/lib/v2/artstation/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const path = require('path');
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
'user-agent': config.trueUA,
};
- const csrfToken = await ctx.cache.tryGet('artstation:csrfToken', async () => {
+ const csrfToken = await cache.tryGet('artstation:csrfToken', async () => {
const tokenResponse = await got.post('https://www.artstation.com/api/v2/csrf_protection/token.json', {
headers,
});
@@ -60,7 +61,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.assetsCount > 1 || !item.icons.image) {
const { data } = await got(`https://www.artstation.com/projects/${item.hashId}.json`, {
headers: {
diff --git a/lib/v2/asiantolick/index.js b/lib/v2/asiantolick/index.js
index 6bac2adc9..c2ec0bf2c 100644
--- a/lib/v2/asiantolick/index.js
+++ b/lib/v2/asiantolick/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -61,7 +62,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/atcoder/contest.js b/lib/v2/atcoder/contest.js
index a52fe5b11..b5787856f 100644
--- a/lib/v2/atcoder/contest.js
+++ b/lib/v2/atcoder/contest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/auto-stats/index.js b/lib/v2/auto-stats/index.js
index c81177940..78f60e2b4 100644
--- a/lib/v2/auto-stats/index.js
+++ b/lib/v2/auto-stats/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
});
diff --git a/lib/v2/baai/events.js b/lib/v2/baai/events.js
index a9d44cc6b..9be0c05f6 100644
--- a/lib/v2/baai/events.js
+++ b/lib/v2/baai/events.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, apiHost, parseEventDetail, parseItem } = require('./utils');
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
item.description = await parseEventDetail(item);
return item;
})
diff --git a/lib/v2/baai/hub.js b/lib/v2/baai/hub.js
index 53f8bd079..b1bfaf7da 100644
--- a/lib/v2/baai/hub.js
+++ b/lib/v2/baai/hub.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.eventId) {
item.description = await parseEventDetail(item);
} else {
diff --git a/lib/v2/backlinko/blog.js b/lib/v2/backlinko/blog.js
index 55046ccc1..2b72efcb2 100644
--- a/lib/v2/backlinko/blog.js
+++ b/lib/v2/backlinko/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
posts.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.apiUrl);
const post = data.pageProps.post || data.pageProps.lockedPost;
diff --git a/lib/v2/baidu/search.js b/lib/v2/baidu/search.js
index 45ad45e44..c1453812b 100644
--- a/lib/v2/baidu/search.js
+++ b/lib/v2/baidu/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`;
const key = `baidu-search:${url}`;
- const items = await ctx.cache.tryGet(
+ const items = await cache.tryGet(
key,
async () => {
const response = (await got(url)).data;
diff --git a/lib/v2/bandcamp/tag.js b/lib/v2/bandcamp/tag.js
index 07fc80cf7..6d001c8f1 100644
--- a/lib/v2/bandcamp/tag.js
+++ b/lib/v2/bandcamp/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bangumi/moe/index.js b/lib/v2/bangumi/moe/index.js
index 46cadd731..c8d7c445c 100644
--- a/lib/v2/bangumi/moe/index.js
+++ b/lib/v2/bangumi/moe/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
tag_id = await Promise.all(
params.map((param) =>
- ctx.cache.tryGet(param, async () => {
+ cache.tryGet(param, async () => {
const paramResponse = await got({
method: 'post',
url: tagUrl,
@@ -61,7 +62,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: `${rootUrl}/api/tag/fetch`,
diff --git a/lib/v2/bangumi/tv/calendar/today.js b/lib/v2/bangumi/tv/calendar/today.js
index 7aa93d6a9..3f2d74e80 100644
--- a/lib/v2/bangumi/tv/calendar/today.js
+++ b/lib/v2/bangumi/tv/calendar/today.js
@@ -1,9 +1,10 @@
+import cache from '@/utils/cache';
const getData = require('./_base');
import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
- const [list, data] = await getData(ctx.cache.tryGet);
+ const [list, data] = await getData(cache.tryGet);
const siteMeta = data.siteMeta;
const today = new Date(Date.now());
diff --git a/lib/v2/bangumi/tv/group/topic.js b/lib/v2/bangumi/tv/group/topic.js
index ea96abe7e..2174a80e9 100644
--- a/lib/v2/bangumi/tv/group/topic.js
+++ b/lib/v2/bangumi/tv/group/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
.toArray()
.map(async (elem) => {
const link = new URL($('.subject a', elem).attr('href'), base_url).href;
- const fullText = await ctx.cache.tryGet(link, async () => {
+ const fullText = await cache.tryGet(link, async () => {
const { data: html } = await got(link);
const $ = load(html);
return $('.postTopic .topic_content').html();
diff --git a/lib/v2/bangumi/tv/user/blog.js b/lib/v2/bangumi/tv/user/blog.js
index b74aad867..ae29d29a2 100644
--- a/lib/v2/bangumi/tv/user/blog.js
+++ b/lib/v2/bangumi/tv/user/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got({ method: 'get', url: item.link });
const content = load(res.data);
diff --git a/lib/v2/baozimh/index.js b/lib/v2/baozimh/index.js
index 4d940adcb..6bb435ab0 100644
--- a/lib/v2/baozimh/index.js
+++ b/lib/v2/baozimh/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
item.description = art(path.join(__dirname, 'templates/desc.art'), {
diff --git a/lib/v2/barronschina/index.js b/lib/v2/barronschina/index.js
index 68f1459aa..49374ae08 100644
--- a/lib/v2/barronschina/index.js
+++ b/lib/v2/barronschina/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
};
})
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bast/index.js b/lib/v2/bast/index.js
index a776769c5..56166bb30 100644
--- a/lib/v2/bast/index.js
+++ b/lib/v2/bast/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/bast\.net\.cn/.test(item.link)) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/bbc/index.js b/lib/v2/bbc/index.js
index 2f7f4df01..cb8d64431 100644
--- a/lib/v2/bbc/index.js
+++ b/lib/v2/bbc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bdys/index.js b/lib/v2/bdys/index.js
index 987ec128b..42b872781 100644
--- a/lib/v2/bdys/index.js
+++ b/lib/v2/bdys/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -55,7 +56,7 @@ module.exports = async (ctx) => {
const items = [];
for await (const data of asyncPool(1, list, (item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/behance/user.js b/lib/v2/behance/user.js
index 5b392fd6f..e22abbf5c 100644
--- a/lib/v2/behance/user.js
+++ b/lib/v2/behance/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
item = item.project;
}
const url = `${item.url}?ilo0=1`;
- const description = await ctx.cache.tryGet(url, async () => {
+ const description = await cache.tryGet(url, async () => {
const response2 = await got({
method: 'get',
url,
diff --git a/lib/v2/bendibao/news.js b/lib/v2/bendibao/news.js
index 562118c78..740672b20 100644
--- a/lib/v2/bendibao/news.js
+++ b/lib/v2/bendibao/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -67,7 +68,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/bilibili/cache.js b/lib/v2/bilibili/cache.js
index ba465d2b3..4edf76d8c 100644
--- a/lib/v2/bilibili/cache.js
+++ b/lib/v2/bilibili/cache.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { load } from 'cheerio';
@@ -5,12 +6,12 @@ import { config } from '@/config';
const logger = require('@/utils/logger');
module.exports = {
- getCookie: (ctx) => {
+ 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 ctx.cache.tryGet(key, async () => {
+ 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');
@@ -53,7 +54,7 @@ module.exports = {
},
getWbiVerifyString: (ctx) => {
const key = 'bili-wbi-verify-string';
- return ctx.cache.tryGet(key, async () => {
+ 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: {
@@ -91,7 +92,7 @@ module.exports = {
},
getUsernameFromUID: (ctx, uid) => {
const key = 'bili-username-from-uid-' + uid;
- return ctx.cache.tryGet(key, async () => {
+ 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}/`, {
@@ -113,8 +114,8 @@ module.exports = {
getUsernameAndFaceFromUID: async (ctx, uid) => {
const nameKey = 'bili-username-from-uid-' + uid;
const faceKey = 'bili-userface-from-uid-' + uid;
- let name = await ctx.cache.get(nameKey);
- let face = await ctx.cache.get(faceKey);
+ 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);
@@ -137,14 +138,14 @@ module.exports = {
} else {
logger.error(`Error when visiting /x/space/wbi/acc/info: ${JSON.stringify(nameResponse)}`);
}
- ctx.cache.set(nameKey, name);
- ctx.cache.set(faceKey, face);
+ cache.set(nameKey, name);
+ cache.set(faceKey, face);
}
return [name, face];
},
getLiveIDFromShortID: (ctx, shortID) => {
const key = `bili-liveID-from-shortID-${shortID}`;
- return ctx.cache.tryGet(key, async () => {
+ 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}`,
@@ -155,7 +156,7 @@ module.exports = {
},
getUsernameFromLiveID: (ctx, liveID) => {
const key = `bili-username-from-liveID-${liveID}`;
- return ctx.cache.tryGet(key, async () => {
+ 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}`,
@@ -166,7 +167,7 @@ module.exports = {
},
getVideoNameFromId: (ctx, aid, bvid) => {
const key = `bili-videoname-from-id-${bvid || aid}`;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const { data } = await got(`https://api.bilibili.com/x/web-interface/view`, {
searchParams: {
aid: aid || undefined,
@@ -179,7 +180,7 @@ module.exports = {
},
getCidFromId: (ctx, aid, pid, bvid) => {
const key = `bili-cid-from-id-${bvid || aid}-${pid}`;
- return ctx.cache.tryGet(key, async () => {
+ 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}`}`,
});
@@ -188,7 +189,7 @@ module.exports = {
},
getAidFromBvid: async (ctx, bvid) => {
const key = `bili-cid-from-bvid-${bvid}`;
- let aid = await ctx.cache.get(key);
+ let aid = await cache.get(key);
if (!aid) {
const response = await got(`https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`, {
headers: {
@@ -198,13 +199,13 @@ module.exports = {
if (response.data && response.data.data && response.data.data.aid) {
aid = response.data.data.aid;
}
- ctx.cache.set(key, aid);
+ cache.set(key, aid);
}
return aid;
},
getArticleDataFromCvid: async (ctx, cvid, uid) => {
const url = `https://www.bilibili.com/read/cv${cvid}/`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
url,
async () =>
(
diff --git a/lib/v2/bilibili/dynamic.js b/lib/v2/bilibili/dynamic.js
index 24a6005dc..71fe0c05a 100644
--- a/lib/v2/bilibili/dynamic.js
+++ b/lib/v2/bilibili/dynamic.js
@@ -1,9 +1,10 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const JSONbig = require('json-bigint');
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
const { fallback, queryToBoolean } = require('@/utils/readable-social');
-const cache = require('./cache');
+const cacheIn = require('./cache');
/**
@by CaoMeiYouRen 2020-05-05 添加注释
@@ -85,11 +86,11 @@ module.exports = async (ctx) => {
});
const cards = JSONbig.parse(response.body).data.cards;
- const usernameAndFace = await cache.getUsernameAndFaceFromUID(ctx, uid);
+ const usernameAndFace = await cacheIn.getUsernameAndFaceFromUID(ctx, uid);
const author = usernameAndFace[0] ?? cards[0]?.desc?.user_profile?.info.uname;
const face = usernameAndFace[1] ?? cards[0]?.desc?.user_profile?.info?.face;
- ctx.cache.set(`bili-username-from-uid-${uid}`, author);
- ctx.cache.set(`bili-userface-from-uid-${uid}`, face);
+ cache.set(`bili-username-from-uid-${uid}`, author);
+ cache.set(`bili-userface-from-uid-${uid}`, face);
const getTitle = (data) => (data ? data.title || data.description || data.content || (data.vest && data.vest.content) || '' : '');
const getDes = (data) =>
@@ -216,7 +217,7 @@ module.exports = async (ctx) => {
};
if (data.image_urls && displayArticle) {
- data_content = (await cache.getArticleDataFromCvid(ctx, data.id, uid)).description;
+ data_content = (await cacheIn.getArticleDataFromCvid(ctx, data.id, uid)).description;
}
return {
diff --git a/lib/v2/bilibili/user-channel.js b/lib/v2/bilibili/user-channel.js
index a03dee57c..67350a60b 100644
--- a/lib/v2/bilibili/user-channel.js
+++ b/lib/v2/bilibili/user-channel.js
@@ -1,6 +1,7 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
-const cache = require('./cache');
+const cacheIn = require('./cache');
const utils = require('./utils');
const notFoundData = {
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
// 获取频道信息
const channelInfoLink = `https://api.bilibili.com/x/series/series?series_id=${sid}`;
- const channelInfo = await ctx.cache.tryGet(channelInfoLink, async () => {
+ const channelInfo = await cache.tryGet(channelInfoLink, async () => {
const response = await got(channelInfoLink, {
headers: {
Referer: link,
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
ctx.set('data', notFoundData);
return;
}
- const [userName, face] = await cache.getUsernameAndFaceFromUID(ctx, uid);
+ const [userName, face] = await cacheIn.getUsernameAndFaceFromUID(ctx, 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, {
diff --git a/lib/v2/bilibili/vsearch.js b/lib/v2/bilibili/vsearch.js
index ba0cc6976..05f08504c 100644
--- a/lib/v2/bilibili/vsearch.js
+++ b/lib/v2/bilibili/vsearch.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const kw_url = encodeURIComponent(kw);
const tids = ctx.req.param('tid') ?? 0;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`bilibili:vsearch:${tids}:${kw}:${order}`,
async () => {
await got('https://passport.bilibili.com/login', {
diff --git a/lib/v2/biodiscover/index.js b/lib/v2/biodiscover/index.js
index 8eb54223f..53fd0d5c7 100644
--- a/lib/v2/biodiscover/index.js
+++ b/lib/v2/biodiscover/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
description: $('meta[name=description]').attr('content'),
item: await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({ url: item.link });
const $ = load(detailResponse.data);
diff --git a/lib/v2/bioone/featured.js b/lib/v2/bioone/featured.js
index 4d17bd6bd..b76c09255 100644
--- a/lib/v2/bioone/featured.js
+++ b/lib/v2/bioone/featured.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
https: {
rejectUnauthorized: false,
diff --git a/lib/v2/bioone/journal.js b/lib/v2/bioone/journal.js
index 5035aeb85..bbe809bb1 100644
--- a/lib/v2/bioone/journal.js
+++ b/lib/v2/bioone/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
https: {
rejectUnauthorized: false,
diff --git a/lib/v2/biquge/index.js b/lib/v2/biquge/index.js
index 4cb61217a..87b869b7b 100644
--- a/lib/v2/biquge/index.js
+++ b/lib/v2/biquge/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -72,7 +73,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bjfu/grs.js b/lib/v2/bjfu/grs.js
index 9eafd7996..7c0e687fc 100644
--- a/lib/v2/bjfu/grs.js
+++ b/lib/v2/bjfu/grs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const itemReponse = await got.get(item.link);
const data = itemReponse.data;
const itemElement = load(data);
diff --git a/lib/v2/bjfu/kjc.js b/lib/v2/bjfu/kjc.js
index 6b2460469..70c0daf3a 100644
--- a/lib/v2/bjfu/kjc.js
+++ b/lib/v2/bjfu/kjc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const itemReponse = await got.get(item.link);
const data = itemReponse.data;
const itemElement = load(data);
diff --git a/lib/v2/bjp/apod.js b/lib/v2/bjp/apod.js
index 5745bd740..1fe5601b8 100644
--- a/lib/v2/bjp/apod.js
+++ b/lib/v2/bjp/apod.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((e) =>
- ctx.cache.tryGet(e.link, async () => {
+ cache.tryGet(e.link, async () => {
const { data } = await got.get(e.link);
const $ = load(data);
diff --git a/lib/v2/bjsk/index.js b/lib/v2/bjsk/index.js
index 0a96604e6..a742a4eae 100644
--- a/lib/v2/bjsk/index.js
+++ b/lib/v2/bjsk/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
https: {
rejectUnauthorized: false,
diff --git a/lib/v2/bjsk/keti.js b/lib/v2/bjsk/keti.js
index 55623849c..3147c21e2 100644
--- a/lib/v2/bjsk/keti.js
+++ b/lib/v2/bjsk/keti.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bjwxdxh/index.js b/lib/v2/bjwxdxh/index.js
index f2109aa53..5d7dc35d6 100644
--- a/lib/v2/bjwxdxh/index.js
+++ b/lib/v2/bjwxdxh/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bjx/huanbao.js b/lib/v2/bjx/huanbao.js
index 7fe2664a8..2f98821c0 100644
--- a/lib/v2/bjx/huanbao.js
+++ b/lib/v2/bjx/huanbao.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
};
const fetchPage = (ctx, link) =>
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
// 可能一篇文章过长会分成多页
const pages = [];
diff --git a/lib/v2/blizzard/news.js b/lib/v2/blizzard/news.js
index 9d476b286..02b19006e 100644
--- a/lib/v2/blizzard/news.js
+++ b/lib/v2/blizzard/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/bloomberg/utils.js b/lib/v2/bloomberg/utils.js
index d2db21389..e831a2224 100644
--- a/lib/v2/bloomberg/utils.js
+++ b/lib/v2/bloomberg/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
const path = require('path');
const asyncPool = require('tiny-async-pool');
@@ -78,8 +79,8 @@ const parseNewsList = async (url, ctx) => {
});
};
-const parseArticle = (item, ctx) =>
- ctx.cache.tryGet(item.link, async () => {
+const parseArticle = (item) =>
+ cache.tryGet(item.link, async () => {
const group = regex
.map((r) => r.exec(item.link))
.filter((e) => e && e.groups)
diff --git a/lib/v2/bluestacks/release.js b/lib/v2/bluestacks/release.js
index a1b928dca..b9f9e6aec 100644
--- a/lib/v2/bluestacks/release.js
+++ b/lib/v2/bluestacks/release.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const cherrio = require('cheerio');
import { parseDate } from '@/utils/parse-date';
import puppeteer from '@/utils/puppeteer';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
diff --git a/lib/v2/bmkg/news.js b/lib/v2/bmkg/news.js
index c769fbf09..b43b54d78 100644
--- a/lib/v2/bmkg/news.js
+++ b/lib/v2/bmkg/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
const p = $('div .blog-grid').find('p');
diff --git a/lib/v2/bnu/bs.js b/lib/v2/bnu/bs.js
index 697af9224..c50ebe38c 100644
--- a/lib/v2/bnu/bs.js
+++ b/lib/v2/bnu/bs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/bnu/dwxgb.js b/lib/v2/bnu/dwxgb.js
index 794b836f5..4324b146d 100644
--- a/lib/v2/bnu/dwxgb.js
+++ b/lib/v2/bnu/dwxgb.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
item.description = content('div.article.typo').html();
diff --git a/lib/v2/bnu/fdy.js b/lib/v2/bnu/fdy.js
index 1c8545e33..a068d751b 100644
--- a/lib/v2/bnu/fdy.js
+++ b/lib/v2/bnu/fdy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('.listconrc-newszw').html();
diff --git a/lib/v2/bnu/lib.js b/lib/v2/bnu/lib.js
index 40fac5647..b49223e59 100644
--- a/lib/v2/bnu/lib.js
+++ b/lib/v2/bnu/lib.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('#block-system-main .content .content').html();
diff --git a/lib/v2/bossdesign/index.js b/lib/v2/bossdesign/index.js
index 78c105479..dfc54ee07 100644
--- a/lib/v2/bossdesign/index.js
+++ b/lib/v2/bossdesign/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -6,7 +7,7 @@ module.exports = async (ctx) => {
const limit = Number.parseInt(ctx.req.query('limit'), 10) || undefined;
const baseUrl = 'https://www.bossdesign.cn';
- const currentCategory = await ctx.cache.tryGet(`bossdesign:categories:${category}`, async () => {
+ const currentCategory = await cache.tryGet(`bossdesign:categories:${category}`, async () => {
const { data: categories } = await got(`${baseUrl}/wp-json/wp/v2/categories`);
return categories.find((item) => item.slug === category || item.name === category);
});
diff --git a/lib/v2/bsky/posts.js b/lib/v2/bsky/posts.js
index 170a6e264..c8801cefc 100644
--- a/lib/v2/bsky/posts.js
+++ b/lib/v2/bsky/posts.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
const { resolveHandle, getProfile, getAuthorFeed } = require('./utils');
import { art } from '@/utils/render';
@@ -5,9 +6,9 @@ const path = require('path');
module.exports = async (ctx) => {
const { handle } = ctx.params;
- const DID = await resolveHandle(handle, ctx.cache.tryGet);
- const profile = await getProfile(DID, ctx.cache.tryGet);
- const authorFeed = await getAuthorFeed(DID, ctx.cache.tryGet);
+ const DID = await resolveHandle(handle, cache.tryGet);
+ const profile = await getProfile(DID, cache.tryGet);
+ const authorFeed = await getAuthorFeed(DID, cache.tryGet);
const items = authorFeed.feed.map(({ post }) => ({
title: post.record.text.split('\n')[0],
diff --git a/lib/v2/btzj/index.js b/lib/v2/btzj/index.js
index a7f431eb7..903181bcb 100644
--- a/lib/v2/btzj/index.js
+++ b/lib/v2/btzj/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/buaa/news/index.js b/lib/v2/buaa/news/index.js
index 6540e56d1..1cca858a2 100644
--- a/lib/v2/buaa/news/index.js
+++ b/lib/v2/buaa/news/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/buaa/sme.js b/lib/v2/buaa/sme.js
index 08bbebd39..e9148e66f 100755
--- a/lib/v2/buaa/sme.js
+++ b/lib/v2/buaa/sme.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -48,7 +49,7 @@ async function getList(url) {
function getItems(ctx, list) {
return Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: descrptionResponse } = await got(item.link);
const $descrption = load(descrptionResponse);
item.description = $descrption('div[class="v_news_content"]').html();
diff --git a/lib/v2/bupt/rczp.js b/lib/v2/bupt/rczp.js
index aea8cc39b..fb63984e6 100644
--- a/lib/v2/bupt/rczp.js
+++ b/lib/v2/bupt/rczp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/c114/roll.js b/lib/v2/c114/roll.js
index 2d8fe2cf8..c5064c5f3 100644
--- a/lib/v2/c114/roll.js
+++ b/lib/v2/c114/roll.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/caam/index.js b/lib/v2/caam/index.js
index 67d872450..891f023f5 100644
--- a/lib/v2/caam/index.js
+++ b/lib/v2/caam/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/caareviews/utils.js b/lib/v2/caareviews/utils.js
index 6ee198e7d..55bacce8e 100644
--- a/lib/v2/caareviews/utils.js
+++ b/lib/v2/caareviews/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ const getList = async (url) => {
const getItems = (ctx, list) =>
Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/cahkms/index.js b/lib/v2/cahkms/index.js
index 5909287ae..89207862a 100644
--- a/lib/v2/cahkms/index.js
+++ b/lib/v2/cahkms/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/caijing/roll.js b/lib/v2/caijing/roll.js
index ed92f1ebb..41c731191 100644
--- a/lib/v2/caijing/roll.js
+++ b/lib/v2/caijing/roll.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.author = $('.editor').text().trim() || $('#editor_baidu').text().trim().replaceAll(/[()]/g, '');
diff --git a/lib/v2/caixin/article.js b/lib/v2/caixin/article.js
index 4eb4d16f5..2b195e176 100644
--- a/lib/v2/caixin/article.js
+++ b/lib/v2/caixin/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { parseArticle } = require('./utils');
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
audio_image_url: item.audio_image_url,
}));
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: '财新网 - 首页',
diff --git a/lib/v2/caixin/blog.js b/lib/v2/caixin/blog.js
index 1ebe775b9..9bd9e4277 100644
--- a/lib/v2/caixin/blog.js
+++ b/lib/v2/caixin/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { isValidHost } = require('@/utils/valid-host');
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.publishTime, 'x'),
}));
- const items = await Promise.all(posts.map((item) => parseBlogArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(posts.map((item) => parseBlogArticle(item, cache.tryGet)));
ctx.state.data = {
title: `财新博客 - ${authorName}`,
@@ -68,7 +69,7 @@ module.exports = async (ctx) => {
link: item.postUrl.replace('http://', 'https://'),
pubDate: parseDate(item.publishTime, 'x'),
}));
- const items = await Promise.all(posts.map((item) => parseBlogArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(posts.map((item) => parseBlogArticle(item, cache.tryGet)));
ctx.state.data = {
title: `财新博客 - 全部`,
diff --git a/lib/v2/caixin/category.js b/lib/v2/caixin/category.js
index cc3af053d..a26c16e2c 100644
--- a/lib/v2/caixin/category.js
+++ b/lib/v2/caixin/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { isValidHost } = require('@/utils/valid-host');
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
audio_image_url: item.pict.imgs[0].url,
}));
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title,
diff --git a/lib/v2/caixin/database.js b/lib/v2/caixin/database.js
index bed20fc6c..4543a6ddc 100644
--- a/lib/v2/caixin/database.js
+++ b/lib/v2/caixin/database.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/caixin/latest.js b/lib/v2/caixin/latest.js
index c65425a0f..8e5a30f5f 100644
--- a/lib/v2/caixin/latest.js
+++ b/lib/v2/caixin/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const rss = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(`caixin:latest:${item.link}`, async () => {
+ cache.tryGet(`caixin:latest:${item.link}`, async () => {
const entry_r = await got(item.link);
const $ = load(entry_r.data);
diff --git a/lib/v2/caixin/weekly.js b/lib/v2/caixin/weekly.js
index 4f310d635..82182fc0f 100644
--- a/lib/v2/caixin/weekly.js
+++ b/lib/v2/caixin/weekly.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/caixinglobal/latest.js b/lib/v2/caixinglobal/latest.js
index 1b7dea722..c596a72f7 100644
--- a/lib/v2/caixinglobal/latest.js
+++ b/lib/v2/caixinglobal/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
$('.loadingBox, .cons-pay-tip').remove();
diff --git a/lib/v2/camchina/index.js b/lib/v2/camchina/index.js
index 2e49d40d8..31b19352c 100644
--- a/lib/v2/camchina/index.js
+++ b/lib/v2/camchina/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cankaoxiaoxi/index.js b/lib/v2/cankaoxiaoxi/index.js
index 9b616c5d3..6b46fb532 100644
--- a/lib/v2/cankaoxiaoxi/index.js
+++ b/lib/v2/cankaoxiaoxi/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.video) {
item.description = art(path.join(__dirname, 'templates/description.art'), {
video: item.video,
diff --git a/lib/v2/cartoonmad/comic.js b/lib/v2/cartoonmad/comic.js
index b99f69483..f51ff00a1 100644
--- a/lib/v2/cartoonmad/comic.js
+++ b/lib/v2/cartoonmad/comic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
const iconv = require('iconv-lite');
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
})
.reverse();
- const chapters = await getChapters(id, list, ctx.cache.tryGet);
+ const chapters = await getChapters(id, list, cache.tryGet);
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/cas/cg/index.js b/lib/v2/cas/cg/index.js
index 4234bd4b3..40d1ad88a 100644
--- a/lib/v2/cas/cg/index.js
+++ b/lib/v2/cas/cg/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cas/iee/kydt.js b/lib/v2/cas/iee/kydt.js
index 0070b6cc3..1969245b1 100644
--- a/lib/v2/cas/iee/kydt.js
+++ b/lib/v2/cas/iee/kydt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cas/is/index.js b/lib/v2/cas/is/index.js
index 415050b59..1eb5726bd 100644
--- a/lib/v2/cas/is/index.js
+++ b/lib/v2/cas/is/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.startsWith(`${baseUrl}/`)) {
return item;
}
diff --git a/lib/v2/cas/mesalab/kb.js b/lib/v2/cas/mesalab/kb.js
index a11a2cc63..30e6bfc80 100644
--- a/lib/v2/cas/mesalab/kb.js
+++ b/lib/v2/cas/mesalab/kb.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const cherrio = require('cheerio');
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const title = a.text().trim();
const link = `${homepage}${a.attr('href')}`;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const result = await got(link);
const $ = cherrio.load(result.data);
return {
diff --git a/lib/v2/cas/sim/kyjz.js b/lib/v2/cas/sim/kyjz.js
index 58865e5c6..df0359ddf 100644
--- a/lib/v2/cas/sim/kyjz.js
+++ b/lib/v2/cas/sim/kyjz.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/cast/index.js b/lib/v2/cast/index.js
index 998ff42ad..de8005813 100644
--- a/lib/v2/cast/index.js
+++ b/lib/v2/cast/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
},
});
- const pageTitle = await ctx.cache.tryGet(link, async () => {
+ const pageTitle = await cache.tryGet(link, async () => {
const { data: response } = await got(link);
const $ = load(response);
return $('head title').text();
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/caus/index.js b/lib/v2/caus/index.js
index 369d362c3..6389b9fe3 100644
--- a/lib/v2/caus/index.js
+++ b/lib/v2/caus/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const categories = {
@@ -67,7 +68,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: `${apiRootUrl}/toronto/display/contentWithRelate?contentId=${item.contentId}`,
diff --git a/lib/v2/cbc/topics.js b/lib/v2/cbc/topics.js
index af892b455..5bf78c0f8 100644
--- a/lib/v2/cbc/topics.js
+++ b/lib/v2/cbc/topics.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
links.map((link) =>
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
const result = await got(link);
const $ = load(result.data);
diff --git a/lib/v2/cbirc/index.js b/lib/v2/cbirc/index.js
index b7304f20f..7102dee13 100644
--- a/lib/v2/cbirc/index.js
+++ b/lib/v2/cbirc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const categories = {
@@ -82,7 +83,7 @@ module.exports = async (ctx) => {
const cat = categories[category];
// 请求集合
- const response = await ctx.cache.tryGet(cat.link, async () => {
+ const response = await cache.tryGet(cat.link, async () => {
const resp = await got({
method: 'get',
url: cat.link,
diff --git a/lib/v2/cbnweek/index.js b/lib/v2/cbnweek/index.js
index 67200fe6e..f0c89f64f 100644
--- a/lib/v2/cbnweek/index.js
+++ b/lib/v2/cbnweek/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: `${apiRootUrl}/v4/articles/${item.guid}`,
diff --git a/lib/v2/ccac/news.js b/lib/v2/ccac/news.js
index 121ac8a10..ee77d4129 100644
--- a/lib/v2/ccac/news.js
+++ b/lib/v2/ccac/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ccf/ccfcv/index.js b/lib/v2/ccf/ccfcv/index.js
index 81ad3e0f6..26fbfdab9 100644
--- a/lib/v2/ccf/ccfcv/index.js
+++ b/lib/v2/ccf/ccfcv/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
if (cate === 'xsqy') {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let detailResponse;
try {
diff --git a/lib/v2/ccf/news.js b/lib/v2/ccf/news.js
index 9a191d903..d5f332d29 100644
--- a/lib/v2/ccf/news.js
+++ b/lib/v2/ccf/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/ccreports/index.js b/lib/v2/ccreports/index.js
index 3dd8e58c3..d0b4a46d8 100644
--- a/lib/v2/ccreports/index.js
+++ b/lib/v2/ccreports/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailData = await got.get(item.link);
const $ = load(detailData.data);
item.description = $('div.pdbox').html();
diff --git a/lib/v2/cctv/jx.js b/lib/v2/cctv/jx.js
index 8670cbfe0..0915cfed7 100644
--- a/lib/v2/cctv/jx.js
+++ b/lib/v2/cctv/jx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cctv/lm.js b/lib/v2/cctv/lm.js
index a7e888936..64fff4574 100644
--- a/lib/v2/cctv/lm.js
+++ b/lib/v2/cctv/lm.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cctv/utils/news.js b/lib/v2/cctv/utils/news.js
index 7a6a15d99..c72afc83c 100644
--- a/lib/v2/cctv/utils/news.js
+++ b/lib/v2/cctv/utils/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const path = require('path');
import { parseDate } from '@/utils/parse-date';
@@ -6,7 +7,7 @@ import randUserAgent from '@/utils/rand-user-agent';
const UA = randUserAgent({ browser: 'mobile safari', os: 'ios', device: 'mobile' });
-module.exports = async (category, ctx) => {
+module.exports = async (category) => {
const url = `https://news.cctv.com/2019/07/gaiban/cmsdatainterface/page/${category}_1.jsonp`;
const response = await got({
@@ -22,7 +23,7 @@ module.exports = async (category, ctx) => {
const list = data.data.list;
const resultItem = await Promise.all(
list.map(({ title, url, focus_date, image }) =>
- ctx.cache.tryGet(`cctv-news: ${url}`, async () => {
+ cache.tryGet(`cctv-news: ${url}`, async () => {
const item = {
title,
link: url,
diff --git a/lib/v2/cctv/utils/xinwen1j1.js b/lib/v2/cctv/utils/xinwen1j1.js
index e954506d4..b5531c18d 100644
--- a/lib/v2/cctv/utils/xinwen1j1.js
+++ b/lib/v2/cctv/utils/xinwen1j1.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ async function loadContent(link) {
}
// 同步 列表
-const ProcessFeed = (data, ctx) =>
+const ProcessFeed = (data) =>
Promise.all(
data.list.map(async (data) => {
const title = data.title;
@@ -46,7 +47,7 @@ const ProcessFeed = (data, ctx) =>
// 使用tryGet方法从缓存获取内容。
// 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
- const other = await ctx.cache.tryGet(itemUrl, () => loadContent(itemUrl));
+ const other = await cache.tryGet(itemUrl, () => loadContent(itemUrl));
// 合并解析后的结果集作为该篇文章最终的输出结果
return { ...single, ...other };
diff --git a/lib/v2/cctv/xwlb.js b/lib/v2/cctv/xwlb.js
index 54309185b..0868ce843 100644
--- a/lib/v2/cctv/xwlb.js
+++ b/lib/v2/cctv/xwlb.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
title: `新闻联播 ${newsDate.format('YYYY/MM/DD')}`,
link: url,
pubDate: timezone(parseDate(newsDate), +8),
- description: await ctx.cache.tryGet(url, async () => {
+ description: await cache.tryGet(url, async () => {
const res = await got(url);
const content = load(res.data);
const list = [];
diff --git a/lib/v2/cde/index.js b/lib/v2/cde/index.js
index 080b0f26c..27109efe5 100644
--- a/lib/v2/cde/index.js
+++ b/lib/v2/cde/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const utils = require('./utils');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -103,7 +104,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
cookie: await utils.getCookie(ctx),
diff --git a/lib/v2/cde/utils.js b/lib/v2/cde/utils.js
index 5271c0378..92bc92a06 100644
--- a/lib/v2/cde/utils.js
+++ b/lib/v2/cde/utils.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const title = '国家药品监督管理局药品审评中心';
const rootUrl = 'https://www.cde.org.cn';
-const getCookie = (ctx) =>
- ctx.cache.tryGet('cde:cookie', async () => {
+const getCookie = () =>
+ cache.tryGet('cde:cookie', async () => {
const response = await got(rootUrl);
return response.headers['set-cookie']
diff --git a/lib/v2/cde/zdyz.js b/lib/v2/cde/zdyz.js
index fbc5ef856..c2860c828 100644
--- a/lib/v2/cde/zdyz.js
+++ b/lib/v2/cde/zdyz.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -55,7 +56,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link, {
headers: {
referer: zdyzMap.zdyz[category].url,
diff --git a/lib/v2/cdi/index.js b/lib/v2/cdi/index.js
index 30d4841f7..b2426f422 100644
--- a/lib/v2/cdi/index.js
+++ b/lib/v2/cdi/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cdzjryb/project-list.js b/lib/v2/cdzjryb/project-list.js
index 993979a65..a49191182 100644
--- a/lib/v2/cdzjryb/project-list.js
+++ b/lib/v2/cdzjryb/project-list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(`cdzjryb:zw:projectList${item[0]}`, async () => {
+ cache.tryGet(`cdzjryb:zw:projectList${item[0]}`, async () => {
const { data: notice } = await got.post('https://zw.cdzjryb.com/lottery/accept/getProjectRule', {
form: {
projectUuid: item[0],
diff --git a/lib/v2/cfmmc/index.js b/lib/v2/cfmmc/index.js
index 1df20e32b..5c05bfee6 100644
--- a/lib/v2/cfmmc/index.js
+++ b/lib/v2/cfmmc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/chaincatcher/home.js b/lib/v2/chaincatcher/home.js
index 9c24d12fa..7650346ca 100644
--- a/lib/v2/chaincatcher/home.js
+++ b/lib/v2/chaincatcher/home.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.categoryId !== 3) {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/changba/user.js b/lib/v2/changba/user.js
index d115f94a6..62a39e7e6 100644
--- a/lib/v2/changba/user.js
+++ b/lib/v2/changba/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
list.map(async (item) => {
const $ = load(item);
const link = $('a').attr('href');
- const songid = await ctx.cache.tryGet(
+ const songid = await cache.tryGet(
link,
async () => {
const result = await got({
diff --git a/lib/v2/chaoxing/qk.js b/lib/v2/chaoxing/qk.js
index bbe0b2941..a55c120bd 100644
--- a/lib/v2/chaoxing/qk.js
+++ b/lib/v2/chaoxing/qk.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (needContent) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/chaping/banner.js b/lib/v2/chaping/banner.js
index 1c3a741a9..6b4742116 100644
--- a/lib/v2/chaping/banner.js
+++ b/lib/v2/chaping/banner.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
bannerList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/chaping/news.js b/lib/v2/chaping/news.js
index c1e6365d2..20e39afb2 100644
--- a/lib/v2/chaping/news.js
+++ b/lib/v2/chaping/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/chiculture/topic.js b/lib/v2/chiculture/topic.js
index 949a07fec..9b0d40b77 100644
--- a/lib/v2/chiculture/topic.js
+++ b/lib/v2/chiculture/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/china/finance/finance.js b/lib/v2/china/finance/finance.js
index 821c57614..e7e31b425 100644
--- a/lib/v2/china/finance/finance.js
+++ b/lib/v2/china/finance/finance.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
detailsUrls.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailsResponse = await got(item.link);
const $d = load(detailsResponse.data);
return {
diff --git a/lib/v2/chinadegrees/province.js b/lib/v2/chinadegrees/province.js
index 194b7d565..fdb62f801 100644
--- a/lib/v2/chinadegrees/province.js
+++ b/lib/v2/chinadegrees/province.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const { province = '11' } = ctx.params;
const url = `${baseUrl}/help/unitSwqk${province}.html`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
url,
async () => {
const browser = puppeteer();
diff --git a/lib/v2/chinafactcheck/index.js b/lib/v2/chinafactcheck/index.js
index 396703869..23b388684 100644
--- a/lib/v2/chinafactcheck/index.js
+++ b/lib/v2/chinafactcheck/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const utils = require('./utils');
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const articles = await Promise.all(
articlesLink.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { title, author, pubDate, description, category } = await utils.getArticleDetail(item.link);
item.title = title;
diff --git a/lib/v2/chinaisa/index.js b/lib/v2/chinaisa/index.js
index ef1513f23..597e33e6b 100644
--- a/lib/v2/chinaisa/index.js
+++ b/lib/v2/chinaisa/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got.post(apiArticleUrl, {
form: {
params: encodeURI(`{"articleId":"${item.guid}","columnId":"${id}"}`),
diff --git a/lib/v2/chinamoney/notice.js b/lib/v2/chinamoney/notice.js
index c7b1457de..cef5eb706 100644
--- a/lib/v2/chinamoney/notice.js
+++ b/lib/v2/chinamoney/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/chinanews/index.js b/lib/v2/chinanews/index.js
index 4c2f35cff..78af74c06 100644
--- a/lib/v2/chinanews/index.js
+++ b/lib/v2/chinanews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/chinathinktanks/viewpoint.js b/lib/v2/chinathinktanks/viewpoint.js
index b51910ac9..7d43c65b8 100644
--- a/lib/v2/chinathinktanks/viewpoint.js
+++ b/lib/v2/chinathinktanks/viewpoint.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
url: item.link,
cookieJar,
diff --git a/lib/v2/chinaventure/index.js b/lib/v2/chinaventure/index.js
index 6028d9a75..70d878216 100644
--- a/lib/v2/chinaventure/index.js
+++ b/lib/v2/chinaventure/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/chinawriter/index.js b/lib/v2/chinawriter/index.js
index 423ed17e1..973895eb5 100644
--- a/lib/v2/chinawriter/index.js
+++ b/lib/v2/chinawriter/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/chsi/hotnews.js b/lib/v2/chsi/hotnews.js
index e6e3e2e4c..a63eff722 100644
--- a/lib/v2/chsi/hotnews.js
+++ b/lib/v2/chsi/hotnews.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const { href: path, title: itemTitle } = item.attribs;
let itemUrl = '';
itemUrl = path.startsWith('http') ? path : host + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
let itemDate;
if (path) {
diff --git a/lib/v2/chsi/kydt.js b/lib/v2/chsi/kydt.js
index 0580d466a..80bf1c2c9 100644
--- a/lib/v2/chsi/kydt.js
+++ b/lib/v2/chsi/kydt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const itemDate = item.find('.span-time').text();
const path = item.find('a').attr('href');
const itemUrl = path.startsWith('http') ? path : host + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
if (!path.startsWith('https://') && !path.startsWith('http://')) {
const result = await got(itemUrl);
diff --git a/lib/v2/chsi/kyzx.js b/lib/v2/chsi/kyzx.js
index 05e6ab602..60b03d91f 100644
--- a/lib/v2/chsi/kyzx.js
+++ b/lib/v2/chsi/kyzx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const path = item.find('a').attr('href');
let itemUrl = '';
itemUrl = path.startsWith('http') ? path : host + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
if (itemUrl) {
const result = await got(itemUrl);
diff --git a/lib/v2/cib/whpj.js b/lib/v2/cib/whpj.js
index dfa2fe9ae..2da9b3428 100644
--- a/lib/v2/cib/whpj.js
+++ b/lib/v2/cib/whpj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
date = date.substring(0, 11) + date.substring(15);
const link = 'https://personalbank.cib.com.cn/pers/main/pubinfo/ifxQuotationQuery/list?_search=false&dataSet.rows=80&dataSet.page=1&dataSet.sidx=&dataSet.sord=asc';
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
link,
async () => {
const detailResponse = await got(link, {
diff --git a/lib/v2/ciidbnu/index.js b/lib/v2/ciidbnu/index.js
index dc7feaf12..224a76766 100644
--- a/lib/v2/ciidbnu/index.js
+++ b/lib/v2/ciidbnu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/clickme/index.js b/lib/v2/clickme/index.js
index dd547142e..49d4978b2 100644
--- a/lib/v2/clickme/index.js
+++ b/lib/v2/clickme/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got.get(item.link);
const $ = load(data);
item.description = $('.article-detail-content').html();
diff --git a/lib/v2/cls/depth.js b/lib/v2/cls/depth.js
index ba8b8634f..430bf04d8 100644
--- a/lib/v2/cls/depth.js
+++ b/lib/v2/cls/depth.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -52,7 +53,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cls/hot.js b/lib/v2/cls/hot.js
index 0a01b122c..c9c2c2807 100644
--- a/lib/v2/cls/hot.js
+++ b/lib/v2/cls/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cmde/index.js b/lib/v2/cmde/index.js
index 3a5ab1504..49bfdf49e 100644
--- a/lib/v2/cmde/index.js
+++ b/lib/v2/cmde/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const cate = ctx.req.param('cate') ?? 'xwdt/zxyw';
const url = `${rootURL}/${cate}/`;
const browser = puppeteer({ stealth: true });
- const data = await ctx.cache.tryGet(url, async () => {
+ const data = await cache.tryGet(url, async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
diff --git a/lib/v2/cmpxchg8b/articles.js b/lib/v2/cmpxchg8b/articles.js
index 9a304281d..a7252a003 100644
--- a/lib/v2/cmpxchg8b/articles.js
+++ b/lib/v2/cmpxchg8b/articles.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/cna/index.js b/lib/v2/cna/index.js
index 50652fd8a..f628a642a 100644
--- a/lib/v2/cna/index.js
+++ b/lib/v2/cna/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cna/web/index.js b/lib/v2/cna/web/index.js
index ff7f683b7..1723179ba 100644
--- a/lib/v2/cna/web/index.js
+++ b/lib/v2/cna/web/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cnbc/rss.js b/lib/v2/cnbc/rss.js
index 0eea5dc8b..8bfb7b336 100644
--- a/lib/v2/cnbc/rss.js
+++ b/lib/v2/cnbc/rss.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const parser = require('@/utils/rss-parser');
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
feed.items
.filter((i) => i.link && !i.link.startsWith('https://www.cnbc.com/select/'))
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/cnbeta/type.js b/lib/v2/cnbeta/type.js
index c19bbb586..7d589f914 100644
--- a/lib/v2/cnbeta/type.js
+++ b/lib/v2/cnbeta/type.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -37,6 +38,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: $('title').text(),
link: currentUrl,
- item: await ProcessItems(items, ctx.req.query('limit'), ctx.cache.tryGet),
+ item: await ProcessItems(items, ctx.req.query('limit'), cache.tryGet),
});
};
diff --git a/lib/v2/cncf/index.js b/lib/v2/cncf/index.js
index 6c27c9242..6a5036591 100644
--- a/lib/v2/cncf/index.js
+++ b/lib/v2/cncf/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/cncf/reports.js b/lib/v2/cncf/reports.js
index a291f4f0f..d825dbbcd 100644
--- a/lib/v2/cncf/reports.js
+++ b/lib/v2/cncf/reports.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/cneb/yjxw.js b/lib/v2/cneb/yjxw.js
index 4a2ad7c7c..6a69ed1e3 100644
--- a/lib/v2/cneb/yjxw.js
+++ b/lib/v2/cneb/yjxw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -48,7 +49,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cnjxol/index.js b/lib/v2/cnjxol/index.js
index e911386e8..3b96116e6 100644
--- a/lib/v2/cnjxol/index.js
+++ b/lib/v2/cnjxol/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -68,7 +69,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item, async () => {
+ cache.tryGet(item, async () => {
const detailResponse = await got({
method: 'get',
url: item,
diff --git a/lib/v2/cnki/author.js b/lib/v2/cnki/author.js
index c0a09debe..3e7ba5a21 100644
--- a/lib/v2/cnki/author.js
+++ b/lib/v2/cnki/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => utils.ProcessItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => utils.ProcessItem(item))));
ctx.set('data', {
title: `知网 ${authorName} ${companyName}`,
diff --git a/lib/v2/cnki/debut.js b/lib/v2/cnki/debut.js
index 7347c5f64..de201b3ea 100644
--- a/lib/v2/cnki/debut.js
+++ b/lib/v2/cnki/debut.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const $ = load(detailResponse.data);
item.description = art(path.join(__dirname, 'templates/desc.art'), {
diff --git a/lib/v2/cnki/journals.js b/lib/v2/cnki/journals.js
index 9bfe4a142..b07872f7d 100644
--- a/lib/v2/cnki/journals.js
+++ b/lib/v2/cnki/journals.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
})
.get();
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => ProcessItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => ProcessItem(item))));
ctx.set('data', {
title: String(title),
diff --git a/lib/v2/cnljxh/index.js b/lib/v2/cnljxh/index.js
index fc05fa6e8..6b25c3fb9 100644
--- a/lib/v2/cnljxh/index.js
+++ b/lib/v2/cnljxh/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/cntheory/paper.js b/lib/v2/cntheory/paper.js
index 64d0f8a54..69348fb1e 100644
--- a/lib/v2/cntheory/paper.js
+++ b/lib/v2/cntheory/paper.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -51,7 +52,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item, async () => {
+ cache.tryGet(item, async () => {
const detailResponse = await got({
method: 'get',
url: item,
diff --git a/lib/v2/comicat/search.js b/lib/v2/comicat/search.js
index 35900b7aa..23d19cc9b 100644
--- a/lib/v2/comicat/search.js
+++ b/lib/v2/comicat/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/comicskingdom/index.js b/lib/v2/comicskingdom/index.js
index 72410d4e3..b9cea14c6 100644
--- a/lib/v2/comicskingdom/index.js
+++ b/lib/v2/comicskingdom/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
}
const items = await Promise.all(
links.map((link) =>
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
const detailResponse = await got(link);
const content = load(detailResponse.data);
diff --git a/lib/v2/consumer/index.js b/lib/v2/consumer/index.js
index e6d002c91..35468b07f 100644
--- a/lib/v2/consumer/index.js
+++ b/lib/v2/consumer/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/consumer/shopping-guide.js b/lib/v2/consumer/shopping-guide.js
index 528dd35d7..38cd74315 100644
--- a/lib/v2/consumer/shopping-guide.js
+++ b/lib/v2/consumer/shopping-guide.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/cool18/index.js b/lib/v2/cool18/index.js
index 07cc464b6..beba4f3fe 100644
--- a/lib/v2/cool18/index.js
+++ b/lib/v2/cool18/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/coolapk/utils.js b/lib/v2/coolapk/utils.js
index 568cad9a9..4e968d1b2 100644
--- a/lib/v2/coolapk/utils.js
+++ b/lib/v2/coolapk/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import md5 from '@/utils/md5';
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -55,7 +56,7 @@ const parseTuwenFromRaw = (raw) =>
}
});
-const parseDynamic = async (item, ctx) => {
+const parseDynamic = async (item) => {
const pubDate = parseDate(item.dateline, 'X');
if (item.entityType === 'sponsorCard' || item.shareUrl === undefined) {
return;
@@ -78,7 +79,7 @@ const parseDynamic = async (item, ctx) => {
// //////////////////////////////////////////// 基本内容 ////////////////////////////////////////////
if (item.issummary) {
// 需要爬内容
- description = await ctx.cache.tryGet(itemUrl, async () => {
+ description = await cache.tryGet(itemUrl, async () => {
const result = await got(itemUrl, {
headers: getHeaders(),
});
@@ -111,7 +112,7 @@ const parseDynamic = async (item, ctx) => {
}
case 12:
title = item.title;
- description = await ctx.cache.tryGet(itemUrl, async () => {
+ description = await cache.tryGet(itemUrl, async () => {
const result = await got(itemUrl, {
headers: getHeaders(),
});
diff --git a/lib/v2/coomer/utils.js b/lib/v2/coomer/utils.js
index 23e88fe98..363b4182c 100644
--- a/lib/v2/coomer/utils.js
+++ b/lib/v2/coomer/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx, currentUrl) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/copymanga/comic.js b/lib/v2/copymanga/comic.js
index 8a24a81f0..d2f3eca5b 100644
--- a/lib/v2/copymanga/comic.js
+++ b/lib/v2/copymanga/comic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const strBaseUrl = `${apiBaseUrl}/api/v3/comic/${id}/group/default/chapters`;
const iReqLimit = 500;
// 获取漫画列表
- const chapterArray = await ctx.cache.tryGet(
+ const chapterArray = await cache.tryGet(
strBaseUrl,
async () => {
let bHasNextPage = false;
@@ -69,7 +70,7 @@ module.exports = async (ctx) => {
);
// 获取漫画标题、介绍
- const { bookTitle, bookIntro } = await ctx.cache.tryGet(`${baseUrl}/comic/${id}`, async () => {
+ const { bookTitle, bookIntro } = await cache.tryGet(`${baseUrl}/comic/${id}`, async () => {
const { data } = await got(`${baseUrl}/comic/${id}`);
const $ = load(data);
return {
@@ -111,7 +112,7 @@ module.exports = async (ctx) => {
return results;
};
- const result = await asyncPoolAll(3, chapterArray.slice(0, chapterCnt), (chapter) => ctx.cache.tryGet(chapter.link, () => genResult(chapter)));
+ const result = await asyncPoolAll(3, chapterArray.slice(0, chapterCnt), (chapter) => cache.tryGet(chapter.link, () => genResult(chapter)));
const items = [...result, ...chapterArray.slice(chapterCnt)];
ctx.set('data', {
diff --git a/lib/v2/cpcey/index.js b/lib/v2/cpcey/index.js
index 2e687dbbd..48614260a 100644
--- a/lib/v2/cpcey/index.js
+++ b/lib/v2/cpcey/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
let desc = '';
const isOtherWebPage = !item.link.includes('.html');
if (isOtherWebPage) {
- desc = await ctx.cache.tryGet(item.link, async () => {
+ desc = await cache.tryGet(item.link, async () => {
const response = await got.get(item.link);
const $ = load(response.data);
const desc = $('div.words > div.graybg.ail > div').html();
diff --git a/lib/v2/cqgas/tqtz.js b/lib/v2/cqgas/tqtz.js
index 0d8bca4b2..6551c4e30 100644
--- a/lib/v2/cqgas/tqtz.js
+++ b/lib/v2/cqgas/tqtz.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('body > div').first().html();
diff --git a/lib/v2/cqwu/index.js b/lib/v2/cqwu/index.js
index 1d870c891..81dd31b33 100644
--- a/lib/v2/cqwu/index.js
+++ b/lib/v2/cqwu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (i, item) => {
const pageUrl = host + $(item).find('a').attr('href');
- const { desc, pubDate } = await ctx.cache.tryGet(pageUrl, async () => {
+ const { desc, pubDate } = await cache.tryGet(pageUrl, async () => {
const page = await got.get(pageUrl);
const $ = load(page.data);
return {
diff --git a/lib/v2/crac/index.js b/lib/v2/crac/index.js
index 651d54e20..82329f33b 100644
--- a/lib/v2/crac/index.js
+++ b/lib/v2/crac/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/creative-comic/book.js b/lib/v2/creative-comic/book.js
index 0a9995816..eae697dae 100644
--- a/lib/v2/creative-comic/book.js
+++ b/lib/v2/creative-comic/book.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
const path = require('path');
@@ -5,7 +6,7 @@ const { getUuid, getBook, getChapter, getChapters, getImgEncrypted, getImgKey, d
module.exports = async (ctx) => {
const { id, coverOnly = 'true', quality = '1' } = ctx.params;
- const uuid = await getUuid(ctx.cache.tryGet);
+ const uuid = await getUuid(cache.tryGet);
const {
data: { data: book },
} = await getBook(id, uuid);
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const realKey = getRealKey(imgKey);
const encrypted = await getImgEncrypted(p.id, quality);
- return ctx.cache.tryGet(`${siteHost}/fs/chapter_content/encrypt/${p.id}/${quality}`, () => decrypt(encrypted, realKey));
+ return cache.tryGet(`${siteHost}/fs/chapter_content/encrypt/${p.id}/${quality}`, () => decrypt(encrypted, realKey));
})
);
}
diff --git a/lib/v2/cs/index.js b/lib/v2/cs/index.js
index d3c7dc87c..e4f1715db 100644
--- a/lib/v2/cs/index.js
+++ b/lib/v2/cs/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
diff --git a/lib/v2/csdn/blog.js b/lib/v2/csdn/blog.js
index 085e78819..a857e6af0 100644
--- a/lib/v2/csdn/blog.js
+++ b/lib/v2/csdn/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const rssParser = require('@/utils/rss-parser');
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/cste/index.js b/lib/v2/cste/index.js
index c8866d9ff..1746c3201 100644
--- a/lib/v2/cste/index.js
+++ b/lib/v2/cste/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/csu/career.js b/lib/v2/csu/career.js
index 7911201c7..5a0f986c5 100644
--- a/lib/v2/csu/career.js
+++ b/lib/v2/csu/career.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
let $ = load(response);
diff --git a/lib/v2/csu/cse.js b/lib/v2/csu/cse.js
index 064eee7e6..cf1c90e4e 100644
--- a/lib/v2/csu/cse.js
+++ b/lib/v2/csu/cse.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const address = new URL($('a').attr('href'), url).href;
const title = $('a').text();
const pubDate = $('span').text();
- return ctx.cache.tryGet(address, async () => {
+ return cache.tryGet(address, async () => {
const single = await fetch(address);
single.title = title;
single.pubDate = parseDate(pubDate, 'YYYY/MM/DD');
diff --git a/lib/v2/csu/mail.js b/lib/v2/csu/mail.js
index 78ce35886..d067e0a89 100644
--- a/lib/v2/csu/mail.js
+++ b/lib/v2/csu/mail.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
item.description = await fetch(item.link);
return item;
})
diff --git a/lib/v2/cts/news.js b/lib/v2/cts/news.js
index 9a6227d89..f5e6937eb 100644
--- a/lib/v2/cts/news.js
+++ b/lib/v2/cts/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
for await (const data of asyncPool(5, $('#newslist-top a[title]').slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20), (item) => {
item = $(item);
const link = item.attr('href');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response = await got(link);
const $ = load(response.data);
const author = $('.artical-content p:eq(0)').text().trim();
diff --git a/lib/v2/cw/utils.js b/lib/v2/cw/utils.js
index c426a7ccc..674ee3359 100644
--- a/lib/v2/cw/utils.js
+++ b/lib/v2/cw/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const { getCookies, setCookies } = require('@/utils/puppeteer-utils');
@@ -48,7 +49,7 @@ const getCookie = async (browser, tryGet) => {
const parsePage = async (path, browser, ctx) => {
const pageUrl = `${baseUrl}${pathMap[path].pageUrl(ctx.req.param('channel'))}`;
- const cookie = await getCookie(browser, ctx.cache.tryGet);
+ const cookie = await getCookie(browser, cache.tryGet);
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
@@ -65,7 +66,7 @@ const parsePage = async (path, browser, ctx) => {
const $ = load(response);
const list = parseList($, ctx.req.query('limit') ? Number(ctx.req.query('limit')) : pathMap[path].limit);
- const items = await parseItems(list, browser, ctx.cache.tryGet);
+ const items = await parseItems(list, browser, cache.tryGet);
return { $, items };
};
diff --git a/lib/v2/cyzone/author.js b/lib/v2/cyzone/author.js
index 39a847e28..b8f568912 100644
--- a/lib/v2/cyzone/author.js
+++ b/lib/v2/cyzone/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, processItems, getInfo } = require('./util');
module.exports = async (ctx) => {
@@ -7,12 +8,12 @@ module.exports = async (ctx) => {
const apiUrl = new URL('v2/author/author/detail', apiRootUrl).href;
const currentUrl = new URL(`author/${id}`, rootUrl).href;
- const items = await processItems(apiUrl, limit, ctx.cache.tryGet, {
+ const items = await processItems(apiUrl, limit, cache.tryGet, {
author_id: id,
});
ctx.set('data', {
item: items,
- ...(await getInfo(currentUrl, ctx.cache.tryGet)),
+ ...(await getInfo(currentUrl, cache.tryGet)),
});
};
diff --git a/lib/v2/cyzone/index.js b/lib/v2/cyzone/index.js
index ed6c3888a..acde93e0d 100644
--- a/lib/v2/cyzone/index.js
+++ b/lib/v2/cyzone/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, processItems, getInfo } = require('./util');
module.exports = async (ctx) => {
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const items = await processItems(
apiUrl,
limit,
- ctx.cache.tryGet,
+ cache.tryGet,
id === 'news'
? {}
: {
@@ -20,6 +21,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
item: items,
- ...(await getInfo(currentUrl, ctx.cache.tryGet)),
+ ...(await getInfo(currentUrl, cache.tryGet)),
});
};
diff --git a/lib/v2/cyzone/label.js b/lib/v2/cyzone/label.js
index 52eecadd8..0c7d35773 100644
--- a/lib/v2/cyzone/label.js
+++ b/lib/v2/cyzone/label.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, processItems, getInfo } = require('./util');
module.exports = async (ctx) => {
@@ -7,12 +8,12 @@ module.exports = async (ctx) => {
const apiUrl = new URL('v2/content/tag/tagList', apiRootUrl).href;
const currentUrl = new URL(`label/${name}`, rootUrl).href;
- const items = await processItems(apiUrl, limit, ctx.cache.tryGet, {
+ const items = await processItems(apiUrl, limit, cache.tryGet, {
tag: name,
});
ctx.set('data', {
item: items,
- ...(await getInfo(currentUrl, ctx.cache.tryGet)),
+ ...(await getInfo(currentUrl, cache.tryGet)),
});
};
diff --git a/lib/v2/dahecube/index.js b/lib/v2/dahecube/index.js
index 3072affd7..d911f6629 100644
--- a/lib/v2/dahecube/index.js
+++ b/lib/v2/dahecube/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const utils = require('./utils');
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.id, async () => {
+ cache.tryGet(item.id, async () => {
const detailResponse = await got({
method: 'post',
url: 'https://app.dahecube.com/napi/news/pc/artinfo',
diff --git a/lib/v2/dapenti/utils.js b/lib/v2/dapenti/utils.js
index 98a86b2c0..1c68f018a 100644
--- a/lib/v2/dapenti/utils.js
+++ b/lib/v2/dapenti/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -5,7 +6,7 @@ import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
module.exports = {
- parseFeed: async ({ subjectid }, ctx) => {
+ parseFeed: async ({ subjectid }) => {
const url = `https://www.dapenti.com/blog/blog.asp?name=xilei&subjectid=${subjectid}`;
const listRes = await got({
method: 'get',
@@ -26,7 +27,7 @@ module.exports = {
const result_item = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(`https://www.dapenti.com/blog/${$(item).find('a').attr('href')}`, async () => {
+ cache.tryGet(`https://www.dapenti.com/blog/${$(item).find('a').attr('href')}`, async () => {
const el = $(item);
const url = `https://www.dapenti.com/blog/${el.find('a').attr('href')}`;
const original_data = await got({
diff --git a/lib/v2/darwinawards/index.js b/lib/v2/darwinawards/index.js
index 436bbd8a8..c9a463ef9 100644
--- a/lib/v2/darwinawards/index.js
+++ b/lib/v2/darwinawards/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dayanzai/index.js b/lib/v2/dayanzai/index.js
index 55669244c..5398f354b 100644
--- a/lib/v2/dayanzai/index.js
+++ b/lib/v2/dayanzai/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
fulltext === 'y'
? await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const content = load(detailResponse.data);
item.description = content('div.intro-box').html();
diff --git a/lib/v2/dcard/section.js b/lib/v2/dcard/section.js
index 62d835f1d..a812b6f2b 100644
--- a/lib/v2/dcard/section.js
+++ b/lib/v2/dcard/section.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
const utils = require('./utils');
import puppeteer from '@/utils/puppeteer';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
await page.goto(`${api}&limit=100`);
await page.waitForSelector('body > pre');
const response = await page.evaluate(() => document.querySelector('body > pre').textContent);
- const cookies = await ctx.cache.tryGet('dcard:cookies', () => page.cookies(), 3600, false);
+ const cookies = await cache.tryGet('dcard:cookies', () => page.cookies(), 3600, false);
await page.close();
const data = JSON.parse(response);
diff --git a/lib/v2/dcfever/news.js b/lib/v2/dcfever/news.js
index ff04ef524..6dade002e 100644
--- a/lib/v2/dcfever/news.js
+++ b/lib/v2/dcfever/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseItem } = require('./utils');
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `${$('.channel_nav')
diff --git a/lib/v2/dcfever/reviews.js b/lib/v2/dcfever/reviews.js
index a38291298..32444630c 100644
--- a/lib/v2/dcfever/reviews.js
+++ b/lib/v2/dcfever/reviews.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseItem } = require('./utils');
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/dcfever/trading-search.js b/lib/v2/dcfever/trading-search.js
index 6d44a03b4..0813cc9d2 100644
--- a/lib/v2/dcfever/trading-search.js
+++ b/lib/v2/dcfever/trading-search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
// import { parseRelativeDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseTradeItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseTradeItem(item, cache.tryGet)));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/dcfever/trading.js b/lib/v2/dcfever/trading.js
index c65807170..bf456338a 100644
--- a/lib/v2/dcfever/trading.js
+++ b/lib/v2/dcfever/trading.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
// import { parseRelativeDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseTradeItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseTradeItem(item, cache.tryGet)));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/dedao/index.js b/lib/v2/dedao/index.js
index ea35977e1..542e4d72f 100644
--- a/lib/v2/dedao/index.js
+++ b/lib/v2/dedao/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dedao/list.js b/lib/v2/dedao/list.js
index b5b40edeb..126a4cfa0 100644
--- a/lib/v2/dedao/list.js
+++ b/lib/v2/dedao/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/deeplearning/thebatch.js b/lib/v2/deeplearning/thebatch.js
index 484ff823c..1473153d3 100644
--- a/lib/v2/deeplearning/thebatch.js
+++ b/lib/v2/deeplearning/thebatch.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
module.exports = async (ctx) => {
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
link: `https://www.deeplearning.ai/the-batch/`,
item: await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const resp = await got({ method: 'get', url: item.jsonUrl });
item.description = resp.data.pageProps.cmsData.post.html;
return item;
diff --git a/lib/v2/deepmind/blog.js b/lib/v2/deepmind/blog.js
index ab55708d8..83a3f4784 100644
--- a/lib/v2/deepmind/blog.js
+++ b/lib/v2/deepmind/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const parser = require('@/utils/rss-parser');
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/deltaio/blog.js b/lib/v2/deltaio/blog.js
index dbcddc171..e668bb113 100644
--- a/lib/v2/deltaio/blog.js
+++ b/lib/v2/deltaio/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -6,7 +7,7 @@ module.exports = async (ctx) => {
const baseUrl = 'https://delta.io';
const dataUrl = `${baseUrl}/page-data/blog/page-data.json`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
dataUrl,
async () => {
const { data } = await got(dataUrl);
diff --git a/lib/v2/devolverdigital/blog.js b/lib/v2/devolverdigital/blog.js
index 31a10be1b..90d7babe3 100644
--- a/lib/v2/devolverdigital/blog.js
+++ b/lib/v2/devolverdigital/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
nextData.props.pageProps.posts.map((postData) => {
const postUrl = `${baseUrl}/post/${postData.id}`;
- return ctx.cache.tryGet(postUrl, async () => {
+ return cache.tryGet(postUrl, async () => {
const { data: postPage } = await got(postUrl);
const $page = load(postPage);
diff --git a/lib/v2/dgjyw/index.js b/lib/v2/dgjyw/index.js
index 82f143e9a..9a8515f2d 100644
--- a/lib/v2/dgjyw/index.js
+++ b/lib/v2/dgjyw/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/dgjyw\.com/.test(item.link)) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/dhu/news/xsxx.js b/lib/v2/dhu/news/xsxx.js
index bea1f1e3b..fe85131a1 100644
--- a/lib/v2/dhu/news/xsxx.js
+++ b/lib/v2/dhu/news/xsxx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
// item content
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('.new_zwCot').first().html();
diff --git a/lib/v2/dhu/yjs/news.js b/lib/v2/dhu/yjs/news.js
index 3a2c998bc..043966e71 100644
--- a/lib/v2/dhu/yjs/news.js
+++ b/lib/v2/dhu/yjs/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
// item content
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('.wp_articlecontent').first().html();
diff --git a/lib/v2/dhu/yjs/zs.js b/lib/v2/dhu/yjs/zs.js
index bfb2f904e..328354473 100644
--- a/lib/v2/dhu/yjs/zs.js
+++ b/lib/v2/dhu/yjs/zs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
// item content
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('.wp_articlecontent').first().html();
diff --git a/lib/v2/diandong/news.js b/lib/v2/diandong/news.js
index c6db318e6..9ff1b0076 100644
--- a/lib/v2/diandong/news.js
+++ b/lib/v2/diandong/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/discord/channel.js b/lib/v2/discord/channel.js
index dce4555e7..887c1ba5e 100644
--- a/lib/v2/discord/channel.js
+++ b/lib/v2/discord/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -11,11 +12,11 @@ module.exports = async (ctx) => {
const { authorization } = config.discord;
const { channelId } = ctx.params;
- const channelInfo = await getChannel(channelId, authorization, ctx.cache.tryGet);
- const messagesRaw = await getChannelMessages(channelId, authorization, ctx.cache.tryGet, ctx.req.query('limit') ?? 100);
+ const channelInfo = await getChannel(channelId, authorization, cache.tryGet);
+ const messagesRaw = await getChannelMessages(channelId, authorization, cache.tryGet, ctx.req.query('limit') ?? 100);
const { name: channelName, topic: channelTopic, guild_id: guildId } = channelInfo;
- const guildInfo = await getGuild(guildId, authorization, ctx.cache.tryGet);
+ const guildInfo = await getGuild(guildId, authorization, cache.tryGet);
const { name: guildName, icon: guidIcon } = guildInfo;
const messages = messagesRaw.map((message) => ({
diff --git a/lib/v2/discourse/notifications.js b/lib/v2/discourse/notifications.js
index bc51c902f..aa0fda748 100644
--- a/lib/v2/discourse/notifications.js
+++ b/lib/v2/discourse/notifications.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getConfig } = require('./utils');
import got from '@/utils/got';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
items.map((e) => {
if (e.original_post_id) {
const post_link = `${link}/posts/${e.original_post_id}.json`;
- return ctx.cache.tryGet(post_link, async () => {
+ return cache.tryGet(post_link, async () => {
const { cooked } = await got(post_link, { headers: { 'User-Api-Key': key } }).json();
return { ...e, description: cooked };
});
diff --git a/lib/v2/discuz/discuz.js b/lib/v2/discuz/discuz.js
index 662b2baca..7c71effb1 100644
--- a/lib/v2/discuz/discuz.js
+++ b/lib/v2/discuz/discuz.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -104,7 +105,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { description } = await loadContent(item.link, charset, header);
item.description = description;
@@ -131,7 +132,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { description } = await loadContent(item.link, charset, header);
item.description = description;
diff --git a/lib/v2/disinfo/publications.js b/lib/v2/disinfo/publications.js
index 9365d0d7d..d4e9e943d 100644
--- a/lib/v2/disinfo/publications.js
+++ b/lib/v2/disinfo/publications.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/distill/index.js b/lib/v2/distill/index.js
index db4a991cc..01f774ae7 100644
--- a/lib/v2/distill/index.js
+++ b/lib/v2/distill/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dlnews/category.js b/lib/v2/dlnews/category.js
index 55ed3f7e4..1cb2e35fd 100644
--- a/lib/v2/dlnews/category.js
+++ b/lib/v2/dlnews/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
const { getData, getList } = require('./utils');
@@ -17,7 +18,7 @@ const topics = {
web3: 'Web3',
};
const extractArticle = (ctx, item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
const scriptTagContent = $('script#fusion-metadata').text();
diff --git a/lib/v2/dlsite/ci-en/article.js b/lib/v2/dlsite/ci-en/article.js
index 6c433349d..7e7e6f384 100644
--- a/lib/v2/dlsite/ci-en/article.js
+++ b/lib/v2/dlsite/ci-en/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dn/news.js b/lib/v2/dn/news.js
index 6a4cccbe2..8b2243c48 100644
--- a/lib/v2/dn/news.js
+++ b/lib/v2/dn/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/dnaindia/category.js b/lib/v2/dnaindia/category.js
index 089d5b379..7cdd03d3c 100644
--- a/lib/v2/dnaindia/category.js
+++ b/lib/v2/dnaindia/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
listItems.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.itunes_item_image = $('div.article-img img').attr('src');
diff --git a/lib/v2/docschina/jsweekly.js b/lib/v2/docschina/jsweekly.js
index c2c653f7f..72016fb11 100644
--- a/lib/v2/docschina/jsweekly.js
+++ b/lib/v2/docschina/jsweekly.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import MarkdownIt from 'markdown-it';
@@ -78,7 +79,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: document } = await got.post('https://tcb-api.tencentcloudapi.com/web', {
headers: {
origin: 'https://docschina.org',
diff --git a/lib/v2/dongqiudi/special.js b/lib/v2/dongqiudi/special.js
index 5fd78014a..b81a05e55 100644
--- a/lib/v2/dongqiudi/special.js
+++ b/lib/v2/dongqiudi/special.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.mobileLink);
utils.ProcessFeedType3(item, response);
diff --git a/lib/v2/dongqiudi/top-news.js b/lib/v2/dongqiudi/top-news.js
index e57665f12..5b21a3b0b 100644
--- a/lib/v2/dongqiudi/top-news.js
+++ b/lib/v2/dongqiudi/top-news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
utils.ProcessFeedType2(item, response);
return item;
diff --git a/lib/v2/dongqiudi/utils.js b/lib/v2/dongqiudi/utils.js
index d6be4f5c0..d242d6073 100644
--- a/lib/v2/dongqiudi/utils.js
+++ b/lib/v2/dongqiudi/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
const { JSDOM } = require('jsdom');
@@ -98,7 +99,7 @@ const ProcessFeed = async (ctx, type, id) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
ProcessFeedType2(item, response);
diff --git a/lib/v2/dorohedoro/news.js b/lib/v2/dorohedoro/news.js
index 7eb034554..916a4d8b9 100644
--- a/lib/v2/dorohedoro/news.js
+++ b/lib/v2/dorohedoro/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.isNews) {
try {
const detailResponse = await got({
diff --git a/lib/v2/douban/other/discussion.js b/lib/v2/douban/other/discussion.js
index 9f2f48cc3..224280ee3 100644
--- a/lib/v2/douban/other/discussion.js
+++ b/lib/v2/douban/other/discussion.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
/*
* @Author: nightmare-mio wanglongwei2009@qq.com
* @Date: 2023-11-20 23:36:12
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
// 评论
diff --git a/lib/v2/douban/other/group.js b/lib/v2/douban/other/group.js
index e7accb593..072ab230d 100644
--- a/lib/v2/douban/other/group.js
+++ b/lib/v2/douban/other/group.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
author: $1.find('a').eq(1).text(),
link: $1.find('.title a').attr('href'),
};
- return ctx.cache.tryGet(result.link, async () => {
+ return cache.tryGet(result.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/douban/other/replied.js b/lib/v2/douban/other/replied.js
index 13fc127c4..1f9dd992e 100644
--- a/lib/v2/douban/other/replied.js
+++ b/lib/v2/douban/other/replied.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/douban/other/replies.js b/lib/v2/douban/other/replies.js
index 4930a05cb..f06a0fe97 100644
--- a/lib/v2/douban/other/replies.js
+++ b/lib/v2/douban/other/replies.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/douban/other/topic.js b/lib/v2/douban/other/topic.js
index 5506ef826..21739d9b9 100644
--- a/lib/v2/douban/other/topic.js
+++ b/lib/v2/douban/other/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
module.exports = async (ctx) => {
@@ -49,9 +50,9 @@ module.exports = async (ctx) => {
const id = item.target.id;
const itemUrl = `https://www.douban.com/j/note/${id}/full`;
- const cache = await ctx.cache.get(link);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(link);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got.get(itemUrl);
description = response.data.html;
@@ -65,7 +66,7 @@ module.exports = async (ctx) => {
};
if (type !== 'status') {
- ctx.cache.set(link, JSON.stringify(single));
+ cache.set(link, JSON.stringify(single));
}
return single;
})
diff --git a/lib/v2/douban/people/status.js b/lib/v2/douban/people/status.js
index 00de22843..bdeea7dc4 100644
--- a/lib/v2/douban/people/status.js
+++ b/lib/v2/douban/people/status.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('querystring');
import got from '@/utils/got';
const { fallback, queryToBoolean, queryToInteger } = require('@/utils/readable-social');
@@ -408,14 +409,14 @@ async function getFullTextItems(ctx, items) {
await Promise.all(
items.map(async (item) => {
let url = prefix + item.status.id;
- let cache = await ctx.cache.get(url);
+ let cache = await cache.get(url);
if (cache) {
item.status.text = cache;
} else {
const {
data: { text },
} = await got({ url, headers });
- ctx.cache.set(url, text);
+ cache.set(url, text);
item.status.text = text;
}
// retweet
@@ -423,7 +424,7 @@ async function getFullTextItems(ctx, items) {
return;
}
url = prefix + item.status.reshared_status.id;
- cache = await ctx.cache.get(url);
+ cache = await cache.get(url);
if (cache) {
item.status.reshared_status.text = cache;
} else if (tryFixStatus(item.status.reshared_status).isFixSuccess) {
@@ -432,7 +433,7 @@ async function getFullTextItems(ctx, items) {
const {
data: { text },
} = await got({ url, headers });
- ctx.cache.set(url, text);
+ cache.set(url, text);
item.status.reshared_status.text = text;
} catch {
item.status.reshared_status.text += '\n[获取原动态失败]';
@@ -445,7 +446,7 @@ async function getFullTextItems(ctx, items) {
module.exports = async (ctx) => {
const userid = ctx.req.param('userid');
const url = `https://m.douban.com/rexxar/api/v2/status/user_timeline/${userid}`;
- const items = await ctx.cache.tryGet(
+ const items = await cache.tryGet(
url,
async () => {
const _r = await got({ url, headers });
diff --git a/lib/v2/douyin/hashtag.js b/lib/v2/douyin/hashtag.js
index e395515fd..1866ddd51 100644
--- a/lib/v2/douyin/hashtag.js
+++ b/lib/v2/douyin/hashtag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import { config } from '@/config';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const tagUrl = `https://www.douyin.com/hashtag/${cid}`;
- const tagData = await ctx.cache.tryGet(
+ const tagData = await cache.tryGet(
`douyin:hashtag:${cid}`,
async () => {
const browser = puppeteer();
diff --git a/lib/v2/douyin/live.js b/lib/v2/douyin/live.js
index c47442f1a..3526596a4 100644
--- a/lib/v2/douyin/live.js
+++ b/lib/v2/douyin/live.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
const { getOriginAvatar } = require('./utils');
const logger = require('@/utils/logger');
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const pageUrl = `https://live.douyin.com/${rid}`;
- const renderData = await ctx.cache.tryGet(
+ const renderData = await cache.tryGet(
`douyin:live:${rid}`,
async () => {
let roomInfo;
diff --git a/lib/v2/douyin/user.js b/lib/v2/douyin/user.js
index 7872fbc3b..18a21ef75 100644
--- a/lib/v2/douyin/user.js
+++ b/lib/v2/douyin/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import { config } from '@/config';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const pageUrl = `https://www.douyin.com/user/${uid}`;
- const pageData = await ctx.cache.tryGet(
+ const pageData = await cache.tryGet(
`douyin:user:${uid}`,
async () => {
const renderData = await universalGet(pageUrl, 'user', ctx);
diff --git a/lib/v2/douyin/utils.js b/lib/v2/douyin/utils.js
index 9cbb5621c..a2a854ba5 100644
--- a/lib/v2/douyin/utils.js
+++ b/lib/v2/douyin/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const path = require('path');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -93,9 +94,9 @@ const puppeteerGet = async (pageUrl) => {
return extractRenderData(html);
};
-const universalGet = async (url, route, ctx) => {
+const universalGet = async (url, route) => {
const cacheKey = `douyin:utils:universalGet:gotFirst:${route}`;
- const gotFirst = await ctx.cache.tryGet(
+ const gotFirst = await cache.tryGet(
cacheKey,
() => '1',
config.cache.contentExpire,
@@ -108,20 +109,20 @@ const universalGet = async (url, route, ctx) => {
if (gotFirst === '1') {
try {
data = await gotGet(url, ua);
- ctx.cache.set(cacheKey, '1', config.cache.contentExpire); // refresh if success
+ cache.set(cacheKey, '1', config.cache.contentExpire); // refresh if success
} catch (error) {
logger.warn('Failed to get data with got, trying puppeteer: ' + error.message);
data = await puppeteerGet(url);
- ctx.cache.set(cacheKey, '0', config.cache.contentExpire); // only set if success
+ cache.set(cacheKey, '0', config.cache.contentExpire); // only set if success
}
} else {
try {
data = await puppeteerGet(url);
- ctx.cache.set(cacheKey, '0', config.cache.contentExpire); // refresh if success
+ cache.set(cacheKey, '0', config.cache.contentExpire); // refresh if success
} catch (error) {
logger.warn('Failed to get data with puppeteer, trying got: ' + error.message);
data = await gotGet(url, ua);
- ctx.cache.set(cacheKey, '1', config.cache.contentExpire); // only set if success
+ cache.set(cacheKey, '1', config.cache.contentExpire); // only set if success
}
}
return data;
diff --git a/lib/v2/dtcj/datahero.js b/lib/v2/dtcj/datahero.js
index 5a16b931c..b77d23b5f 100644
--- a/lib/v2/dtcj/datahero.js
+++ b/lib/v2/dtcj/datahero.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dtcj/datainsight.js b/lib/v2/dtcj/datainsight.js
index 07af51ba7..5728784ee 100644
--- a/lib/v2/dtcj/datainsight.js
+++ b/lib/v2/dtcj/datainsight.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dut/index.js b/lib/v2/dut/index.js
index 5c075d4f3..1aa200da0 100644
--- a/lib/v2/dut/index.js
+++ b/lib/v2/dut/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -66,7 +67,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/dx2025/index.js b/lib/v2/dx2025/index.js
index 9371b9ae6..0ea8de378 100644
--- a/lib/v2/dx2025/index.js
+++ b/lib/v2/dx2025/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/dxy/profile/thread.js b/lib/v2/dxy/profile/thread.js
index 1cd6c0fe3..4ec5aca95 100644
--- a/lib/v2/dxy/profile/thread.js
+++ b/lib/v2/dxy/profile/thread.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { webBaseUrl, generateNonce, sign, getPost } = require('../utils');
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const { userId } = ctx.params;
const { limit = '30' } = ctx.query;
- const userInfo = await ctx.cache.tryGet(`dxy:user-info:${userId}`, async () => {
+ const userInfo = await cache.tryGet(`dxy:user-info:${userId}`, async () => {
const userInfoParams = {
userId,
serverTimestamp: Date.now(),
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
return userInfo.data;
});
- const postList = await ctx.cache.tryGet(
+ const postList = await cache.tryGet(
`dxy:user:post:${userId}`,
async () => {
const postListParams = {
@@ -70,7 +71,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => getPost(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => getPost(item, cache.tryGet)));
ctx.set('data', {
title: `${userInfo.nickname} 的个人主页 - 丁香园论坛 - 专业医生社区,医学、药学、生命科学、科研学术交流`,
diff --git a/lib/v2/dxy/special.js b/lib/v2/dxy/special.js
index 3a3e0b70b..8ad05dcc4 100644
--- a/lib/v2/dxy/special.js
+++ b/lib/v2/dxy/special.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { phoneBaseUrl, webBaseUrl, generateNonce, sign, getPost } = require('./utils');
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const { specialId } = ctx.params;
const { limit = '10' } = ctx.query;
- const specialDetail = await ctx.cache.tryGet(`dxy:special:detail:${specialId}`, async () => {
+ const specialDetail = await cache.tryGet(`dxy:special:detail:${specialId}`, async () => {
const detailParams = {
specialId,
requestType: 'h5',
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
return detail.data;
});
- const recommendList = await ctx.cache.tryGet(
+ const recommendList = await cache.tryGet(
`dxy:special:recommend-list-v3:${specialId}`,
async () => {
const listParams = {
@@ -67,7 +68,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => getPost(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => getPost(item, cache.tryGet)));
ctx.set('data', {
title: specialDetail.name,
diff --git a/lib/v2/e-hentai/index.js b/lib/v2/e-hentai/index.js
index 909562a3e..79d122cda 100644
--- a/lib/v2/e-hentai/index.js
+++ b/lib/v2/e-hentai/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
items.map(async (item) => {
if (item.enclosure_url) {
let forms = '',
- torrents = await ctx.cache.get(item.enclosure_url);
+ torrents = await cache.get(item.enclosure_url);
if (!torrents) {
const torrentResponse = await got({
@@ -65,7 +66,7 @@ module.exports = async (ctx) => {
t = torrent(t);
return { link: t.attr('href'), title: t.text() };
});
- ctx.cache.set(item.enclosure_url, torrents);
+ cache.set(item.enclosure_url, torrents);
}
item.description += forms;
item.enclosure_url = torrents[0].link;
@@ -73,7 +74,7 @@ module.exports = async (ctx) => {
}
if (needImages) {
- let images = await ctx.cache.get(item.link);
+ let images = await cache.get(item.link);
if (!images) {
const imageResponse = await got({
@@ -87,7 +88,7 @@ module.exports = async (ctx) => {
content('.gdtm a')
.toArray()
.map((i) =>
- ctx.cache.tryGet(content(i).attr('href'), async () => {
+ cache.tryGet(content(i).attr('href'), async () => {
const imageResponse = await got({
method: 'get',
url: content(i).attr('href'),
@@ -99,7 +100,7 @@ module.exports = async (ctx) => {
})
)
);
- ctx.cache.set(item.link, images);
+ cache.set(item.link, images);
}
item.description += art(path.join(__dirname, 'templates/images.art'), { images });
}
diff --git a/lib/v2/eagle/blog.js b/lib/v2/eagle/blog.js
index 4990d3a5e..2ece2c84b 100644
--- a/lib/v2/eagle/blog.js
+++ b/lib/v2/eagle/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/eastday/24.js b/lib/v2/eastday/24.js
index 2a1b2b8e9..2e298c8fc 100644
--- a/lib/v2/eastday/24.js
+++ b/lib/v2/eastday/24.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
@@ -60,7 +61,7 @@ module.exports = async (ctx) => {
}
for (const link of links) {
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
const pageResponse = await got({
method: 'get',
url: link,
diff --git a/lib/v2/eastday/portrait.js b/lib/v2/eastday/portrait.js
index 2b0b0f8f6..bc07ff04e 100644
--- a/lib/v2/eastday/portrait.js
+++ b/lib/v2/eastday/portrait.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/eastday/sh.js b/lib/v2/eastday/sh.js
index 0474781ab..fb218d45c 100644
--- a/lib/v2/eastday/sh.js
+++ b/lib/v2/eastday/sh.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const logger = require('@/utils/logger');
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
try {
const cacheKey = `eastday_sh_${link}`;
- entity.description = await ctx.cache.tryGet(cacheKey, async () => {
+ entity.description = await cache.tryGet(cacheKey, async () => {
const article = await got({
method: 'get',
url: link,
diff --git a/lib/v2/eastmoney/report/index.js b/lib/v2/eastmoney/report/index.js
index 546184956..a8f7b6578 100644
--- a/lib/v2/eastmoney/report/index.js
+++ b/lib/v2/eastmoney/report/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/eastmoney/ttjj/user.js b/lib/v2/eastmoney/ttjj/user.js
index c141e8c5b..ec1881f75 100644
--- a/lib/v2/eastmoney/ttjj/user.js
+++ b/lib/v2/eastmoney/ttjj/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(userArticleUrl + item.post_id, async () => {
+ cache.tryGet(userArticleUrl + item.post_id, async () => {
const detailResponse = await got({
method: 'post',
url: userArticleUrl,
diff --git a/lib/v2/ecnu/yjs.js b/lib/v2/ecnu/yjs.js
index 7f2e5a0b3..3c2915a00 100644
--- a/lib/v2/ecnu/yjs.js
+++ b/lib/v2/ecnu/yjs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('.articleCon').html();
diff --git a/lib/v2/economist/espresso.js b/lib/v2/economist/espresso.js
index 300fb8855..d609d88e6 100644
--- a/lib/v2/economist/espresso.js
+++ b/lib/v2/economist/espresso.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { config } from '@/config';
@@ -5,7 +6,7 @@ import { config } from '@/config';
const link = 'https://www.economist.com/the-world-in-brief';
module.exports = async (ctx) => {
- const $ = await ctx.cache.tryGet(
+ const $ = await cache.tryGet(
link,
async () => {
const response = await got(link);
diff --git a/lib/v2/economist/full.js b/lib/v2/economist/full.js
index 8cd67f762..56e5660d9 100644
--- a/lib/v2/economist/full.js
+++ b/lib/v2/economist/full.js
@@ -1,9 +1,10 @@
+import cache from '@/utils/cache';
const parser = require('@/utils/rss-parser');
import got from '@/utils/got';
import { load } from 'cheerio';
-const getArticleDetail = (link, ctx) =>
- ctx.cache.tryGet(link, async () => {
+const getArticleDetail = (link) =>
+ cache.tryGet(link, async () => {
const response = await got(link);
const $ = load(response.data);
$('div.article-audio-player__center-tooltip').remove();
diff --git a/lib/v2/economist/global-business-review.js b/lib/v2/economist/global-business-review.js
index 1b5c4c880..d34280678 100644
--- a/lib/v2/economist/global-business-review.js
+++ b/lib/v2/economist/global-business-review.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const ALLOW_LANGUAGE = {
@@ -49,9 +50,9 @@ const parseImage = function (data, article_id, language) {
return `
})
`;
};
-const getArticleDetail = (article_id, language, ctx) => {
+const getArticleDetail = (article_id, language) => {
const link = `https://api.hummingbird.businessreview.global/api/article/index?id=${article_id}`;
- return ctx.cache.tryGet(`${link}:${language.join('-')}`, async () => {
+ return cache.tryGet(`${link}:${language.join('-')}`, async () => {
const response = await got({
method: 'get',
url: link,
diff --git a/lib/v2/ecust/e/news.js b/lib/v2/ecust/e/news.js
index 8d0f12988..2c52fdd46 100644
--- a/lib/v2/ecust/e/news.js
+++ b/lib/v2/ecust/e/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('toPhoneSign')) {
return item;
}
diff --git a/lib/v2/ecust/jwc/notice.js b/lib/v2/ecust/jwc/notice.js
index 33b53e0f6..6d35dc1e2 100644
--- a/lib/v2/ecust/jwc/notice.js
+++ b/lib/v2/ecust/jwc/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const items = (await Promise.all(pageUrl.map((link) => get_from_link(link)))).flat();
const result = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const content = load(response);
// remove all attrs and empty objects
diff --git a/lib/v2/ekantipur/issue.js b/lib/v2/ekantipur/issue.js
index cd5990b50..2de752f80 100644
--- a/lib/v2/ekantipur/issue.js
+++ b/lib/v2/ekantipur/issue.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// Require necessary modules
import got from '@/utils/got'; // a customised got
import { load } from 'cheerio'; // an HTML parser with a jQuery-like API
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/elasticsearch-cn/index.js b/lib/v2/elasticsearch-cn/index.js
index f507a19f9..b2fffa2ca 100644
--- a/lib/v2/elasticsearch-cn/index.js
+++ b/lib/v2/elasticsearch-cn/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/eleduck/jobs.js b/lib/v2/eleduck/jobs.js
index 54b2c8ac1..8ba3d2be5 100644
--- a/lib/v2/eleduck/jobs.js
+++ b/lib/v2/eleduck/jobs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
data.map((job) =>
- ctx.cache.tryGet(job.link, async () => {
+ cache.tryGet(job.link, async () => {
const { data: jobDetail } = await got(`https://svc.eleduck.com/api/v1/posts/${job.id}`);
job.description = jobDetail.post.content;
diff --git a/lib/v2/eleduck/posts.js b/lib/v2/eleduck/posts.js
index eb246a21a..e4212c43b 100644
--- a/lib/v2/eleduck/posts.js
+++ b/lib/v2/eleduck/posts.js
@@ -1,8 +1,9 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const getCateName = async (ctx, cid = 0) => {
const key = 'eleduck-categories';
- const cates = await ctx.cache.tryGet(key, async () => {
+ const cates = await cache.tryGet(key, async () => {
const res = await got(`https://svc.eleduck.com/api/v1/categories`);
const map = {};
for (const item of res.data.categories) {
diff --git a/lib/v2/elsevier/issue.js b/lib/v2/elsevier/issue.js
index b59f3dbbc..9e0710cde 100644
--- a/lib/v2/elsevier/issue.js
+++ b/lib/v2/elsevier/issue.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
});
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response2 = await got(`${host}/science/article/pii/${item.id}`, {
cookieJar,
});
diff --git a/lib/v2/elsevier/journal.js b/lib/v2/elsevier/journal.js
index cf02e8ed7..ca2052709 100644
--- a/lib/v2/elsevier/journal.js
+++ b/lib/v2/elsevier/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
});
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response3 = await got(`${host}/science/article/pii/${item.id}`, {
cookieJar,
});
diff --git a/lib/v2/embassy/index.js b/lib/v2/embassy/index.js
index 25fe879ec..ab18cd908 100644
--- a/lib/v2/embassy/index.js
+++ b/lib/v2/embassy/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((link) =>
- ctx.cache.tryGet(link.href, async () => {
+ cache.tryGet(link.href, async () => {
const response = await got(link);
const $ = load(response.data);
const single = {
diff --git a/lib/v2/eprice/rss.js b/lib/v2/eprice/rss.js
index c42fbd52f..77b756638 100644
--- a/lib/v2/eprice/rss.js
+++ b/lib/v2/eprice/rss.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link, {
headers: {
Referer: `https://www.eprice.com.${region}`,
diff --git a/lib/v2/famitsu/category.js b/lib/v2/famitsu/category.js
index 3915833a9..4d07596cc 100644
--- a/lib/v2/famitsu/category.js
+++ b/lib/v2/famitsu/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/fansly/post.js b/lib/v2/fansly/post.js
index 8bbcd7d04..f0f7a30f6 100644
--- a/lib/v2/fansly/post.js
+++ b/lib/v2/fansly/post.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
const { getAccountByUsername, getTimelineByAccountId, parseDescription, baseUrl } = require('./utils');
module.exports = async (ctx) => {
const { username } = ctx.params;
- const account = await getAccountByUsername(username, ctx.cache.tryGet);
+ const account = await getAccountByUsername(username, cache.tryGet);
const timeline = await getTimelineByAccountId(account.id);
const items = timeline.posts.map((post) => ({
diff --git a/lib/v2/fansly/tag.js b/lib/v2/fansly/tag.js
index 5bf27b543..73fad070d 100644
--- a/lib/v2/fansly/tag.js
+++ b/lib/v2/fansly/tag.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
const { getTagId, getTagSuggestion, findAccountById, parseDescription, baseUrl, icon } = require('./utils');
module.exports = async (ctx) => {
const { tag } = ctx.params;
- const tagId = await getTagId(tag, ctx.cache.tryGet);
+ const tagId = await getTagId(tag, cache.tryGet);
const suggestion = await getTagSuggestion(tagId);
const items = suggestion.aggregationData?.posts.map((post) => {
diff --git a/lib/v2/fantia/user.js b/lib/v2/fantia/user.js
index 7c3de8f62..ac695b976 100644
--- a/lib/v2/fantia/user.js
+++ b/lib/v2/fantia/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
}));
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const contentResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/fastbull/news.js b/lib/v2/fastbull/news.js
index 95d432543..ee992e8aa 100644
--- a/lib/v2/fastbull/news.js
+++ b/lib/v2/fastbull/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/fda/cdrh.js b/lib/v2/fda/cdrh.js
index ab1528be4..e03ef6efb 100644
--- a/lib/v2/fda/cdrh.js
+++ b/lib/v2/fda/cdrh.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(titleOnly ? `${item.link}#${item.title}#titleOnly` : `${item.link}#${item.title}`, async () => {
+ cache.tryGet(titleOnly ? `${item.link}#${item.title}#titleOnly` : `${item.link}#${item.title}`, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/feng/utils.js b/lib/v2/feng/utils.js
index 6e48317ee..7ff08f71e 100644
--- a/lib/v2/feng/utils.js
+++ b/lib/v2/feng/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const CryptoJS = require('crypto-js');
import got from '@/utils/got';
import { config } from '@/config';
@@ -18,9 +19,9 @@ const getXRequestId = (apiUrl) => {
return encrypted;
};
-const getCategory = (topicId, ctx) => {
+const getCategory = (topicId) => {
const url = `${apiUrl}/v1/topic/category`;
- return ctx.cache.tryGet(
+ return cache.tryGet(
url,
async () => {
const response = await got(url, {
@@ -41,9 +42,9 @@ const getForumMeta = async (topicId, ctx) => {
return Object.values(categoryData.data.dataList).find((item) => item.dataList.find((i) => i.topicId === topicId));
};
-const getThreads = (topicId, type, ctx) => {
+const getThreads = (topicId, type) => {
const url = `${apiUrl}/v1/topic/${topicId}/thread?topicId=${topicId}&type=${type}&pageCount=50&order=${type === 'newest' ? 'replyTime' : 'postTime'}&page=1`;
- return ctx.cache.tryGet(
+ return cache.tryGet(
url,
async () => {
const response = await got(url, {
@@ -59,9 +60,9 @@ const getThreads = (topicId, type, ctx) => {
);
};
-const getThread = (tid, topicId, ctx) => {
+const getThread = (tid, topicId) => {
const url = `${apiUrl}/v1/thread/${tid}`;
- return ctx.cache.tryGet(url, async () => {
+ return cache.tryGet(url, async () => {
const response = await got(url, {
headers: {
Referer: `${baseUrl}/forum/${topicId}`,
diff --git a/lib/v2/fffdm/manhua/manhua.js b/lib/v2/fffdm/manhua/manhua.js
index a35fd69dd..dd4d41775 100644
--- a/lib/v2/fffdm/manhua/manhua.js
+++ b/lib/v2/fffdm/manhua/manhua.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const domain = 'manhua.fffdm.com';
const host = `https://${domain}`;
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const chapter_detail = await Promise.all(
data.mhlist.splice(0, count).map((item) => {
const url = `${host}/api/manhua/${id}/${item.url}`;
- return ctx.cache.tryGet(url, async () => {
+ return cache.tryGet(url, async () => {
const picContent = await get_pic(url);
return {
title: picContent.chapterTitle,
diff --git a/lib/v2/finology/utils.js b/lib/v2/finology/utils.js
index 4df6d61a7..606b91a06 100644
--- a/lib/v2/finology/utils.js
+++ b/lib/v2/finology/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ const getItems = async (ctx, url, extra) => {
const items = (
await Promise.allSettled(
listItems.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
const div = $('div.w60.flex.flex-wrap-badge');
diff --git a/lib/v2/fishshell/index.js b/lib/v2/fishshell/index.js
index 3fbad66b3..2641d499d 100644
--- a/lib/v2/fishshell/index.js
+++ b/lib/v2/fishshell/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { config } from '@/config';
@@ -5,7 +6,7 @@ import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx) => {
const link = 'https://fishshell.com/docs/current/relnotes.html';
- const data = await ctx.cache.tryGet(link, async () => (await got(link)).data, config.cache.contentExpire, false);
+ const data = await cache.tryGet(link, async () => (await got(link)).data, config.cache.contentExpire, false);
const $ = load(data);
ctx.set('data', {
link,
diff --git a/lib/v2/fjksbm/index.js b/lib/v2/fjksbm/index.js
index 61c5305c4..fa8c5c419 100644
--- a/lib/v2/fjksbm/index.js
+++ b/lib/v2/fjksbm/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/flyert/preferential.js b/lib/v2/flyert/preferential.js
index b17927054..45821709c 100644
--- a/lib/v2/flyert/preferential.js
+++ b/lib/v2/flyert/preferential.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
responseType: 'buffer',
});
diff --git a/lib/v2/focustaiwan/index.js b/lib/v2/focustaiwan/index.js
index 132e84b15..6c7d084b7 100644
--- a/lib/v2/focustaiwan/index.js
+++ b/lib/v2/focustaiwan/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/followin/index.js b/lib/v2/followin/index.js
index 5deb629b4..404092955 100644
--- a/lib/v2/followin/index.js
+++ b/lib/v2/followin/index.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiUrl, favicon, getBParam, getBuildId, getGToken, parseList, parseItem } = require('./utils');
module.exports = async (ctx) => {
const { categoryId = '1', lang = 'en' } = ctx.params;
const { limit = 20 } = ctx.query;
- const gToken = await getGToken(ctx.cache.tryGet);
+ const gToken = await getGToken(cache.tryGet);
const bParam = getBParam(lang);
const { data: response } = await got.post(`${apiUrl}/feed/list/recommended`, {
@@ -21,10 +22,10 @@ module.exports = async (ctx) => {
throw new Error(response.msg);
}
- const buildId = await getBuildId(ctx.cache.tryGet);
+ const buildId = await getBuildId(cache.tryGet);
const list = parseList(response.data.list, lang, buildId);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: 'Followin',
diff --git a/lib/v2/followin/kol.js b/lib/v2/followin/kol.js
index 49af93017..13b200afd 100644
--- a/lib/v2/followin/kol.js
+++ b/lib/v2/followin/kol.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, getBuildId, parseList, parseItem } = require('./utils');
@@ -5,14 +6,14 @@ module.exports = async (ctx) => {
const { kolId, lang = 'en' } = ctx.params;
const { limit = 10 } = ctx.query;
- const buildId = await getBuildId(ctx.cache.tryGet);
+ const buildId = await getBuildId(cache.tryGet);
const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/kol/${kolId}.json`);
const { queries } = response.pageProps.dehydratedState;
const { data: profile } = queries.find((q) => q.queryKey[0] === '/user/get_profile').state;
const list = parseList(queries.find((q) => q.queryKey[0] === '/feed/list/user').state.data.pages[0].list.slice(0, limit), lang, buildId);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `${profile.nickname} - Followin`,
diff --git a/lib/v2/followin/news.js b/lib/v2/followin/news.js
index bea4a7701..3dc083f42 100644
--- a/lib/v2/followin/news.js
+++ b/lib/v2/followin/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, favicon, getBuildId, parseList, parseItem } = require('./utils');
@@ -5,11 +6,11 @@ module.exports = async (ctx) => {
const { lang = 'en' } = ctx.params;
const { limit = 20 } = ctx.query;
- const buildId = await getBuildId(ctx.cache.tryGet);
+ const buildId = await getBuildId(cache.tryGet);
const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/news.json`);
const list = parseList(response.pageProps.dehydratedState.queries.find((q) => q.queryKey[0] === '/feed/list/recommended/news').state.data.pages[0].list.slice(0, limit), lang, buildId);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `${lang === 'en' ? 'News' : lang === 'vi' ? 'Bản tin' : '快讯'} - Followin`,
diff --git a/lib/v2/followin/tag.js b/lib/v2/followin/tag.js
index 51b801695..1e4030d45 100644
--- a/lib/v2/followin/tag.js
+++ b/lib/v2/followin/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiUrl, baseUrl, getBParam, getBuildId, getGToken, parseList, parseItem } = require('./utils');
@@ -5,15 +6,15 @@ module.exports = async (ctx) => {
const { tagId, lang = 'en' } = ctx.params;
const { limit = 20 } = ctx.query;
- const buildId = await getBuildId(ctx.cache.tryGet);
- const tagInfo = await ctx.cache.tryGet(`followin:tag:${tagId}:${lang}`, async () => {
+ const buildId = await getBuildId(cache.tryGet);
+ const tagInfo = await cache.tryGet(`followin:tag:${tagId}:${lang}`, async () => {
const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/tag/${tagId}.json`);
const { queries } = response.pageProps.dehydratedState;
const { base_info: tagInfo } = queries.find((q) => q.queryKey[0] === '/tag/info/v2').state.data;
return tagInfo;
});
- const gToken = await getGToken(ctx.cache.tryGet);
+ const gToken = await getGToken(cache.tryGet);
const bParam = getBParam(lang);
const { data: tagResponse } = await got.post(`${apiUrl}/feed/list/tag`, {
headers: {
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
}
const list = parseList(tagResponse.data.list.slice(0, limit), lang, buildId);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `${tagInfo.name} - Followin`,
diff --git a/lib/v2/followin/topic.js b/lib/v2/followin/topic.js
index 049bbd25e..c8eb151f3 100644
--- a/lib/v2/followin/topic.js
+++ b/lib/v2/followin/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, getBuildId, parseList, parseItem } = require('./utils');
@@ -5,14 +6,14 @@ module.exports = async (ctx) => {
const { topicId, lang = 'en' } = ctx.params;
const { limit = 20 } = ctx.query;
- const buildId = await getBuildId(ctx.cache.tryGet);
+ const buildId = await getBuildId(cache.tryGet);
const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/${lang}/topic/${topicId}.json`);
const { queries } = response.pageProps.dehydratedState;
const { data: topicInfo } = queries.find((q) => q.queryKey[0] === '/topic/info').state;
const list = parseList(queries.find((q) => q.queryKey[0] === '/feed/list/topic').state.data.pages[0].list.slice(0, limit), lang, buildId);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `${topicInfo.title} - Followin`,
diff --git a/lib/v2/fortnite/news.js b/lib/v2/fortnite/news.js
index 04cd167b9..2861d111c 100644
--- a/lib/v2/fortnite/news.js
+++ b/lib/v2/fortnite/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
const logger = require('@/utils/logger');
import puppeteer from '@/utils/puppeteer';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const { blogList: list } = data;
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, () => ({
+ cache.tryGet(item.link, () => ({
title: item.title,
link: `${rootUrl}/${path}/${item.slug}?lang=${language}`,
pubDate: parseDate(item.date),
diff --git a/lib/v2/fortunechina/index.js b/lib/v2/fortunechina/index.js
index 068b115e5..34071b323 100644
--- a/lib/v2/fortunechina/index.js
+++ b/lib/v2/fortunechina/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/freewechat/profile.js b/lib/v2/freewechat/profile.js
index a84e52a92..8c1bd7702 100644
--- a/lib/v2/freewechat/profile.js
+++ b/lib/v2/freewechat/profile.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link, {
headers: {
Referer: url,
diff --git a/lib/v2/ft/myft.js b/lib/v2/ft/myft.js
index 8603cc2cf..e98467a1a 100644
--- a/lib/v2/ft/myft.js
+++ b/lib/v2/ft/myft.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ft/utils.js b/lib/v2/ft/utils.js
index d958a77ee..1ed4497a0 100644
--- a/lib/v2/ft/utils.js
+++ b/lib/v2/ft/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -39,7 +40,7 @@ const ProcessFeed = (i, $, link) => {
return { content, author, title };
};
-const getData = async ({ site = 'www', channel, ctx }) => {
+const getData = async ({ site = 'www', channel }) => {
let feed;
if (channel) {
@@ -61,7 +62,7 @@ const getData = async ({ site = 'www', channel, ctx }) => {
const items = await Promise.all(
feed.items.map((item) => {
item.link = item.link.replace('http://', 'https://');
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const response = await got.get(`${item.link}?full=y&archive`);
const $ = load(response.data);
diff --git a/lib/v2/futunn/main.js b/lib/v2/futunn/main.js
index 0b0d17952..a7540071f 100644
--- a/lib/v2/futunn/main.js
+++ b/lib/v2/futunn/main.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/news\.futunn\.com/.test(item.link)) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/fx-markets/channel.js b/lib/v2/fx-markets/channel.js
index f34bf4327..0fc6fee4e 100644
--- a/lib/v2/fx-markets/channel.js
+++ b/lib/v2/fx-markets/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
articles.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link);
const doc = load(res.data);
// This script holds publish datetime info {"datePublished": "2022-05-12T08:45:04+01:00"}
diff --git a/lib/v2/fx678/kx.js b/lib/v2/fx678/kx.js
index fc8e504b2..5244842b3 100644
--- a/lib/v2/fx678/kx.js
+++ b/lib/v2/fx678/kx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((itemUrl) =>
- ctx.cache.tryGet(itemUrl, async () => {
+ cache.tryGet(itemUrl, async () => {
const res = await got.get(itemUrl);
const $ = load(res.data);
diff --git a/lib/v2/fxiaoke/crm.js b/lib/v2/fxiaoke/crm.js
index 8b67f4062..ea7e7fbf9 100644
--- a/lib/v2/fxiaoke/crm.js
+++ b/lib/v2/fxiaoke/crm.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
});
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const resp = await got(item.link);
const $ = load(resp.data);
const firstViewBox = $('.body-wrapper-article').first();
diff --git a/lib/v2/gameapps/index.js b/lib/v2/gameapps/index.js
index 56b2de96f..7cbf49d76 100644
--- a/lib/v2/gameapps/index.js
+++ b/lib/v2/gameapps/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
headers: {
Referer: baseUrl,
diff --git a/lib/v2/gamebase/news.js b/lib/v2/gamebase/news.js
index 01f6009bd..0ec49069e 100644
--- a/lib/v2/gamebase/news.js
+++ b/lib/v2/gamebase/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.return_msg.list.slice(0, limit).map((item) =>
- ctx.cache.tryGet(`gamebase:news:${type}:${category}:${item.news_no}`, async () => {
+ cache.tryGet(`gamebase:news:${type}:${category}:${item.news_no}`, async () => {
const i = {};
i.author = item.nickname;
diff --git a/lib/v2/gamegene/news.js b/lib/v2/gamegene/news.js
index b5777f896..27210bb09 100644
--- a/lib/v2/gamegene/news.js
+++ b/lib/v2/gamegene/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
});
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gamer/gnn-index.js b/lib/v2/gamer/gnn-index.js
index 6d5265244..869725e7b 100644
--- a/lib/v2/gamer/gnn-index.js
+++ b/lib/v2/gamer/gnn-index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -69,7 +70,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
- item.description = await ctx.cache.tryGet(item.link, async () => {
+ item.description = await cache.tryGet(item.link, async () => {
const response = await got.get(item.link);
let component = '';
const urlReg = /window.location.replace\('.*'/g;
diff --git a/lib/v2/gamer/hot.js b/lib/v2/gamer/hot.js
index 1e7b79fc3..1576b0490 100644
--- a/lib/v2/gamer/hot.js
+++ b/lib/v2/gamer/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
url: item.link,
headers: {
diff --git a/lib/v2/gamersecret/index.js b/lib/v2/gamersecret/index.js
index 653090703..19e42ab62 100644
--- a/lib/v2/gamersecret/index.js
+++ b/lib/v2/gamersecret/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gamme/category.js b/lib/v2/gamme/category.js
index 78f706c88..772397784 100644
--- a/lib/v2/gamme/category.js
+++ b/lib/v2/gamme/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const parser = require('@/utils/rss-parser');
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/gamme/tag.js b/lib/v2/gamme/tag.js
index 718136fba..124b40692 100644
--- a/lib/v2/gamme/tag.js
+++ b/lib/v2/gamme/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/gcores/category.js b/lib/v2/gcores/category.js
index bf1be5986..df2f64c09 100644
--- a/lib/v2/gcores/category.js
+++ b/lib/v2/gcores/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
list.map((item) => {
const articleUrl = `https://www.gcores.com${item.url}`;
- return ctx.cache.tryGet(articleUrl, async () => {
+ return cache.tryGet(articleUrl, async () => {
const itemRes = await got({
method: 'get',
url: articleUrl,
diff --git a/lib/v2/gcores/collection.js b/lib/v2/gcores/collection.js
index 958688660..26972df0c 100644
--- a/lib/v2/gcores/collection.js
+++ b/lib/v2/gcores/collection.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
/* refer to: ./tag.js (author: @StevenREC0) */
import got from '@/utils/got';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = list.map((item) => {
const articleUrl = `https://www.gcores.com/${item.type}/${item.id}`;
- return ctx.cache.tryGet(articleUrl, () => {
+ return cache.tryGet(articleUrl, () => {
let cover = '';
if (item.attributes.cover) {
cover = `
`;
diff --git a/lib/v2/gcores/tag.js b/lib/v2/gcores/tag.js
index 8a118f9d2..28580e6e4 100644
--- a/lib/v2/gcores/tag.js
+++ b/lib/v2/gcores/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
list.map((item) => {
const articleUrl = `https://www.gcores.com${item.url}`;
- return ctx.cache.tryGet(articleUrl, async () => {
+ return cache.tryGet(articleUrl, async () => {
const itemRes = await got({
method: 'get',
url: articleUrl,
diff --git a/lib/v2/gdsrx/index.js b/lib/v2/gdsrx/index.js
index db4402fb9..e48ca318b 100644
--- a/lib/v2/gdsrx/index.js
+++ b/lib/v2/gdsrx/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gdut/news.js b/lib/v2/gdut/news.js
index 24d9e89df..2f2aa21fb 100644
--- a/lib/v2/gdut/news.js
+++ b/lib/v2/gdut/news.js
@@ -1,3 +1,4 @@
+// import cache from '@/utils/cache';
/* eslint-disable unicorn/no-empty-file */
/* Removed due to news.gdut.edu.cn no longer exists.
@@ -59,10 +60,10 @@ module.exports = async (ctx) => {
const page = '/ArticleList.aspx?category=4';
// 缓存cookie
- let cookie = await ctx.cache.get(site + page);
+ let cookie = await cache.get(site + page);
if (!cookie) {
cookie = await getCookie();
- ctx.cache.set(site + page, cookie);
+ cache.set(site + page, cookie);
}
let pageResp = await got({
@@ -76,7 +77,7 @@ module.exports = async (ctx) => {
if (e.statusCode === 302) {
if (/UserLogin/.test(e.headers.location)) {
cookie = await getCookie();
- ctx.cache.set(site + page, cookie);
+ cache.set(site + page, cookie);
pageResp = await got({
method: 'get',
url: site + page,
@@ -110,9 +111,9 @@ module.exports = async (ctx) => {
const out = await Promise.all(
articleList.map(async (data) => {
const link = data.link;
- const cache = await ctx.cache.get(link);
- if (cache) {
- return Promise.resolve(JSON.parse(cache));
+ const cacheIn = await cache.get(link);
+ if (cacheIn) {
+ return Promise.resolve(JSON.parse(cacheIn));
}
// 获取数据
@@ -152,7 +153,7 @@ module.exports = async (ctx) => {
category,
};
// 将文章结果缓存
- ctx.cache.set(link, JSON.stringify(single));
+ cache.set(link, JSON.stringify(single));
return Promise.resolve(single);
})
);
diff --git a/lib/v2/gdut/oa-news.js b/lib/v2/gdut/oa-news.js
index 90a385370..41ed55afc 100644
--- a/lib/v2/gdut/oa-news.js
+++ b/lib/v2/gdut/oa-news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import wait from '@/utils/wait';
import { load } from 'cheerio';
@@ -114,7 +115,7 @@ module.exports = async (ctx) => {
// 获取实际的文章内容
for await (const data of asyncPool(2, articles, async (data) => {
const link = data.link;
- data.description = await ctx.cache.tryGet(link, async () => {
+ data.description = await cache.tryGet(link, async () => {
// 获取数据
const response = await got(link, {
cookieJar,
diff --git a/lib/v2/gelonghui/home.js b/lib/v2/gelonghui/home.js
index 642553edb..a8f0d7c2a 100644
--- a/lib/v2/gelonghui/home.js
+++ b/lib/v2/gelonghui/home.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { parseItem } = require('./utils');
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: '格隆汇-财经资讯动态-股市行情',
diff --git a/lib/v2/gelonghui/hot-article.js b/lib/v2/gelonghui/hot-article.js
index 511228c04..826a85d7e 100644
--- a/lib/v2/gelonghui/hot-article.js
+++ b/lib/v2/gelonghui/hot-article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseItem } = require('./utils');
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `最热文章 - ${type === 0 ? '日排行' : '周排行'} - 格隆汇`,
diff --git a/lib/v2/gelonghui/keyword.js b/lib/v2/gelonghui/keyword.js
index a162f3260..3325965d5 100644
--- a/lib/v2/gelonghui/keyword.js
+++ b/lib/v2/gelonghui/keyword.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { parseItem } = require('./utils');
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.timestamp, 'X'),
}));
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `格隆汇 - 关键词 “${keyword}” 的文章`,
diff --git a/lib/v2/gelonghui/subject.js b/lib/v2/gelonghui/subject.js
index a00dcee9e..177a47674 100644
--- a/lib/v2/gelonghui/subject.js
+++ b/lib/v2/gelonghui/subject.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.timestamp, 'X'),
}));
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `格隆汇 - 主题 ${$('span.user-nick').text()} 的文章`,
diff --git a/lib/v2/gelonghui/user.js b/lib/v2/gelonghui/user.js
index 8967e73fb..92eb0c49a 100644
--- a/lib/v2/gelonghui/user.js
+++ b/lib/v2/gelonghui/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { parseItem } = require('./utils');
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.createTimestamp, 'X'),
}));
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `格隆汇 - 用户 ${data.result[0].user.nick} 的文章`,
diff --git a/lib/v2/getdr/index.js b/lib/v2/getdr/index.js
index 1634fefaf..48f3254c5 100644
--- a/lib/v2/getdr/index.js
+++ b/lib/v2/getdr/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gf-cn/news.js b/lib/v2/gf-cn/news.js
index fc6beae2a..d46c2005b 100644
--- a/lib/v2/gf-cn/news.js
+++ b/lib/v2/gf-cn/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: `${apiRootUrl}/website/news/${item.guid}`,
diff --git a/lib/v2/gitee/repos/commits.js b/lib/v2/gitee/repos/commits.js
index d58e75c71..514db848b 100644
--- a/lib/v2/gitee/repos/commits.js
+++ b/lib/v2/gitee/repos/commits.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const { owner, repo } = ctx.params;
const apiUrl = `https://gitee.com/api/v5/repos/${owner}/${repo}/commits`;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
apiUrl,
async () =>
(
diff --git a/lib/v2/gitee/repos/events.js b/lib/v2/gitee/repos/events.js
index 3c9ee6080..df49aff17 100644
--- a/lib/v2/gitee/repos/events.js
+++ b/lib/v2/gitee/repos/events.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const { owner, repo } = ctx.params;
const apiUrl = `https://gitee.com/api/v5/repos/${owner}/${repo}/events`;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
apiUrl,
async () =>
(
diff --git a/lib/v2/gitee/users/events.js b/lib/v2/gitee/users/events.js
index 12a4fd3e9..5d94616c7 100644
--- a/lib/v2/gitee/users/events.js
+++ b/lib/v2/gitee/users/events.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const { username } = ctx.params;
const apiUrl = `https://gitee.com/api/v5/users/${username}/events/public`;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
apiUrl,
async () =>
(
diff --git a/lib/v2/gitpod/blog.js b/lib/v2/gitpod/blog.js
index cc69f5e84..0da0c3f8a 100644
--- a/lib/v2/gitpod/blog.js
+++ b/lib/v2/gitpod/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/google/news.js b/lib/v2/google/news.js
index 5888543b0..bce70484b 100644
--- a/lib/v2/google/news.js
+++ b/lib/v2/google/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const category = ctx.req.param('category');
const locale = ctx.req.param('locale');
- const categoryUrls = await ctx.cache.tryGet(`google:news:${locale}`, async () => {
+ const categoryUrls = await cache.tryGet(`google:news:${locale}`, async () => {
const { data: front_data } = await got(`${baseUrl}/?${locale}`);
const $ = load(front_data);
diff --git a/lib/v2/google/search.js b/lib/v2/google/search.js
index bd022744d..7922b9b2f 100644
--- a/lib/v2/google/search.js
+++ b/lib/v2/google/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
tempUrl.search = searchParams.toString();
const url = tempUrl.toString();
const key = `google-search:${language}:${url}`;
- const items = await ctx.cache.tryGet(
+ const items = await cache.tryGet(
key,
async () => {
const response = (
diff --git a/lib/v2/gov/anhui/kjt.js b/lib/v2/gov/anhui/kjt.js
index 1736e7361..15d1e7382 100644
--- a/lib/v2/gov/anhui/kjt.js
+++ b/lib/v2/gov/anhui/kjt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/beijing/bjedu/gh.js b/lib/v2/gov/beijing/bjedu/gh.js
index c098cdc76..3687435fa 100644
--- a/lib/v2/gov/beijing/bjedu/gh.js
+++ b/lib/v2/gov/beijing/bjedu/gh.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.endsWith('.html')) {
return item;
}
diff --git a/lib/v2/gov/beijing/bphc/index.js b/lib/v2/gov/beijing/bphc/index.js
index 03bbb34dd..9863322ca 100644
--- a/lib/v2/gov/beijing/bphc/index.js
+++ b/lib/v2/gov/beijing/bphc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) => {
const detail = `${rootUrl}${obj.detail}/${item.id}`;
- return ctx.cache.tryGet(detail, async () => {
+ return cache.tryGet(detail, async () => {
const detailResponse = await got(detail).json();
const description = (detailResponse.data?.content || detailResponse.data?.introduction) ?? '';
const single = {
diff --git a/lib/v2/gov/beijing/jw/tzgg.js b/lib/v2/gov/beijing/jw/tzgg.js
index e9dc980b7..4b16791ae 100644
--- a/lib/v2/gov/beijing/jw/tzgg.js
+++ b/lib/v2/gov/beijing/jw/tzgg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/beijing/kw/index.js b/lib/v2/gov/beijing/kw/index.js
index 26f47fc5d..07321a43f 100644
--- a/lib/v2/gov/beijing/kw/index.js
+++ b/lib/v2/gov/beijing/kw/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const content = await got.get(item.link);
const $ = load(content.data);
item.description = $('#zoom').html() || $('div.left.zhengce_right').html();
diff --git a/lib/v2/gov/cac/index.js b/lib/v2/gov/cac/index.js
index 50846cd7f..8f5702a06 100644
--- a/lib/v2/gov/cac/index.js
+++ b/lib/v2/gov/cac/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const homepage = `${host}/index.htm`;
// 在首页查找出所有的目录完整路径,比如http://www.cac.gov.cn/xxh/A0906index_1.htm
// xxh --> {"path": "/xxh", "completeUrl": "http://www.cac.gov.cn/xxh/A0906index_1.htm"}
- const pathList = await ctx.cache.tryGet(
+ const pathList = await cache.tryGet(
'gov:cac:pathList',
async () => {
const { data: homepageResponse } = await got(homepage);
diff --git a/lib/v2/gov/ccdi/utils.js b/lib/v2/gov/ccdi/utils.js
index 542b7723e..5f8be7bc6 100644
--- a/lib/v2/gov/ccdi/utils.js
+++ b/lib/v2/gov/ccdi/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
@@ -62,9 +63,9 @@ const changeTrCookie = async () => {
}
};
-const parseArticle = async (item, ctx) => {
+const parseArticle = async (item) => {
await changeTrCookie();
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const response = await got(item.link, { cookieJar });
const data = response.data;
await parseCookie(data);
diff --git a/lib/v2/gov/chinamine-safety/xw.js b/lib/v2/gov/chinamine-safety/xw.js
index 18c32a29d..553f272ea 100644
--- a/lib/v2/gov/chinamine-safety/xw.js
+++ b/lib/v2/gov/chinamine-safety/xw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
};
});
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
ctx.set('data', {
item: items,
diff --git a/lib/v2/gov/chinamine-safety/zfxxgk.js b/lib/v2/gov/chinamine-safety/zfxxgk.js
index 0432e25f0..0e37fce02 100644
--- a/lib/v2/gov/chinamine-safety/zfxxgk.js
+++ b/lib/v2/gov/chinamine-safety/zfxxgk.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
};
});
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
ctx.set('data', {
item: items,
diff --git a/lib/v2/gov/chinatax/latest.js b/lib/v2/gov/chinatax/latest.js
index ba5223c31..7c0512001 100644
--- a/lib/v2/gov/chinatax/latest.js
+++ b/lib/v2/gov/chinatax/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const res = await got({ method: 'get', url: item.link });
const content = load(res.data);
diff --git a/lib/v2/gov/chongqing/gzw.js b/lib/v2/gov/chongqing/gzw.js
index f0722fab6..e9260ab83 100644
--- a/lib/v2/gov/chongqing/gzw.js
+++ b/lib/v2/gov/chongqing/gzw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/chongqing/rsks.js b/lib/v2/gov/chongqing/rsks.js
index 0427b5553..46b827571 100644
--- a/lib/v2/gov/chongqing/rsks.js
+++ b/lib/v2/gov/chongqing/rsks.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
// 获取考试信息正文
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.pubDate = parseDate($('meta[name="PubDate"]').attr('content')) ?? item.pubDate;
diff --git a/lib/v2/gov/chongqing/sydwgkzp.js b/lib/v2/gov/chongqing/sydwgkzp.js
index b0c666431..6367846fc 100644
--- a/lib/v2/gov/chongqing/sydwgkzp.js
+++ b/lib/v2/gov/chongqing/sydwgkzp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
// 获取每个通知的具体信息
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
// 主题正文
diff --git a/lib/v2/gov/cmse/index.js b/lib/v2/gov/cmse/index.js
index 1552b2aed..9bfeae5ba 100644
--- a/lib/v2/gov/cmse/index.js
+++ b/lib/v2/gov/cmse/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/cnnic/index.js b/lib/v2/gov/cnnic/index.js
index 093adbf07..e0e63947a 100644
--- a/lib/v2/gov/cnnic/index.js
+++ b/lib/v2/gov/cnnic/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/csrc/news.js b/lib/v2/gov/csrc/news.js
index dc3bdeaf6..0c3f46d47 100644
--- a/lib/v2/gov/csrc/news.js
+++ b/lib/v2/gov/csrc/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: res } = await got(item.link);
const $ = load(res);
item.description = $('.detail-news').html();
diff --git a/lib/v2/gov/customs/list.js b/lib/v2/gov/customs/list.js
index a9d18ce21..8ef040325 100644
--- a/lib/v2/gov/customs/list.js
+++ b/lib/v2/gov/customs/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
const { host, puppeteerGet } = require('./utils');
import { config } from '@/config';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const browser = puppeteer({ stealth: true });
- const list = await ctx.cache.tryGet(
+ const list = await cache.tryGet(
link,
async () => {
const response = await puppeteerGet(link, browser);
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((info) =>
- ctx.cache.tryGet(info.link, async () => {
+ cache.tryGet(info.link, async () => {
const response = await puppeteerGet(info.link, browser);
const $ = load(response);
let date;
diff --git a/lib/v2/gov/forestry/gjlckjdjt.js b/lib/v2/gov/forestry/gjlckjdjt.js
index a779f4891..332fc1fa2 100644
--- a/lib/v2/gov/forestry/gjlckjdjt.js
+++ b/lib/v2/gov/forestry/gjlckjdjt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/general/general.js b/lib/v2/gov/general/general.js
index 3196ac11e..013b58128 100644
--- a/lib/v2/gov/general/general.js
+++ b/lib/v2/gov/general/general.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 来人拯救一下啊( >﹏<。)
// 待做功能:
// 1. 传入和处理
@@ -168,7 +169,7 @@ const gdgov = async (info, ctx) => {
// http://smzj.maoming.gov.cn/zcjdpt?id=4595
// http://fgj.maoming.gov.cn/zcjdpt?id=4993
// https://zcjd.cloud.gd.gov.cn/api/home/article?id=4993
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const zcjdlink = 'https://zcjd.cloud.gd.gov.cn/api/home/article' + idlink.search;
const response = await got(zcjdlink);
const data = response.data.data;
@@ -188,7 +189,7 @@ const gdgov = async (info, ctx) => {
const { finishArticleItem } = require('@/utils/wechat-mp');
return finishArticleItem({ link });
} else {
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
// 获取网页
const { data: res } = await got(link);
const content = load(res);
diff --git a/lib/v2/gov/hebei/czt.js b/lib/v2/gov/hebei/czt.js
index 28f829d13..6711c5f85 100644
--- a/lib/v2/gov/hebei/czt.js
+++ b/lib/v2/gov/hebei/czt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/huizhou/zwgk/index.js b/lib/v2/gov/huizhou/zwgk/index.js
index a6520d2e0..af1477f5e 100644
--- a/lib/v2/gov/huizhou/zwgk/index.js
+++ b/lib/v2/gov/huizhou/zwgk/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/gov/hunan/changsha/major-email.js b/lib/v2/gov/hunan/changsha/major-email.js
index dcca43e4f..6dab58fe1 100644
--- a/lib/v2/gov/hunan/changsha/major-email.js
+++ b/lib/v2/gov/hunan/changsha/major-email.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const postPage = await got(item.link, {
responseType: 'buffer',
});
diff --git a/lib/v2/gov/jgjcndrc/index.js b/lib/v2/gov/jgjcndrc/index.js
index 94a03bf9e..c43732ded 100644
--- a/lib/v2/gov/jgjcndrc/index.js
+++ b/lib/v2/gov/jgjcndrc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/maonan/maonan.js b/lib/v2/gov/maonan/maonan.js
index 060b7b109..4e4402d50 100644
--- a/lib/v2/gov/maonan/maonan.js
+++ b/lib/v2/gov/maonan/maonan.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -54,7 +55,7 @@ module.exports = async (ctx) => {
const pubDate = timezone(parseDate($('a[href="' + link + '"] ~ .time').text()), +8);
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
// 获取网页
const { data: res } = await got(link);
const content = load(res);
diff --git a/lib/v2/gov/mee/ywdt.js b/lib/v2/gov/mee/ywdt.js
index a8ed12f92..fc38749d5 100644
--- a/lib/v2/gov/mee/ywdt.js
+++ b/lib/v2/gov/mee/ywdt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
try {
diff --git a/lib/v2/gov/mem/sgcc.js b/lib/v2/gov/mem/sgcc.js
index d95f653ed..c3712be16 100644
--- a/lib/v2/gov/mem/sgcc.js
+++ b/lib/v2/gov/mem/sgcc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.endsWith('html')) {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/gov/mfa/wjdt.js b/lib/v2/gov/mfa/wjdt.js
index b15ac25c2..ab9a2e3c7 100644
--- a/lib/v2/gov/mfa/wjdt.js
+++ b/lib/v2/gov/mfa/wjdt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/miit/wjfb.js b/lib/v2/gov/miit/wjfb.js
index 6f0f88b4e..aaeabb7d1 100644
--- a/lib/v2/gov/miit/wjfb.js
+++ b/lib/v2/gov/miit/wjfb.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/gov/miit/wjgs.js b/lib/v2/gov/miit/wjgs.js
index eab4600b5..68ff003fd 100644
--- a/lib/v2/gov/miit/wjgs.js
+++ b/lib/v2/gov/miit/wjgs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/gov/miit/yjzj.js b/lib/v2/gov/miit/yjzj.js
index 8069ed130..80b764d04 100644
--- a/lib/v2/gov/miit/yjzj.js
+++ b/lib/v2/gov/miit/yjzj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/gov/miit/zcjd.js b/lib/v2/gov/miit/zcjd.js
index a341aca38..9afe84bc1 100644
--- a/lib/v2/gov/miit/zcjd.js
+++ b/lib/v2/gov/miit/zcjd.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/gov/miit/zcwj.js b/lib/v2/gov/miit/zcwj.js
index bfdd6de47..af1a2cc70 100644
--- a/lib/v2/gov/miit/zcwj.js
+++ b/lib/v2/gov/miit/zcwj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -23,9 +24,9 @@ module.exports = async (ctx) => {
link = base_url + link;
}
- const cache = await ctx.cache.get(link);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(link);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got({
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
link,
};
- ctx.cache.set(link, JSON.stringify(single));
+ cache.set(link, JSON.stringify(single));
return single;
})
);
diff --git a/lib/v2/gov/moa/moa.js b/lib/v2/gov/moa/moa.js
index 9e3d3b164..c9c6bad45 100644
--- a/lib/v2/gov/moa/moa.js
+++ b/lib/v2/gov/moa/moa.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -72,9 +73,9 @@ async function dealChannel(ctx, suburl, selectors) {
pageInfos.map(async (item) => {
const link = item.link;
- const cache = await ctx.cache.get(link);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(link);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
if (item.pageType === 'normal') {
@@ -89,7 +90,7 @@ async function dealChannel(ctx, suburl, selectors) {
item.author = 'unknown';
}
- ctx.cache.set(link, JSON.stringify(item));
+ cache.set(link, JSON.stringify(item));
return item;
})
);
diff --git a/lib/v2/gov/moa/zdscxx.js b/lib/v2/gov/moa/zdscxx.js
index d26a0828f..771793ab0 100644
--- a/lib/v2/gov/moa/zdscxx.js
+++ b/lib/v2/gov/moa/zdscxx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -58,7 +59,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const { data: detailResponse } = await got.post(apiDetailUrl, {
form: {
id: item.link,
diff --git a/lib/v2/gov/moe/moe.js b/lib/v2/gov/moe/moe.js
index 06587899c..fc1bbe4a2 100644
--- a/lib/v2/gov/moe/moe.js
+++ b/lib/v2/gov/moe/moe.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const logger = require('@/utils/logger');
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
? {
description: firstA.html(),
}
- : await ctx.cache.tryGet(itemUrl, async () => {
+ : await cache.tryGet(itemUrl, async () => {
const res = {};
const response = await got({
method: 'get',
diff --git a/lib/v2/gov/moe/s78.js b/lib/v2/gov/moe/s78.js
index d6f74a356..e2c1b824b 100644
--- a/lib/v2/gov/moe/s78.js
+++ b/lib/v2/gov/moe/s78.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/gov/mof/bond.js b/lib/v2/gov/mof/bond.js
index 9f032b803..c520048f7 100644
--- a/lib/v2/gov/mof/bond.js
+++ b/lib/v2/gov/mof/bond.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
indexes.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
item.description = content('div.my_doccontent').html();
diff --git a/lib/v2/gov/mofcom/article.js b/lib/v2/gov/mofcom/article.js
index 06d3a2ec1..da3057fb3 100644
--- a/lib/v2/gov/mofcom/article.js
+++ b/lib/v2/gov/mofcom/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let responses = await got(item.link);
// xwfb/xwlxfbh || xwfb/xwztfbh
const redirect = responses.data.match(/_cofing1={href:"(.*)",type/) || responses.data.match(/window\.location\.href='(.*)'/);
diff --git a/lib/v2/gov/moj/aac/news.js b/lib/v2/gov/moj/aac/news.js
index bd9b95a31..68d54fc78 100644
--- a/lib/v2/gov/moj/aac/news.js
+++ b/lib/v2/gov/moj/aac/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.isDownload) {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/gov/moj/lfyjzj.js b/lib/v2/gov/moj/lfyjzj.js
index b16ef952b..f90253181 100644
--- a/lib/v2/gov/moj/lfyjzj.js
+++ b/lib/v2/gov/moj/lfyjzj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
indexes.map((item) =>
- ctx.cache.tryGet(`gov:mof:${item.link}`, async () => {
+ cache.tryGet(`gov:mof:${item.link}`, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
item.description = content('div.TRS_Editor').html();
diff --git a/lib/v2/gov/mot/index.js b/lib/v2/gov/mot/index.js
index dd7231502..c56570a3c 100644
--- a/lib/v2/gov/mot/index.js
+++ b/lib/v2/gov/mot/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/\.gov\.cn/.test(item.link) && item.link.endsWith('.html')) {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/gov/ndrc/fggz.js b/lib/v2/gov/ndrc/fggz.js
index 6e089c7c1..c25bfd8b0 100644
--- a/lib/v2/gov/ndrc/fggz.js
+++ b/lib/v2/gov/ndrc/fggz.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/ndrc/xwdt.js b/lib/v2/gov/ndrc/xwdt.js
index c7fbc2d99..71810f4f9 100644
--- a/lib/v2/gov/ndrc/xwdt.js
+++ b/lib/v2/gov/ndrc/xwdt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/nea/ghs.js b/lib/v2/gov/nea/ghs.js
index 60f2ddb25..025e8f42f 100644
--- a/lib/v2/gov/nea/ghs.js
+++ b/lib/v2/gov/nea/ghs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/news/index.js b/lib/v2/gov/news/index.js
index 023cc1d18..0f71a7de5 100644
--- a/lib/v2/gov/news/index.js
+++ b/lib/v2/gov/news/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const logger = require('@/utils/logger');
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
item = $(item);
let contentUrl = item.find('a').attr('href');
contentUrl = contentUrl.startsWith('http') ? contentUrl : new URL(contentUrl, url).href;
- return ctx.cache.tryGet(contentUrl, async () => {
+ return cache.tryGet(contentUrl, async () => {
let description;
let fullTextData;
let fullTextGet;
diff --git a/lib/v2/gov/nifdc/index.js b/lib/v2/gov/nifdc/index.js
index b92112a51..9f380c07b 100644
--- a/lib/v2/gov/nifdc/index.js
+++ b/lib/v2/gov/nifdc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/gov/nmpa/generic.js b/lib/v2/gov/nmpa/generic.js
index 7f512e82a..c9a8167b7 100644
--- a/lib/v2/gov/nmpa/generic.js
+++ b/lib/v2/gov/nmpa/generic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -9,7 +10,7 @@ import got from '@/utils/got';
module.exports = async (ctx) => {
const path = ctx.params[0];
const url = `${baseUrl}/${path.endsWith('/') ? path.slice(0, -1) : path}/index.html`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
url,
async () => {
const { data: html } = await got(url);
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.items.map((item) => {
if (/^https:\/\/www\.nmpa\.gov\.cn\//.test(item.link)) {
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const { data: html } = await got(item.link);
const $ = load(html);
item.description = $('.text').html();
diff --git a/lib/v2/gov/nopss/index.js b/lib/v2/gov/nopss/index.js
index 577fce6e5..8825c2907 100644
--- a/lib/v2/gov/nopss/index.js
+++ b/lib/v2/gov/nopss/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/npc/index.js b/lib/v2/gov/npc/index.js
index ad3829e21..d93df812f 100644
--- a/lib/v2/gov/npc/index.js
+++ b/lib/v2/gov/npc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
// 获取标题、日期、内容
const items = await Promise.all(
links.map((link) =>
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
const response = await got(link);
const data = response.data;
const $ = load(data);
diff --git a/lib/v2/gov/nrta/dsj.js b/lib/v2/gov/nrta/dsj.js
index f78ed2184..6979ad660 100644
--- a/lib/v2/gov/nrta/dsj.js
+++ b/lib/v2/gov/nrta/dsj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const results = [];
for await (const item of asyncPool(5, items, (item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/nrta/news.js b/lib/v2/gov/nrta/news.js
index cee8d581d..a62606183 100644
--- a/lib/v2/gov/nrta/news.js
+++ b/lib/v2/gov/nrta/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/nsfc/index.js b/lib/v2/gov/nsfc/index.js
index 79053636d..a75bbd14f 100644
--- a/lib/v2/gov/nsfc/index.js
+++ b/lib/v2/gov/nsfc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link, {
https: {
rejectUnauthorized: false,
diff --git a/lib/v2/gov/pbc/goutongjiaoliu.js b/lib/v2/gov/pbc/goutongjiaoliu.js
index b17aea54b..8d37584d2 100644
--- a/lib/v2/gov/pbc/goutongjiaoliu.js
+++ b/lib/v2/gov/pbc/goutongjiaoliu.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailPage = await browser.newPage();
await detailPage.setRequestInterception(true);
detailPage.on('request', (request) => {
diff --git a/lib/v2/gov/pbc/trade-announcement.js b/lib/v2/gov/pbc/trade-announcement.js
index b45800962..c131dcb2c 100644
--- a/lib/v2/gov/pbc/trade-announcement.js
+++ b/lib/v2/gov/pbc/trade-announcement.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailPage = await browser.newPage();
await detailPage.setRequestInterception(true);
detailPage.on('request', (request) => {
diff --git a/lib/v2/gov/pbc/utils.js b/lib/v2/gov/pbc/utils.js
index b5f3b749c..02af3422c 100644
--- a/lib/v2/gov/pbc/utils.js
+++ b/lib/v2/gov/pbc/utils.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
-const processItems = (list, ctx) =>
+const processItems = (list) =>
Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.post(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/gov/sasac/generic.js b/lib/v2/gov/sasac/generic.js
index 501f3fe8c..6e10d1e99 100644
--- a/lib/v2/gov/sasac/generic.js
+++ b/lib/v2/gov/sasac/generic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
$('style, #qr_container, #div_div, [class^=jiathis]').remove();
diff --git a/lib/v2/gov/shaanxi/kjt.js b/lib/v2/gov/shaanxi/kjt.js
index 6134fcc54..fb8339d1f 100644
--- a/lib/v2/gov/shaanxi/kjt.js
+++ b/lib/v2/gov/shaanxi/kjt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/shanghai/wgj/wgj.js b/lib/v2/gov/shanghai/wgj/wgj.js
index 6e86ad7d1..8a3a62832 100644
--- a/lib/v2/gov/shanghai/wgj/wgj.js
+++ b/lib/v2/gov/shanghai/wgj/wgj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: baseUrl + item.link,
diff --git a/lib/v2/gov/shanghai/yjj/index.js b/lib/v2/gov/shanghai/yjj/index.js
index bf9c86270..ac09b5e68 100644
--- a/lib/v2/gov/shanghai/yjj/index.js
+++ b/lib/v2/gov/shanghai/yjj/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/gov/shenzhen/xxgk/zfxxgj.js b/lib/v2/gov/shenzhen/xxgk/zfxxgj.js
index d16d56aea..2f8ae9637 100644
--- a/lib/v2/gov/shenzhen/xxgk/zfxxgj.js
+++ b/lib/v2/gov/shenzhen/xxgk/zfxxgj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
item.description = content('div.news_cont_d_wrap').html();
diff --git a/lib/v2/gov/sichuan/deyang/govpublicinfo.js b/lib/v2/gov/sichuan/deyang/govpublicinfo.js
index f292c40f2..0f050a42f 100644
--- a/lib/v2/gov/sichuan/deyang/govpublicinfo.js
+++ b/lib/v2/gov/sichuan/deyang/govpublicinfo.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ const getInfoUrlList = async (rootUrl, infoBasicUrl) => {
// 获取信息正文内容
const getInfoContent = (ctx, rootUrl, item) =>
- ctx.cache.tryGet(item.url, async () => {
+ cache.tryGet(item.url, async () => {
const response = await got(item.url);
// 部分网页会跳转其他类型网站,则不解析,直接附超链接
try {
diff --git a/lib/v2/gov/sichuan/deyang/mztoday.js b/lib/v2/gov/sichuan/deyang/mztoday.js
index 8c258cbda..de0cfaa24 100644
--- a/lib/v2/gov/sichuan/deyang/mztoday.js
+++ b/lib/v2/gov/sichuan/deyang/mztoday.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -104,7 +105,7 @@ const getInfoUrlList = async (url) => {
// 获取信息正文内容
const getInfoContent = (ctx, item) =>
- ctx.cache.tryGet(item.url, async () => {
+ cache.tryGet(item.url, async () => {
const response = await got(item.url);
const $ = load(response.data);
return {
diff --git a/lib/v2/gov/stats/index.js b/lib/v2/gov/stats/index.js
index 1f8e9a611..2c3abf99b 100644
--- a/lib/v2/gov/stats/index.js
+++ b/lib/v2/gov/stats/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/suzhou/doc.js b/lib/v2/gov/suzhou/doc.js
index 0ad94e492..bb2c38768 100644
--- a/lib/v2/gov/suzhou/doc.js
+++ b/lib/v2/gov/suzhou/doc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/gov/suzhou/fg.js b/lib/v2/gov/suzhou/fg.js
index 4029c0c63..6ca37546a 100644
--- a/lib/v2/gov/suzhou/fg.js
+++ b/lib/v2/gov/suzhou/fg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/suzhou/news.js b/lib/v2/gov/suzhou/news.js
index df51e92df..e392359ae 100644
--- a/lib/v2/gov/suzhou/news.js
+++ b/lib/v2/gov/suzhou/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -82,7 +83,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
infoList.map((item) =>
// 获取全文
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('ucapcontent').html();
diff --git a/lib/v2/gov/wuhan/whyw.js b/lib/v2/gov/wuhan/whyw.js
index 37bba319b..e3d544c62 100644
--- a/lib/v2/gov/wuhan/whyw.js
+++ b/lib/v2/gov/wuhan/whyw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/gov/xuzhou/hrss.js b/lib/v2/gov/xuzhou/hrss.js
index 5f4da4640..dbac67b4a 100644
--- a/lib/v2/gov/xuzhou/hrss.js
+++ b/lib/v2/gov/xuzhou/hrss.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/gov/zhejiang/gwy.js b/lib/v2/gov/zhejiang/gwy.js
index 604dfee5e..56a67bc7b 100644
--- a/lib/v2/gov/zhejiang/gwy.js
+++ b/lib/v2/gov/zhejiang/gwy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const { data: detailResponse } = await got.post(detailUrl, {
form: {
mkxh: item.category,
diff --git a/lib/v2/gov/zhengce/govall.js b/lib/v2/gov/zhengce/govall.js
index dc618e2e4..ae70daa3d 100644
--- a/lib/v2/gov/zhengce/govall.js
+++ b/lib/v2/gov/zhengce/govall.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let description = '';
try {
const contentData = await got(item.link);
diff --git a/lib/v2/gov/zhengce/index.js b/lib/v2/gov/zhengce/index.js
index 898e43c4b..786ca580e 100644
--- a/lib/v2/gov/zhengce/index.js
+++ b/lib/v2/gov/zhengce/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
.filter((item) => /https?:\/\/www\.gov\.cn\/zhengce.*content_\d+\.htm/.test(item.link))
.slice(0, limit)
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/gov/zhengce/wenjian.js b/lib/v2/gov/zhengce/wenjian.js
index a85240287..db5d0ed1f 100644
--- a/lib/v2/gov/zhengce/wenjian.js
+++ b/lib/v2/gov/zhengce/wenjian.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const contentData = await got(item.link);
const $ = load(contentData.data);
item.description = $('#UCAP-CONTENT').html();
diff --git a/lib/v2/grist/featured.js b/lib/v2/grist/featured.js
index 6a01a5265..728162f17 100644
--- a/lib/v2/grist/featured.js
+++ b/lib/v2/grist/featured.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getData, getList } = require('./utils');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
link,
};
});
- const itemData = await Promise.all(listItems.map((item) => ctx.cache.tryGet(item.link, async () => (await getData(`https://grist.org/wp-json/wp/v2/posts?slug='${item.link}'&_embed`))[0])));
+ const itemData = await Promise.all(listItems.map((item) => cache.tryGet(item.link, async () => (await getData(`https://grist.org/wp-json/wp/v2/posts?slug='${item.link}'&_embed`))[0])));
const items = await getList(itemData);
ctx.set('data', {
diff --git a/lib/v2/guancha/headline.js b/lib/v2/guancha/headline.js
index 6347a4db2..445fdccec 100644
--- a/lib/v2/guancha/headline.js
+++ b/lib/v2/guancha/headline.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/guancha/index.js b/lib/v2/guancha/index.js
index a03390799..155fd407f 100644
--- a/lib/v2/guancha/index.js
+++ b/lib/v2/guancha/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -109,7 +110,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
[...newsList, ...redianList, ...gundongList].map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/guancha/topic.js b/lib/v2/guancha/topic.js
index c3c7167cc..86b7a9d85 100644
--- a/lib/v2/guancha/topic.js
+++ b/lib/v2/guancha/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/guangdiu/index.js b/lib/v2/guangdiu/index.js
index 81d5b0665..1593fb0df 100644
--- a/lib/v2/guangdiu/index.js
+++ b/lib/v2/guangdiu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/guangdiu/rank.js b/lib/v2/guangdiu/rank.js
index 9bcd66dc0..98a110a02 100644
--- a/lib/v2/guangdiu/rank.js
+++ b/lib/v2/guangdiu/rank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/guangdiu/search.js b/lib/v2/guangdiu/search.js
index 8b30e9674..cd1fe1c24 100644
--- a/lib/v2/guangdiu/search.js
+++ b/lib/v2/guangdiu/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/guanhai/index.js b/lib/v2/guanhai/index.js
index e0a1ef187..d39138076 100644
--- a/lib/v2/guanhai/index.js
+++ b/lib/v2/guanhai/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.author = $('.source').text();
diff --git a/lib/v2/guduodata/daily.js b/lib/v2/guduodata/daily.js
index 7bddc1e00..a8f008e32 100644
--- a/lib/v2/guduodata/daily.js
+++ b/lib/v2/guduodata/daily.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const dayjs = require('dayjs');
import { art } from '@/utils/render';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
description: yestoday,
item: await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.url, async () => {
+ cache.tryGet(item.url, async () => {
const response = await got.get(`${item.url}&t=${now}`, {
headers: { Referer: `http://data.guduodata.com/` },
});
diff --git a/lib/v2/guokr/channel.js b/lib/v2/guokr/channel.js
index 7e9b130dd..4a338415d 100644
--- a/lib/v2/guokr/channel.js
+++ b/lib/v2/guokr/channel.js
@@ -1,8 +1,9 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
async function loadFullPage(ctx, id) {
const link = `https://apis.guokr.com/minisite/article/${id}.json`;
- const content = await ctx.cache.tryGet(link, async () => {
+ const content = await cache.tryGet(link, async () => {
const res = await got(link);
return res.data.result.content;
});
diff --git a/lib/v2/guokr/scientific.js b/lib/v2/guokr/scientific.js
index 2dbc39cd8..3cd068e45 100644
--- a/lib/v2/guokr/scientific.js
+++ b/lib/v2/guokr/scientific.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
description: '果壳网 科学人',
item: await Promise.all(
result.map((item) =>
- ctx.cache.tryGet(item.url, async () => {
+ cache.tryGet(item.url, async () => {
const res = await got(item.url);
const $ = load(res.data);
item.description = $('.eflYNZ #js_content').css('visibility', 'visible').html() ?? $('.bxHoEL').html();
diff --git a/lib/v2/gxmzu/lib.js b/lib/v2/gxmzu/lib.js
index 8ecf44758..fb77dea75 100644
--- a/lib/v2/gxmzu/lib.js
+++ b/lib/v2/gxmzu/lib.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入got库,该库用来请求网页数据
import got from '@/utils/got';
// 导入cheerio库,该库用来解析网页数据
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
// 使用缓存
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
// 排除非本站点的外链
if (item.link && !item.link.startsWith('https://library.gxmzu.edu.cn/')) {
item.description = '该通知无法直接预览,请点击原文链接↑查看';
diff --git a/lib/v2/gxmzu/utils/index.js b/lib/v2/gxmzu/utils/index.js
index 61912b870..5755e0081 100644
--- a/lib/v2/gxmzu/utils/index.js
+++ b/lib/v2/gxmzu/utils/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ async function getNoticeList(ctx, url, host, titleSelector, dateSelector, conten
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('.jsp')) {
item.description = '该通知无法直接预览,请点击原文链接↑查看';
} else {
diff --git a/lib/v2/gzdaily/app.js b/lib/v2/gzdaily/app.js
index e8bff5ee8..b6ac2ebc6 100644
--- a/lib/v2/gzdaily/app.js
+++ b/lib/v2/gzdaily/app.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hackernews/index.js b/lib/v2/hackernews/index.js
index 97a634d49..0e9dd2e6d 100644
--- a/lib/v2/hackernews/index.js
+++ b/lib/v2/hackernews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -51,7 +52,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
if (item.comments !== 'discuss' && type === 'comments') {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/hafu/utils.js b/lib/v2/hafu/utils.js
index 2f64c206d..e4e94ca40 100644
--- a/lib/v2/hafu/utils.js
+++ b/lib/v2/hafu/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -92,7 +93,7 @@ async function ggtzParse(ctx, $) {
const link = typeMap.ggtz.root + href;
const title = $(item).find('a[class=c269582]').attr('title');
- const result = await ctx.cache.tryGet(link, async () => {
+ const result = await cache.tryGet(link, async () => {
const { articleData, description } = await tryGetFullText(href, link, 'ggtz');
let author = '';
let pubDate = '';
@@ -139,7 +140,7 @@ async function jwcParse(ctx, $) {
const date = $(item).find('span[class=timestyle259713]').text();
const pubDate = parseDate(date, 'YYYY/MM/DD');
- const result = await ctx.cache.tryGet(link, async () => {
+ const result = await cache.tryGet(link, async () => {
const { articleData, description } = await tryGetFullText(href, link, 'jwc');
let author = '';
@@ -175,7 +176,7 @@ async function zsjycParse(ctx, $) {
const title = $(item).find('a[class=c127701]').attr('title');
- const result = await ctx.cache.tryGet(link, async () => {
+ const result = await cache.tryGet(link, async () => {
const { articleData, description } = await tryGetFullText(href, link, 'zsjyc');
let pubDate = '';
diff --git a/lib/v2/hakkatv/type.js b/lib/v2/hakkatv/type.js
index f9335a200..052eeda63 100644
--- a/lib/v2/hakkatv/type.js
+++ b/lib/v2/hakkatv/type.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(`${apiUrl}/api/news/read/${item.id}`);
item.category = data.tag.map((t) => t.tag);
item.description = data.content.replaceAll('\n', '
');
diff --git a/lib/v2/hameln/chapter.js b/lib/v2/hameln/chapter.js
index b3f9d0ceb..d880cb669 100644
--- a/lib/v2/hameln/chapter.js
+++ b/lib/v2/hameln/chapter.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const item_list = await Promise.all(
chapter_list.map((chapter) => {
chapter.link = `${link}/${chapter.link}`;
- return ctx.cache.tryGet(chapter.link, async () => {
+ return cache.tryGet(chapter.link, async () => {
const content = load(await get(chapter.link));
chapter.description = content('#honbun').html();
return chapter;
diff --git a/lib/v2/harvard/health/blog.js b/lib/v2/harvard/health/blog.js
index d1404be57..f6916ff79 100644
--- a/lib/v2/harvard/health/blog.js
+++ b/lib/v2/harvard/health/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hbr/topic.js b/lib/v2/hbr/topic.js
index ce8c8a382..a5e20adbc 100644
--- a/lib/v2/hbr/topic.js
+++ b/lib/v2/hbr/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hdu/cs/notice.js b/lib/v2/hdu/cs/notice.js
index cb7b48c5b..d8084b17e 100644
--- a/lib/v2/hdu/cs/notice.js
+++ b/lib/v2/hdu/cs/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await getSingleRecord();
const out = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
return {
diff --git a/lib/v2/hdu/cs/pg.js b/lib/v2/hdu/cs/pg.js
index c3f0542b8..c7db47711 100644
--- a/lib/v2/hdu/cs/pg.js
+++ b/lib/v2/hdu/cs/pg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await getSingleRecord();
const out = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
return {
diff --git a/lib/v2/hebtv/nong-bo-shi-zai-xing-dong.js b/lib/v2/hebtv/nong-bo-shi-zai-xing-dong.js
index a2d550226..b9b112ae4 100644
--- a/lib/v2/hebtv/nong-bo-shi-zai-xing-dong.js
+++ b/lib/v2/hebtv/nong-bo-shi-zai-xing-dong.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.slice(0, limit).map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const tenantId = detailResponse.match(/tenantid = '(\w+)';/)[1];
diff --git a/lib/v2/hellobtc/information.js b/lib/v2/hellobtc/information.js
index 207458ca4..eabc3ae84 100644
--- a/lib/v2/hellobtc/information.js
+++ b/lib/v2/hellobtc/information.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/hellobtc/kepu.js b/lib/v2/hellobtc/kepu.js
index 2e6d8da3a..ae64e0dc4 100644
--- a/lib/v2/hellobtc/kepu.js
+++ b/lib/v2/hellobtc/kepu.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/hellogithub/index.js b/lib/v2/hellogithub/index.js
index b596b6c00..01bbf7c1f 100644
--- a/lib/v2/hellogithub/index.js
+++ b/lib/v2/hellogithub/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailUrl = `${rootUrl}/_next/data/${buildId}/repository/${item.guid}.json`;
const detailResponse = await got({
diff --git a/lib/v2/hex-rays/index.js b/lib/v2/hex-rays/index.js
index 12272276f..ed3511ea8 100644
--- a/lib/v2/hex-rays/index.js
+++ b/lib/v2/hex-rays/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/hinatazaka46/news.js b/lib/v2/hinatazaka46/news.js
index 3c6f5fa1c..7fefe09ff 100644
--- a/lib/v2/hinatazaka46/news.js
+++ b/lib/v2/hinatazaka46/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hit/hitgs.js b/lib/v2/hit/hitgs.js
index 4ca277f3c..9a5e50440 100644
--- a/lib/v2/hit/hitgs.js
+++ b/lib/v2/hit/hitgs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link, {
headers: {
Referer: host,
diff --git a/lib/v2/hit/jwc.js b/lib/v2/hit/jwc.js
index fad58c4c4..0ce464729 100644
--- a/lib/v2/hit/jwc.js
+++ b/lib/v2/hit/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
links.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (type(item.link) === 'htm') {
try {
const { data } = await got(item.link);
diff --git a/lib/v2/hit/today.js b/lib/v2/hit/today.js
index 253fc0b04..41c0066a6 100644
--- a/lib/v2/hit/today.js
+++ b/lib/v2/hit/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const response = await got(item.link, {
headers: {
diff --git a/lib/v2/hitsz/article.js b/lib/v2/hitsz/article.js
index 3872239d1..d56aff4af 100644
--- a/lib/v2/hitsz/article.js
+++ b/lib/v2/hitsz/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
lists.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got.get(item.link);
const $ = load(response.data);
item.description = $('div.edittext').html().trim();
diff --git a/lib/v2/hitwh/today.js b/lib/v2/hitwh/today.js
index 4dd3ca929..d6cc87833 100644
--- a/lib/v2/hitwh/today.js
+++ b/lib/v2/hitwh/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
link: `${baseUrl}/1024/list.htm`,
item: await Promise.all(
links.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (type(item.link) === 'htm') {
try {
const { data } = await got(item.link, {
diff --git a/lib/v2/hizu/index.js b/lib/v2/hizu/index.js
index dbaffb1e8..3c44ae776 100644
--- a/lib/v2/hizu/index.js
+++ b/lib/v2/hizu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hk01/channel.js b/lib/v2/hk01/channel.js
index f195f704d..d856b1e13 100644
--- a/lib/v2/hk01/channel.js
+++ b/lib/v2/hk01/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
url: apiUrl,
});
- const items = await ProcessItems(response.data.items, ctx.req.query('limit'), ctx.cache.tryGet);
+ const items = await ProcessItems(response.data.items, ctx.req.query('limit'), cache.tryGet);
ctx.set('data', {
title: response.data.category ? `${response.data.category.publishName} | 香港01` : `Channel: ${id} | 香港01`,
diff --git a/lib/v2/hk01/hot.js b/lib/v2/hk01/hot.js
index 367f0c1c6..9e926f48f 100644
--- a/lib/v2/hk01/hot.js
+++ b/lib/v2/hk01/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
url: apiUrl,
});
- const items = await ProcessItems(response.data.items, ctx.req.query('limit'), ctx.cache.tryGet);
+ const items = await ProcessItems(response.data.items, ctx.req.query('limit'), cache.tryGet);
ctx.set('data', {
title: '熱門新聞、全城熱話及社會時事 | 香港01',
diff --git a/lib/v2/hk01/issue.js b/lib/v2/hk01/issue.js
index 1536e9b99..2bd1e3432 100644
--- a/lib/v2/hk01/issue.js
+++ b/lib/v2/hk01/issue.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
url: apiUrl,
});
- const items = await ProcessItems(response.data.blocks[0].articles, ctx.req.query('limit'), ctx.cache.tryGet);
+ const items = await ProcessItems(response.data.blocks[0].articles, ctx.req.query('limit'), cache.tryGet);
ctx.set('data', {
title: `${response.data.title} | 香港01`,
diff --git a/lib/v2/hk01/latest.js b/lib/v2/hk01/latest.js
index 3ac3911e2..ce9d74f97 100644
--- a/lib/v2/hk01/latest.js
+++ b/lib/v2/hk01/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
url: apiUrl,
});
- const items = await ProcessItems(response.data.items, ctx.req.query('limit'), ctx.cache.tryGet);
+ const items = await ProcessItems(response.data.items, ctx.req.query('limit'), cache.tryGet);
ctx.set('data', {
title: '即時 | 香港01',
diff --git a/lib/v2/hk01/tag.js b/lib/v2/hk01/tag.js
index 38fe5c3f6..6dc7ee38a 100644
--- a/lib/v2/hk01/tag.js
+++ b/lib/v2/hk01/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
url: apiUrl,
});
- const items = await ProcessItems(response.data.items, ctx.req.query('limit'), ctx.cache.tryGet);
+ const items = await ProcessItems(response.data.items, ctx.req.query('limit'), cache.tryGet);
ctx.set('data', {
title: `${id} | 香港01`,
diff --git a/lib/v2/hk01/zone.js b/lib/v2/hk01/zone.js
index cdca60317..aa4592931 100644
--- a/lib/v2/hk01/zone.js
+++ b/lib/v2/hk01/zone.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
url: apiUrl,
});
- const items = await ProcessItems(response.data.items, ctx.req.query('limit'), ctx.cache.tryGet);
+ const items = await ProcessItems(response.data.items, ctx.req.query('limit'), cache.tryGet);
ctx.set('data', {
title: `${response.data.category.publishName} | 香港01`,
diff --git a/lib/v2/hkej/index.js b/lib/v2/hkej/index.js
index 12e56d136..7fc5cc73c 100644
--- a/lib/v2/hkej/index.js
+++ b/lib/v2/hkej/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -93,7 +94,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list &&
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const article = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hkepc/index.js b/lib/v2/hkepc/index.js
index fad2868b3..94f61bc63 100644
--- a/lib/v2/hkepc/index.js
+++ b/lib/v2/hkepc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
headers: {
Referer: baseUrl,
diff --git a/lib/v2/hket/index.js b/lib/v2/hket/index.js
index 6f699f1ce..36f1bee9a 100644
--- a/lib/v2/hket/index.js
+++ b/lib/v2/hket/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.startsWith('https://invest.hket.com/') || item.link.startsWith('https://ps.hket.com/')) {
let data;
diff --git a/lib/v2/hkjunkcall/index.js b/lib/v2/hkjunkcall/index.js
index 8c0fc7c7f..b4b881931 100644
--- a/lib/v2/hkjunkcall/index.js
+++ b/lib/v2/hkjunkcall/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hljucm/yjsy.js b/lib/v2/hljucm/yjsy.js
index c43d70372..1b1627806 100644
--- a/lib/v2/hljucm/yjsy.js
+++ b/lib/v2/hljucm/yjsy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/hnrb/index.js b/lib/v2/hnrb/index.js
index 87550973c..cf7a8b150 100644
--- a/lib/v2/hnrb/index.js
+++ b/lib/v2/hnrb/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item, async () => {
+ cache.tryGet(item, async () => {
const detailResponse = await got({
method: 'get',
url: item,
diff --git a/lib/v2/hongkong/chp.js b/lib/v2/hongkong/chp.js
index 01b901213..549acc531 100644
--- a/lib/v2/hongkong/chp.js
+++ b/lib/v2/hongkong/chp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -75,7 +76,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if ((category === 'important_ft' || category === 'press_data_index') && (item.link.indexOf('htm') > 0 || item.link.indexOf('/features/') > 0)) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/hongkong/dh.js b/lib/v2/hongkong/dh.js
index 3b897ec05..cabc7fdb1 100644
--- a/lib/v2/hongkong/dh.js
+++ b/lib/v2/hongkong/dh.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hoyolab/news.js b/lib/v2/hoyolab/news.js
index 72fe1ed1d..d8c850d59 100644
--- a/lib/v2/hoyolab/news.js
+++ b/lib/v2/hoyolab/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const logger = require('@/utils/logger');
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ const getPostContent = (ctx, list, { language }) =>
language, // language为了区分缓存,对接口并无意义
}).toString();
const url = `${HOST}${POST_FULL}?${query}`;
- return await ctx.cache.tryGet(url, async () => {
+ return await cache.tryGet(url, async () => {
const res = await got({
method: 'get',
url,
@@ -78,8 +79,8 @@ module.exports = async (ctx) => {
language,
size: Number.parseInt(ctx.query?.limit) || 15,
};
- const gameInfo = await getI18nGameInfo(gids, language, ctx.cache.tryGet);
- const typeInfo = await getI18nType(language, ctx.cache.tryGet);
+ const gameInfo = await getI18nGameInfo(gids, language, cache.tryGet);
+ const typeInfo = await getI18nType(language, cache.tryGet);
const list = await getEventList(params);
const items = await getPostContent(ctx, list, params);
ctx.state.data = {
diff --git a/lib/v2/hrbeu/gx/list.js b/lib/v2/hrbeu/gx/list.js
index 1cf068aa6..8b0cdd556 100644
--- a/lib/v2/hrbeu/gx/list.js
+++ b/lib/v2/hrbeu/gx/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('info')) {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/hrbeu/job/list.js b/lib/v2/hrbeu/job/list.js
index c752b7303..e71007c6b 100644
--- a/lib/v2/hrbeu/job/list.js
+++ b/lib/v2/hrbeu/job/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('HrbeuJY')) {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/hrbeu/uae/news.js b/lib/v2/hrbeu/uae/news.js
index 3173789ad..4020b28b2 100644
--- a/lib/v2/hrbeu/uae/news.js
+++ b/lib/v2/hrbeu/uae/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (new URL(item.link).hostname === 'uae.hrbeu.edu.cn') {
const resp = await got(item.link);
const $1 = load(resp.data);
diff --git a/lib/v2/hrbeu/ugs/news.js b/lib/v2/hrbeu/ugs/news.js
index 570319f10..d0c7113a0 100644
--- a/lib/v2/hrbeu/ugs/news.js
+++ b/lib/v2/hrbeu/ugs/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -76,7 +77,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('.htm')) {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/hrbeu/yjsy/list.js b/lib/v2/hrbeu/yjsy/list.js
index 3bd8dd987..b33bf2841 100644
--- a/lib/v2/hrbeu/yjsy/list.js
+++ b/lib/v2/hrbeu/yjsy/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('page.htm')) {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/huanqiu/index.js b/lib/v2/huanqiu/index.js
index f24b83a8f..3f6aa9323 100644
--- a/lib/v2/huanqiu/index.js
+++ b/lib/v2/huanqiu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/hunanpea/rsks.js b/lib/v2/hunanpea/rsks.js
index bfdb9c606..c29d61d80 100644
--- a/lib/v2/hunanpea/rsks.js
+++ b/lib/v2/hunanpea/rsks.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/hunau/utils/common.js b/lib/v2/hunau/utils/common.js
index 21e34f13d..09d0bffb1 100644
--- a/lib/v2/hunau/utils/common.js
+++ b/lib/v2/hunau/utils/common.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// common.js
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -36,7 +37,7 @@ async function getContent(ctx, { baseHost, baseCategory, baseType, baseTitle, ba
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const content = await newsContent(item.link, baseDeparment);
item.pubDate = content.pubDate;
diff --git a/lib/v2/hupu/all.js b/lib/v2/hupu/all.js
index da1515323..a365f8ef0 100644
--- a/lib/v2/hupu/all.js
+++ b/lib/v2/hupu/all.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/hupu/bbs.js b/lib/v2/hupu/bbs.js
index 13a798eb8..40f39f081 100644
--- a/lib/v2/hupu/bbs.js
+++ b/lib/v2/hupu/bbs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
let detailResponse = await got({
method: 'get',
diff --git a/lib/v2/hupu/index.js b/lib/v2/hupu/index.js
index 7bb06255c..1b904f2d8 100644
--- a/lib/v2/hupu/index.js
+++ b/lib/v2/hupu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
items
.filter((item) => !/subject/.test(item.link))
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/huxiu/brief-column.js b/lib/v2/huxiu/brief-column.js
index 02259189f..7d24962c7 100644
--- a/lib/v2/huxiu/brief-column.js
+++ b/lib/v2/huxiu/brief-column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiBriefRootUrl, processItems, fetchBriefColumnData } = require('./util');
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
ctx.state.json = response.data.datalist;
- const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data.datalist, limit, cache.tryGet);
const data = await fetchBriefColumnData(id);
diff --git a/lib/v2/huxiu/channel.js b/lib/v2/huxiu/channel.js
index c49895017..ff7fd4d36 100644
--- a/lib/v2/huxiu/channel.js
+++ b/lib/v2/huxiu/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiArticleRootUrl, processItems, fetchData } = require('./util');
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
},
});
- const items = await processItems(response.data?.dataList ?? response.data.datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data?.dataList ?? response.data.datalist, limit, cache.tryGet);
const data = await fetchData(currentUrl);
diff --git a/lib/v2/huxiu/club.js b/lib/v2/huxiu/club.js
index d536295c9..3d7a00106 100644
--- a/lib/v2/huxiu/club.js
+++ b/lib/v2/huxiu/club.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiBriefRootUrl, processItems, fetchClubData } = require('./util');
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
ctx.state.json = response.data.datalist;
- const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data.datalist, limit, cache.tryGet);
ctx.set('data', {
item: items,
diff --git a/lib/v2/huxiu/collection.js b/lib/v2/huxiu/collection.js
index 58e19d799..1d975d82f 100644
--- a/lib/v2/huxiu/collection.js
+++ b/lib/v2/huxiu/collection.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiArticleRootUrl, processItems, fetchData } = require('./util');
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
},
});
- const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data.datalist, limit, cache.tryGet);
const data = await fetchData(currentUrl);
diff --git a/lib/v2/huxiu/member.js b/lib/v2/huxiu/member.js
index 4de314d73..e19f64e93 100644
--- a/lib/v2/huxiu/member.js
+++ b/lib/v2/huxiu/member.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiMemberRootUrl, processItems, fetchData } = require('./util');
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
},
});
- const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data.datalist, limit, cache.tryGet);
const data = await fetchData(currentUrl);
diff --git a/lib/v2/huxiu/moment.js b/lib/v2/huxiu/moment.js
index 5c6da1603..720de968c 100644
--- a/lib/v2/huxiu/moment.js
+++ b/lib/v2/huxiu/moment.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiMomentRootUrl, processItems, fetchData } = require('./util');
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
},
});
- const items = await processItems(response.data.moment_list.datalist[0].datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data.moment_list.datalist[0].datalist, limit, cache.tryGet);
const data = await fetchData(currentUrl);
diff --git a/lib/v2/huxiu/search.js b/lib/v2/huxiu/search.js
index 49ee29e3e..f9bcd68b5 100644
--- a/lib/v2/huxiu/search.js
+++ b/lib/v2/huxiu/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, apiSearchRootUrl, generateSignature, processItems, fetchData } = require('./util');
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
},
});
- const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data.datalist, limit, cache.tryGet);
const data = await fetchData(currentUrl);
data.title = `${keyword}-搜索结果-${data.title}`;
diff --git a/lib/v2/huxiu/tag.js b/lib/v2/huxiu/tag.js
index 4353599c7..21d4d144f 100644
--- a/lib/v2/huxiu/tag.js
+++ b/lib/v2/huxiu/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, processItems, fetchData } = require('./util');
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
},
});
- const items = await processItems(response.data, limit, ctx.cache.tryGet);
+ const items = await processItems(response.data, limit, cache.tryGet);
const data = await fetchData(currentUrl);
diff --git a/lib/v2/ianspriggs/index.js b/lib/v2/ianspriggs/index.js
index a36ece900..2312ce3cb 100644
--- a/lib/v2/ianspriggs/index.js
+++ b/lib/v2/ianspriggs/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/icac/news.js b/lib/v2/icac/news.js
index 38bc1fa2f..2995f0532 100644
--- a/lib/v2/icac/news.js
+++ b/lib/v2/icac/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ieee/earlyaccess.js b/lib/v2/ieee/earlyaccess.js
index 887440c48..29b220289 100644
--- a/lib/v2/ieee/earlyaccess.js
+++ b/lib/v2/ieee/earlyaccess.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -56,7 +57,7 @@ module.exports = async (ctx) => {
});
list = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.abstract !== '') {
const response3 = await got(`${host}${item.link}`);
const { abstract } = JSON.parse(response3.body.match(/metadata=(.*);/)[1]);
diff --git a/lib/v2/ieee/journal.js b/lib/v2/ieee/journal.js
index 1ba924196..05d443891 100644
--- a/lib/v2/ieee/journal.js
+++ b/lib/v2/ieee/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -57,7 +58,7 @@ module.exports = async (ctx) => {
});
list = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.abstract !== '') {
const response3 = await got(`${host}${item.link}`);
const { abstract } = JSON.parse(response3.body.match(/metadata=(.*);/)[1]);
diff --git a/lib/v2/ieee/recent.js b/lib/v2/ieee/recent.js
index 285a89997..b4daa8a6e 100644
--- a/lib/v2/ieee/recent.js
+++ b/lib/v2/ieee/recent.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -74,7 +75,7 @@ module.exports = async (ctx) => {
});
list = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.abstract !== '') {
const response3 = await got(`${host}${item.link}`);
const { abstract } = JSON.parse(response3.body.match(/metadata=(.*);/)[1]);
diff --git a/lib/v2/ielts/index.js b/lib/v2/ielts/index.js
index 04c298a95..f955383be 100644
--- a/lib/v2/ielts/index.js
+++ b/lib/v2/ielts/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
@@ -7,7 +8,7 @@ import { config } from '@/config';
import puppeteer from '@/utils/puppeteer';
module.exports = async (ctx) => {
- const html = await ctx.cache.tryGet(
+ const html = await cache.tryGet(
targetUrl,
async () => {
const browser = puppeteer({ stealth: true });
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ifeng/feng.js b/lib/v2/ifeng/feng.js
index 38fd51015..ac7a68dcb 100644
--- a/lib/v2/ifeng/feng.js
+++ b/lib/v2/ifeng/feng.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { extractDoc, renderVideo } = require('./utils');
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/ifeng/news.js b/lib/v2/ifeng/news.js
index 95d36d072..60c008dad 100644
--- a/lib/v2/ifeng/news.js
+++ b/lib/v2/ifeng/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/iguoguo/index.js b/lib/v2/iguoguo/index.js
index 1ad3f15a9..24324eaaf 100644
--- a/lib/v2/iguoguo/index.js
+++ b/lib/v2/iguoguo/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/imiker/jinghua.js b/lib/v2/imiker/jinghua.js
index 7c91635bf..4a056ecb1 100644
--- a/lib/v2/imiker/jinghua.js
+++ b/lib/v2/imiker/jinghua.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/indiansinkuwait/latest.js b/lib/v2/indiansinkuwait/latest.js
index b02dafcf3..787a77c58 100644
--- a/lib/v2/indiansinkuwait/latest.js
+++ b/lib/v2/indiansinkuwait/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/indienova/article.js b/lib/v2/indienova/article.js
index 083e10098..3a2886d51 100644
--- a/lib/v2/indienova/article.js
+++ b/lib/v2/indienova/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseList, parseItem } = require('./utils');
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const $ = load(response.data);
const list = parseList($);
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/indienova/column.js b/lib/v2/indienova/column.js
index e2f693b58..0fbdd99a5 100644
--- a/lib/v2/indienova/column.js
+++ b/lib/v2/indienova/column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseList, parseItem } = require('./utils');
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const list = parseList($);
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/indienova/gamedb.js b/lib/v2/indienova/gamedb.js
index 5a64cebbd..e46a9c2fd 100644
--- a/lib/v2/indienova/gamedb.js
+++ b/lib/v2/indienova/gamedb.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/indienova/usergames.js b/lib/v2/indienova/usergames.js
index 732c871b2..8a72edb9f 100644
--- a/lib/v2/indienova/usergames.js
+++ b/lib/v2/indienova/usergames.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/inewsweek/index.js b/lib/v2/inewsweek/index.js
index d938ba3b9..d38e76c48 100644
--- a/lib/v2/inewsweek/index.js
+++ b/lib/v2/inewsweek/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
item = $(item);
const href = item.find('a').attr('href');
const articleLink = `${rootUrl}${href}`;
- return ctx.cache.tryGet(articleLink, async () => {
+ return cache.tryGet(articleLink, async () => {
const response = await got(articleLink, {
responseType: 'buffer',
});
diff --git a/lib/v2/informs/index.js b/lib/v2/informs/index.js
index 5e28304eb..2ba577b60 100644
--- a/lib/v2/informs/index.js
+++ b/lib/v2/informs/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const cateUrl = `${rootUrl}/toc/${category}/0/0`;
const getCookie = () =>
- ctx.cache.tryGet(cateUrl, async () => {
+ cache.tryGet(cateUrl, async () => {
const setCookiesUrl = `${cateUrl}?cookieSet=1`;
const response = await got.extend({ followRedirect: false }).get(setCookiesUrl, {
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link, {
headers: {
referer: cateUrl,
diff --git a/lib/v2/instagram/private-api/index.js b/lib/v2/instagram/private-api/index.js
index 5328007e5..bb032a53c 100644
--- a/lib/v2/instagram/private-api/index.js
+++ b/lib/v2/instagram/private-api/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { ig, login } = require('./utils');
const logger = require('@/utils/logger');
import { config } from '@/config';
@@ -75,7 +76,7 @@ module.exports = async (ctx) => {
let data;
try {
- data = await loadContent(category, key, ctx.cache.tryGet);
+ data = await loadContent(category, key, cache.tryGet);
} catch (error) {
logger.error(`Instagram error: ${error}`);
throw error;
diff --git a/lib/v2/instagram/web-api/index.js b/lib/v2/instagram/web-api/index.js
index 453294e77..28cdb435c 100644
--- a/lib/v2/instagram/web-api/index.js
+++ b/lib/v2/instagram/web-api/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { CookieJar } = require('tough-cookie');
import { config } from '@/config';
const { renderItems } = require('../common-utils');
@@ -14,8 +15,8 @@ module.exports = async (ctx) => {
throw new Error('Such feed is not supported.');
}
- let cookieJar = await ctx.cache.get('instagram:cookieJar');
- const wwwClaimV2 = await ctx.cache.get('instagram:wwwClaimV2');
+ let cookieJar = await cache.get('instagram:cookieJar');
+ const wwwClaimV2 = await cache.get('instagram:wwwClaimV2');
const cacheMiss = !cookieJar;
if (cacheMiss) {
@@ -61,7 +62,7 @@ module.exports = async (ctx) => {
feedLink = `${baseUrl}/explore/tags/${tag}`;
if (cookie) {
- items = await getTagsFeedItems(tag, 'recent', cookieJar, ctx.cache.tryGet);
+ items = await getTagsFeedItems(tag, 'recent', cookieJar, cache.tryGet);
} else {
const hashTag = await getLoggedOutTagsFeedItems(tag, cookieJar);
items = [...hashTag.edge_hashtag_to_media.edges, ...hashTag.edge_hashtag_to_top_posts.edges];
@@ -73,7 +74,7 @@ module.exports = async (ctx) => {
break;
}
- await ctx.cache.set('instagram:cookieJar', cookieJar.toJSON(), 31_536_000);
+ await cache.set('instagram:cookieJar', cookieJar.toJSON(), 31_536_000);
ctx.set('data', {
title: feedTitle,
diff --git a/lib/v2/iqilu/program.js b/lib/v2/iqilu/program.js
index 61fb3f5c2..edd659084 100644
--- a/lib/v2/iqilu/program.js
+++ b/lib/v2/iqilu/program.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -48,7 +49,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/iqiyi/video.js b/lib/v2/iqiyi/video.js
index 1f4dab1db..a2167576f 100644
--- a/lib/v2/iqiyi/video.js
+++ b/lib/v2/iqiyi/video.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { config } from '@/config';
import { parseDate } from '@/utils/parse-date';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
// Use puppeteer because iqiyi page has a delay.
const browser = puppeteer();
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
link,
async () => {
const page = await browser.newPage();
diff --git a/lib/v2/iqnew/latest.js b/lib/v2/iqnew/latest.js
index 8f3009018..43384b2a0 100644
--- a/lib/v2/iqnew/latest.js
+++ b/lib/v2/iqnew/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/iresearch/report.js b/lib/v2/iresearch/report.js
index b5e29a799..2a3e34821 100644
--- a/lib/v2/iresearch/report.js
+++ b/lib/v2/iresearch/report.js
@@ -1,14 +1,15 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-function processReport(item, ctx) {
+function processReport(item) {
const apiUrl = `https://www.iresearch.com.cn/api/Detail/reportM?id=${item.NewsId}&isfree=0`;
const pageUrl = 'https://www.iresearch.com.cn/m/report.shtml';
- const description = ctx.cache.tryGet(apiUrl, async () => {
+ const description = cache.tryGet(apiUrl, async () => {
const response = await got({
method: 'get',
url: apiUrl,
diff --git a/lib/v2/itch/devlog.js b/lib/v2/itch/devlog.js
index 2d7fc6deb..0cf3e5906 100644
--- a/lib/v2/itch/devlog.js
+++ b/lib/v2/itch/devlog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/itch/index.js b/lib/v2/itch/index.js
index b94c29512..0b43480bd 100644
--- a/lib/v2/itch/index.js
+++ b/lib/v2/itch/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ithome/index.js b/lib/v2/ithome/index.js
index d9c80551f..7085099a7 100644
--- a/lib/v2/ithome/index.js
+++ b/lib/v2/ithome/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got({ method: 'get', url: item.link });
const content = load(res.data);
const post = content('#paragraph');
diff --git a/lib/v2/ithome/ranking.js b/lib/v2/ithome/ranking.js
index c302f4cde..010da5c28 100644
--- a/lib/v2/ithome/ranking.js
+++ b/lib/v2/ithome/ranking.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ithome/tag.js b/lib/v2/ithome/tag.js
index d568644cd..38105b503 100644
--- a/lib/v2/ithome/tag.js
+++ b/lib/v2/ithome/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let detailResponse;
// handle 404 errors for some article URLs
diff --git a/lib/v2/ithome/tw/feeds.js b/lib/v2/ithome/tw/feeds.js
index e6e31bd91..859b11bd4 100644
--- a/lib/v2/ithome/tw/feeds.js
+++ b/lib/v2/ithome/tw/feeds.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
.get()
.map((item) => {
const link = baseUrl + $(item).attr('href');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response = await got(link);
const $ = load(response.data);
return {
diff --git a/lib/v2/ithome/zt.js b/lib/v2/ithome/zt.js
index 37c01aaa4..e730a4338 100644
--- a/lib/v2/ithome/zt.js
+++ b/lib/v2/ithome/zt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/iwara/index.js b/lib/v2/iwara/index.js
index a8e30e8ad..214d99159 100644
--- a/lib/v2/iwara/index.js
+++ b/lib/v2/iwara/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -36,9 +37,9 @@ const parseThumbnail = (type, item) => {
module.exports = async (ctx) => {
const username = ctx.req.param('username');
- const id = await ctx.cache.tryGet(`${apiRootUrl}/profile/${username}`, async () => (await got(`${apiRootUrl}/profile/${username}`)).data.user.id);
+ const id = await cache.tryGet(`${apiRootUrl}/profile/${username}`, async () => (await got(`${apiRootUrl}/profile/${username}`)).data.user.id);
const type = ctx.req.param('type') ?? 'video';
- const items = (await ctx.cache.tryGet(`${apiUrlMap[type]}?user=${id}`, async () => (await got(`${apiUrlMap[type]}?user=${id}`)).data.results, config.cache.routeExpire, false)).map((item) => ({
+ const items = (await cache.tryGet(`${apiUrlMap[type]}?user=${id}`, async () => (await got(`${apiUrlMap[type]}?user=${id}`)).data.results, config.cache.routeExpire, false)).map((item) => ({
title: item.title,
author: username,
link: `${rootUrl}/${type}/${item.id}/${item.slug}`,
diff --git a/lib/v2/iwara/subscriptions.js b/lib/v2/iwara/subscriptions.js
index 3bc8f57b3..7fd0b2aa0 100644
--- a/lib/v2/iwara/subscriptions.js
+++ b/lib/v2/iwara/subscriptions.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { art } from '@/utils/render';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const password = config.iwara.password;
// get refresh token
- const refreshHeaders = await ctx.cache.tryGet(
+ const refreshHeaders = await cache.tryGet(
'iwara:token',
async () => {
const loginResponse = await got({
@@ -97,7 +98,7 @@ module.exports = async (ctx) => {
const list = [...videoList, ...imageList];
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let description = art(path.join(__dirname, 'templates/subscriptions.art'), {
type: item.category,
imageUrl: item.imageUrl,
diff --git a/lib/v2/jandan/index.js b/lib/v2/jandan/index.js
index 560ea5c1f..d96f5ff94 100644
--- a/lib/v2/jandan/index.js
+++ b/lib/v2/jandan/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const parser = require('@/utils/rss-parser');
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const feed = await parser.parseURL(`${rootUrl}/feed/`);
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
$('.wechat-hide').prev().nextAll().remove();
diff --git a/lib/v2/javbus/index.js b/lib/v2/javbus/index.js
index 7042dcc91..0df69030d 100644
--- a/lib/v2/javbus/index.js
+++ b/lib/v2/javbus/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
@@ -69,7 +70,7 @@ module.exports = async (ctx) => {
.toArray()
.map((s) => content(s).text());
- const cache = {
+ const cacheIn = {
author: stars.join(', '),
title: content('h3').text(),
category: [
@@ -151,12 +152,12 @@ module.exports = async (ctx) => {
}
}
- item.author = cache.author;
- item.title = cache.title;
- item.category = cache.category;
+ item.author = cacheIn.author;
+ item.title = cacheIn.title;
+ item.category = cacheIn.category;
item.description = art(path.join(__dirname, 'templates/description.art'), {
- info: cache.info,
- thumbs: cache.thumbs,
+ info: cacheIn.info,
+ thumbs: cacheIn.thumbs,
magnets,
videoSrc,
videoPreview,
diff --git a/lib/v2/javdb/utils.js b/lib/v2/javdb/utils.js
index 3fcaf6049..14ad29693 100644
--- a/lib/v2/javdb/utils.js
+++ b/lib/v2/javdb/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/javlibrary/bestrated.js b/lib/v2/javlibrary/bestrated.js
index 245d3b479..32a30eb2e 100644
--- a/lib/v2/javlibrary/bestrated.js
+++ b/lib/v2/javlibrary/bestrated.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -5,5 +6,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_bestrated.php?list&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/bestreviews.js b/lib/v2/javlibrary/bestreviews.js
index fc130d09a..8d94e46e3 100644
--- a/lib/v2/javlibrary/bestreviews.js
+++ b/lib/v2/javlibrary/bestreviews.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -5,5 +6,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/tl_bestreviews.php?list&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/genre.js b/lib/v2/javlibrary/genre.js
index bca115761..986b27368 100644
--- a/lib/v2/javlibrary/genre.js
+++ b/lib/v2/javlibrary/genre.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultGenre, defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_genre.php?list&g=${genre}&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/maker.js b/lib/v2/javlibrary/maker.js
index 3dd6cd86a..ad9cda1ca 100644
--- a/lib/v2/javlibrary/maker.js
+++ b/lib/v2/javlibrary/maker.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultLanguage, defaultMaker, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_maker.php?list&m=${maker}&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/mostwanted.js b/lib/v2/javlibrary/mostwanted.js
index 0a8f24dde..fa7acfdd2 100644
--- a/lib/v2/javlibrary/mostwanted.js
+++ b/lib/v2/javlibrary/mostwanted.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -5,5 +6,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_mostwanted.php?list&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/newentries.js b/lib/v2/javlibrary/newentries.js
index 07306df14..1c10f0359 100644
--- a/lib/v2/javlibrary/newentries.js
+++ b/lib/v2/javlibrary/newentries.js
@@ -1,8 +1,9 @@
+import cache from '@/utils/cache';
const { defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_newentries.php?list`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/newrelease.js b/lib/v2/javlibrary/newrelease.js
index 639e0f55d..403a01718 100644
--- a/lib/v2/javlibrary/newrelease.js
+++ b/lib/v2/javlibrary/newrelease.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -5,5 +6,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_newrelease.php?list&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/star.js b/lib/v2/javlibrary/star.js
index 0b415f258..f326f3aa6 100644
--- a/lib/v2/javlibrary/star.js
+++ b/lib/v2/javlibrary/star.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultMode, defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_star.php?list&s=${id}&mode=${mode}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/update.js b/lib/v2/javlibrary/update.js
index 1c59b37c0..4794c7323 100644
--- a/lib/v2/javlibrary/update.js
+++ b/lib/v2/javlibrary/update.js
@@ -1,8 +1,9 @@
+import cache from '@/utils/cache';
const { defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/vl_update.php?list`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/javlibrary/user.js b/lib/v2/javlibrary/user.js
index b8d27b464..cea772666 100644
--- a/lib/v2/javlibrary/user.js
+++ b/lib/v2/javlibrary/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { defaultLanguage, rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
@@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const language = ctx.req.param('language') ?? defaultLanguage;
const currentUrl = `${rootUrl}/${language}/${type}.php?list&u=${id}`;
- ctx.set('data', await ProcessItems(language, currentUrl, ctx.cache.tryGet));
+ ctx.set('data', await ProcessItems(language, currentUrl, cache.tryGet));
};
diff --git a/lib/v2/jiemian/lists.js b/lib/v2/jiemian/lists.js
index b9372de32..b97dd50a6 100644
--- a/lib/v2/jiemian/lists.js
+++ b/lib/v2/jiemian/lists.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
Object.values(items)
.slice(0, limit)
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/jike/topic.js b/lib/v2/jike/topic.js
index 4a14b564c..e3ddbbf09 100644
--- a/lib/v2/jike/topic.js
+++ b/lib/v2/jike/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { topicDataHanding } = require('./utils');
import { load } from 'cheerio';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const regResult = /https:\/\/www\.okjike\.com\/medium\/[\dA-Za-z]*/.exec(item.description);
if (regResult) {
const newsUrl = regResult[0];
- item.description = await ctx.cache.tryGet(newsUrl, async () => {
+ item.description = await cache.tryGet(newsUrl, async () => {
const { data } = await got(newsUrl);
const $ = load(data);
const upper = $('ul.main > li.item');
diff --git a/lib/v2/jike/utils.js b/lib/v2/jike/utils.js
index 663b8bda0..2be411bc6 100644
--- a/lib/v2/jike/utils.js
+++ b/lib/v2/jike/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -147,7 +148,7 @@ module.exports = {
};
}),
constructTopicEntry: async (ctx, url) => {
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
url,
async () => {
const resp = await got(url);
diff --git a/lib/v2/jin10/index.js b/lib/v2/jin10/index.js
index 7a0bb4418..250548c94 100644
--- a/lib/v2/jin10/index.js
+++ b/lib/v2/jin10/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -7,7 +8,7 @@ import { config } from '@/config';
module.exports = async (ctx) => {
const { important = false } = ctx.params;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
'jin10:index',
async () => {
const { data: response } = await got('https://flash-api.jin10.com/get_flash_list', {
diff --git a/lib/v2/jin10/topic.js b/lib/v2/jin10/topic.js
index f377d5a83..416552604 100644
--- a/lib/v2/jin10/topic.js
+++ b/lib/v2/jin10/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -5,7 +6,7 @@ import { config } from '@/config';
module.exports = async (ctx) => {
const id = ctx.req.param('id');
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`jin10:topic:${id}`,
async () => {
const { data: response } = await got(`https://reference-api.jin10.com/topic/getById?id=${id}`, {
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.list.map((item) =>
- ctx.cache.tryGet(`jin10:reference:${item.id}`, async () => {
+ cache.tryGet(`jin10:reference:${item.id}`, async () => {
const { data: response } = await got(`https://reference-api.jin10.com/reference/getOne?id=${item.id}&type=news`, {
headers: {
'x-app-id': 'g93rhHb9DcDptyPb',
diff --git a/lib/v2/jinse/catalogue.js b/lib/v2/jinse/catalogue.js
index cb2f1d531..5ed614a8e 100644
--- a/lib/v2/jinse/catalogue.js
+++ b/lib/v2/jinse/catalogue.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -56,7 +57,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/\/lives\//.test(item.link)) {
return item;
}
diff --git a/lib/v2/jinse/timeline.js b/lib/v2/jinse/timeline.js
index 5732eb908..27441e43d 100644
--- a/lib/v2/jinse/timeline.js
+++ b/lib/v2/jinse/timeline.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -51,7 +52,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/\/lives\//.test(item.link)) {
return item;
}
diff --git a/lib/v2/jisilu/index.js b/lib/v2/jisilu/index.js
index e7503aabb..d61b28d20 100644
--- a/lib/v2/jisilu/index.js
+++ b/lib/v2/jisilu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -65,7 +66,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/jjwxc/book.js b/lib/v2/jjwxc/book.js
index 26b05140b..1c7f8747a 100644
--- a/lib/v2/jjwxc/book.js
+++ b/lib/v2/jjwxc/book.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -65,7 +66,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.slice(0, limit).map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.isVip) {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
diff --git a/lib/v2/jou/utils/index.js b/lib/v2/jou/utils/index.js
index 85e14b477..3ea7ad127 100644
--- a/lib/v2/jou/utils/index.js
+++ b/lib/v2/jou/utils/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入got库,该库用来请求网页数据
import got from '@/utils/got';
// 导入cheerio库,该库用来解析网页数据
@@ -32,7 +33,7 @@ async function getItems(ctx, url, host, tableClass, timeStyleClass1, titleStyleC
const out = await Promise.all(
list.map((item) =>
// 使用缓存
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({ url: item.link, https: { rejectUnauthorized: false } });
if (response.redirectUrls.length) {
item.link = response.redirectUrls[0];
diff --git a/lib/v2/jseea/news.js b/lib/v2/jseea/news.js
index c5c7b46a6..b2405a953 100644
--- a/lib/v2/jseea/news.js
+++ b/lib/v2/jseea/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -48,7 +49,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
// 遍历每一篇文章
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
item.description = await loadContent(item.link);
// 合并解析后的结果集作为该篇文章最终的输出结果
return item;
diff --git a/lib/v2/jsu/cxzx.js b/lib/v2/jsu/cxzx.js
index 6a3b78415..743a1a6c8 100644
--- a/lib/v2/jsu/cxzx.js
+++ b/lib/v2/jsu/cxzx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
list.map((item) => {
item = $(item);
const link = new URL(item.find('td:nth-child(2) > a').attr('href'), baseUrl).href;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const title = item.find('td:nth-child(2) > a').text() || '无标题';
const category = urls[types].title;
diff --git a/lib/v2/jsu/jwc.js b/lib/v2/jsu/jwc.js
index 8983c7bff..87b8b264e 100644
--- a/lib/v2/jsu/jwc.js
+++ b/lib/v2/jsu/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
list.map((item) => {
item = $(item);
const link = new URL(item.attr('href'), baseUrl).href;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const description = await getPageItemAndDate(
'#vsb_content',
link,
diff --git a/lib/v2/jsu/math.js b/lib/v2/jsu/math.js
index da11fc1b6..6d5533e7d 100644
--- a/lib/v2/jsu/math.js
+++ b/lib/v2/jsu/math.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
list.map((item) => {
item = $(item);
const link = new URL(item.find('a').attr('href'), baseUrl).href;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const description = await getPageItemAndDate('#right_con > form > div.articleInfo', link, '#right_con > form > div.articleTitle', '#right_con > form > div.articleAuthor > span:nth-child(1)');
const pubDate = parseDate(description.date, 'YYYY年MM月DD日 HH:mm');
return {
diff --git a/lib/v2/jsu/rjxy.js b/lib/v2/jsu/rjxy.js
index 5d2631851..fbba1274c 100644
--- a/lib/v2/jsu/rjxy.js
+++ b/lib/v2/jsu/rjxy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
list.map((item) => {
item = $(item);
const link = new URL(item.find('a').attr('href'), baseUrl).href;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const category = '通知公告';
const description = await getPageItemAndDate('#vsb_content', link, 'body > form > div > h1', 'body > form > div > div.label', (date) => date.split(' 点击:')[0]);
const pubDate = parseDate(description.date, 'YYYY年MM月DD日 HH:mm');
diff --git a/lib/v2/jsu/universityindex.js b/lib/v2/jsu/universityindex.js
index d08c7155f..5efc66214 100644
--- a/lib/v2/jsu/universityindex.js
+++ b/lib/v2/jsu/universityindex.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
list.map((item) => {
item = $(item);
const link = new URL(item.find('a').attr('href'), baseUrl).href;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const description = await getPageItemAndDate(
'#vsb_content',
link,
diff --git a/lib/v2/kamen-rider-official/news.js b/lib/v2/kamen-rider-official/news.js
index 0a84cee6e..43d78e434 100644
--- a/lib/v2/kamen-rider-official/news.js
+++ b/lib/v2/kamen-rider-official/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -49,7 +50,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/kantarworldpanel/index.js b/lib/v2/kantarworldpanel/index.js
index 6774f19aa..b14f4e112 100644
--- a/lib/v2/kantarworldpanel/index.js
+++ b/lib/v2/kantarworldpanel/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -49,7 +50,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
// The URL similar to the example below is the file download URL.
// eg. https://www.kantarworldpanel.com/dwl.php?sn=publications&id=1632.
if (item.link === currentUrl || !item.link.startsWith(rootUrl)) {
diff --git a/lib/v2/kbs/news.js b/lib/v2/kbs/news.js
index 5663e488d..cfb6ef68a 100644
--- a/lib/v2/kbs/news.js
+++ b/lib/v2/kbs/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/kbs/today.js b/lib/v2/kbs/today.js
index e57985b9a..f2abb29bf 100644
--- a/lib/v2/kbs/today.js
+++ b/lib/v2/kbs/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/kcna/news.js b/lib/v2/kcna/news.js
index cb148eddd..fca07d92d 100644
--- a/lib/v2/kcna/news.js
+++ b/lib/v2/kcna/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const asyncPool = require('tiny-async-pool');
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
// verify that with `mtr www.kcna.kp -Tz`
const items = [];
for await (const item of asyncPool(3, list, (item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.title = $('article-main-title').text() || item.title;
diff --git a/lib/v2/kcna/utils.js b/lib/v2/kcna/utils.js
index 786b99523..ce4dae366 100644
--- a/lib/v2/kcna/utils.js
+++ b/lib/v2/kcna/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -33,7 +34,7 @@ const fixDesc = ($, elem) => {
};
const fetchPhoto = (ctx, url) =>
- ctx.cache.tryGet(url, async () => {
+ cache.tryGet(url, async () => {
const res = await got(url);
const $ = load(res.data);
let html = '';
@@ -47,7 +48,7 @@ const fetchPhoto = (ctx, url) =>
});
const fetchVideo = (ctx, url) =>
- ctx.cache.tryGet(url, async () => {
+ cache.tryGet(url, async () => {
const res = await got(url);
const $ = load(res.data);
const js = $('script[type="text/javascript"]:not([src])').html();
diff --git a/lib/v2/keepass/news.js b/lib/v2/keepass/news.js
index ddbd20a9b..ae4869f5c 100644
--- a/lib/v2/keepass/news.js
+++ b/lib/v2/keepass/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.startsWith('https://keepass.info/')) {
return item;
}
diff --git a/lib/v2/kemono/index.js b/lib/v2/kemono/index.js
index 9b2a06d9e..87aaaecd4 100644
--- a/lib/v2/kemono/index.js
+++ b/lib/v2/kemono/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
response.data.map((channel) =>
- ctx.cache.tryGet(channel.id, async () => {
+ cache.tryGet(channel.id, async () => {
const channelResponse = await got({
method: 'get',
url: `${rootUrl}/api/v1/discord/channel/${channel.id}?o=0`,
@@ -74,7 +75,7 @@ module.exports = async (ctx) => {
};
})
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/kepu/live.js b/lib/v2/kepu/live.js
index c4ef2cc41..8230c43fa 100644
--- a/lib/v2/kepu/live.js
+++ b/lib/v2/kepu/live.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const apiReplayUrl = new URL('index.php/front/live/replay_url', apiRootUrl).href;
const { data: detailResponse } = await got.post(apiReplayUrl, {
diff --git a/lib/v2/keylol/index.js b/lib/v2/keylol/index.js
index 5ab2aa182..c8a490dd0 100644
--- a/lib/v2/keylol/index.js
+++ b/lib/v2/keylol/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/kimlaw/thesis.js b/lib/v2/kimlaw/thesis.js
index eec5efd6d..3f6061550 100644
--- a/lib/v2/kimlaw/thesis.js
+++ b/lib/v2/kimlaw/thesis.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/konghq/blog-posts.js b/lib/v2/konghq/blog-posts.js
index 08f1f4275..6f2156b5e 100644
--- a/lib/v2/konghq/blog-posts.js
+++ b/lib/v2/konghq/blog-posts.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// Get the lastest blog posts of https://konghq.com/
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
// Request each post to get the details content as "description"
const items = await Promise.all(
posts.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/kuaidi100/utils.js b/lib/v2/kuaidi100/utils.js
index 631541915..a353d4c39 100644
--- a/lib/v2/kuaidi100/utils.js
+++ b/lib/v2/kuaidi100/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const wwwid_key = 'kuaidi100-wwwid';
const csrf_key = 'kuaidi100-csrf';
@@ -11,12 +12,12 @@ const max_query_count = 30;
async function getCookie(ctx) {
// Check if this key should be replace? every 30 times should be fine.
shouldUpdateCookie(ctx);
- let wwwid = await ctx.cache.get(wwwid_key);
- let csrf = await ctx.cache.get(csrf_key);
- let globacsrftoken = await ctx.cache.get(globacsrftoken_key);
- let dasddocTitl = await ctx.cache.get(dasddocTitl_key);
- let dasddocReferrer = await ctx.cache.get(dasddocReferrer_key);
- let dasddocHref = await ctx.cache.get(dasddocHref_key);
+ let wwwid = await cache.get(wwwid_key);
+ let csrf = await cache.get(csrf_key);
+ let globacsrftoken = await cache.get(globacsrftoken_key);
+ let dasddocTitl = await cache.get(dasddocTitl_key);
+ let dasddocReferrer = await cache.get(dasddocReferrer_key);
+ let dasddocHref = await cache.get(dasddocHref_key);
if (!wwwid || !csrf || !dasddocTitl || !dasddocReferrer || !dasddocHref) {
const indexResponse = await got({
method: 'get',
@@ -46,12 +47,12 @@ async function getCookie(ctx) {
}
}
- ctx.cache.set(wwwid_key, wwwid, 600);
- ctx.cache.set(csrf_key, csrf, 600);
- ctx.cache.set(globacsrftoken_key, globacsrftoken, 600);
- ctx.cache.set(dasddocTitl_key, dasddocTitl, 600);
- ctx.cache.set(dasddocReferrer_key, dasddocReferrer, 600);
- ctx.cache.set(dasddocHref_key, dasddocHref, 600);
+ cache.set(wwwid_key, wwwid, 600);
+ cache.set(csrf_key, csrf, 600);
+ cache.set(globacsrftoken_key, globacsrftoken, 600);
+ cache.set(dasddocTitl_key, dasddocTitl, 600);
+ cache.set(dasddocReferrer_key, dasddocReferrer, 600);
+ cache.set(dasddocHref_key, dasddocHref, 600);
// We have acquired new cookie. It may due to cache timeout.
// Force update counter and don't wait it finished.
shouldUpdateCookie(ctx, true);
@@ -89,7 +90,7 @@ async function getCookie(ctx) {
function getCompanyList(ctx) {
// Using date as cache key and it will automatically expired by 1d
const key = `kuaidi100-company-name-${new Date().toISOString().split('T')[0]}`;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const cookie = await getCookie(ctx);
const wwwid = cookie.wwwid;
const companyResponse = await got({
@@ -117,25 +118,25 @@ function getCompanyList(ctx) {
function shouldUpdateCookie(ctx, forcedUpdate = false) {
if (forcedUpdate) {
- ctx.cache.set(query_count, 0);
+ cache.set(query_count, 0);
} else {
- const count = ctx.cache.get(query_count);
+ const count = cache.get(query_count);
if (count) {
if (count > max_query_count) {
- ctx.cache.set(query_count, 0);
- clearCookie(ctx);
+ cache.set(query_count, 0);
+ clearCookie();
} else {
- ctx.cache.set(query_count, count + 1);
+ cache.set(query_count, count + 1);
}
} else {
- ctx.cache.set(query_count, 1);
+ cache.set(query_count, 1);
}
}
}
-function clearCookie(ctx) {
- ctx.cache.set(wwwid_key, null);
- ctx.cache.set(csrf_key, null);
+function clearCookie() {
+ cache.set(wwwid_key, null);
+ cache.set(csrf_key, null);
}
module.exports = {
@@ -206,7 +207,7 @@ module.exports = {
getQuery: async (ctx, number, id, phone) => {
const query_key = `kuaidi100-query-${number}-${id}`;
- let query = await ctx.cache.get(query_key);
+ let query = await cache.get(query_key);
// 组装日期与单号 日期为提前两个月
const timestamp = Number.parseInt(Date.now() / 1000);
const lastTowMonth = Date.now() - 60 * 60 * 24 * 60 * 1000;
@@ -239,17 +240,17 @@ module.exports = {
if (query.status === '200') {
if (query.data && query.data[0].context === '查无结果') {
// 查无结果 appears when cookie is invaild, force update cookie.
- clearCookie(ctx);
+ clearCookie();
throw new Error('暂时无法获取快递信息,请稍后重试...');
} else if (query.ischeck === '0') {
// Not yet complete, don't cache for now.
// To avoid frquent link test when add source, add 180s cache
- ctx.cache.set(query_key, query, 180);
+ cache.set(query_key, query, 180);
} else {
- ctx.cache.set(query_key, query); // Finished, cache id
+ cache.set(query_key, query); // Finished, cache id
}
} else {
- ctx.cache.set(query_key, query); // Error, cache as well
+ cache.set(query_key, query); // Error, cache as well
throw new Error(`[${query.status}]信息有误,请重新检查后订阅:${query.message}`);
}
}
diff --git a/lib/v2/kuwaitlocal/index.js b/lib/v2/kuwaitlocal/index.js
index 2697c7060..31ec51239 100644
--- a/lib/v2/kuwaitlocal/index.js
+++ b/lib/v2/kuwaitlocal/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/kyodonews/index.js b/lib/v2/kyodonews/index.js
index 0c209651a..5fda5782f 100644
--- a/lib/v2/kyodonews/index.js
+++ b/lib/v2/kyodonews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -62,7 +63,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/lanqiao/author.js b/lib/v2/lanqiao/author.js
index d613e54d0..9a19610ce 100644
--- a/lib/v2/lanqiao/author.js
+++ b/lib/v2/lanqiao/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
const MarkdownIt = require('markdown-it');
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const md = new MarkdownIt();
const items = await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(`https://www.lanqiao.cn/api/v2/courses/${item.id}/`, async () => {
+ cache.tryGet(`https://www.lanqiao.cn/api/v2/courses/${item.id}/`, async () => {
const courseResponse = await got({
method: 'get',
url: `https://www.lanqiao.cn/api/v2/courses/${item.id}/`,
diff --git a/lib/v2/lanqiao/courses.js b/lib/v2/lanqiao/courses.js
index 44e1fa907..5e097ebe7 100644
--- a/lib/v2/lanqiao/courses.js
+++ b/lib/v2/lanqiao/courses.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
const MarkdownIt = require('markdown-it');
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(`https://www.lanqiao.cn/api/v2/courses/${item.id}/`, async () => {
+ cache.tryGet(`https://www.lanqiao.cn/api/v2/courses/${item.id}/`, async () => {
const courseResponse = await got({
method: 'get',
url: `https://www.lanqiao.cn/api/v2/courses/${item.id}/`,
diff --git a/lib/v2/lanqiao/questions.js b/lib/v2/lanqiao/questions.js
index bd9b8adf3..3225cec17 100644
--- a/lib/v2/lanqiao/questions.js
+++ b/lib/v2/lanqiao/questions.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const MarkdownIt = require('markdown-it');
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
data
.filter((element) => filterToped(element))
.map((item) =>
- ctx.cache.tryGet(`https://www.lanqiao.cn/api/v2/questions/${item.id}/`, async () => {
+ cache.tryGet(`https://www.lanqiao.cn/api/v2/questions/${item.id}/`, async () => {
const questionResponse = await got({
method: 'get',
url: `https://www.lanqiao.cn/api/v2/questions/${item.id}/`,
diff --git a/lib/v2/laohu8/personal.js b/lib/v2/laohu8/personal.js
index e67334a95..7a11a616c 100644
--- a/lib/v2/laohu8/personal.js
+++ b/lib/v2/laohu8/personal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(item.link, () => ({
+ cache.tryGet(item.link, () => ({
title: item.title,
description: String(item.htmlText).replaceAll('\n', '
'),
link: `${rootUrl}/post/${item.id}`,
diff --git a/lib/v2/latepost/index.js b/lib/v2/latepost/index.js
index ea601667a..f5176df2b 100644
--- a/lib/v2/latepost/index.js
+++ b/lib/v2/latepost/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -56,7 +57,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const { data: commentResponse } = await got.post(apiCommentUrl, {
diff --git a/lib/v2/layoffs/index.js b/lib/v2/layoffs/index.js
index e751a1447..b0821f4c7 100644
--- a/lib/v2/layoffs/index.js
+++ b/lib/v2/layoffs/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
};
// Get the latest data source url
- let dataSourceUrl = await ctx.cache.get(ENTRY_URL);
+ let dataSourceUrl = await cache.get(ENTRY_URL);
let cacheInvalid = false;
let response;
if (dataSourceUrl) {
@@ -82,7 +83,7 @@ module.exports = async (ctx) => {
.replaceAll('\\u002F', '/');
// Cache it again
- ctx.cache.set(ENTRY_URL, dataSourceUrl);
+ cache.set(ENTRY_URL, dataSourceUrl);
// Refetch the data source
response = await got({
diff --git a/lib/v2/learnku/topic.js b/lib/v2/learnku/topic.js
index f322f5c65..e0578f123 100644
--- a/lib/v2/learnku/topic.js
+++ b/lib/v2/learnku/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const itemLink = $('.topic-title-wrap').attr('href');
const title = $('.topic-title').text().trim();
- const content = await ctx.cache.tryGet(itemLink, async () => {
+ const content = await cache.tryGet(itemLink, async () => {
const result = await got.get(itemLink);
return load(result.data);
diff --git a/lib/v2/leetcode/articles.js b/lib/v2/leetcode/articles.js
index 814c5054a..768343786 100644
--- a/lib/v2/leetcode/articles.js
+++ b/lib/v2/leetcode/articles.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((info) =>
- ctx.cache.tryGet(info.link, async () => {
+ cache.tryGet(info.link, async () => {
const titleSlug = info.link.split('/')[4];
const questionContent = await got
diff --git a/lib/v2/lemmy/index.js b/lib/v2/lemmy/index.js
index 33345e9a1..ace037211 100644
--- a/lib/v2/lemmy/index.js
+++ b/lib/v2/lemmy/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const md = require('markdown-it')({ html: true });
@@ -17,13 +18,13 @@ module.exports = async (ctx) => {
}
const communityUrl = `https://${instance}/api/v3/community?name=${community}`;
- const communityData = await ctx.cache.tryGet(communityUrl, async () => {
+ const communityData = await cache.tryGet(communityUrl, async () => {
const result = await got({ method: 'get', url: communityUrl, headers: { 'Content-Type': 'application/json' } });
return result.data.community_view.community;
});
const postUrl = `https://${instance}/api/v3/post/list?type_=All&sort=${sort}&community_name=${community}&limit=50`;
- const postData = await ctx.cache.tryGet(
+ const postData = await cache.tryGet(
postUrl,
async () => {
const result = await got({ method: 'get', url: postUrl, headers: { 'Content-Type': 'application/json' } });
diff --git a/lib/v2/lifeweek/channel.js b/lib/v2/lifeweek/channel.js
index c4cd90c8b..327e96625 100644
--- a/lib/v2/lifeweek/channel.js
+++ b/lib/v2/lifeweek/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const getRssItem = require('./utils');
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
result.map((item) => {
const articleLink = `${articleRootUrl}/${item.id}`;
- return ctx.cache.tryGet(articleLink, () => getRssItem(item, articleLink));
+ return cache.tryGet(articleLink, () => getRssItem(item, articleLink));
})
);
diff --git a/lib/v2/lifeweek/tag.js b/lib/v2/lifeweek/tag.js
index e937c4a70..4d45c464a 100644
--- a/lib/v2/lifeweek/tag.js
+++ b/lib/v2/lifeweek/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const getRssItem = require('./utils');
const rootApiUrl = 'https://www.lifeweek.com.cn/api/userWebFollow/getFollowTagContentList?type=4&sort=2&tagId';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
result.map((item) => {
const articleLink = `${articleRootUrl}/${item.id}`;
- return ctx.cache.tryGet(articleLink, () => getRssItem(item, articleLink));
+ return cache.tryGet(articleLink, () => getRssItem(item, articleLink));
})
);
diff --git a/lib/v2/lightnovel/light-novel.js b/lib/v2/lightnovel/light-novel.js
index ce34ecf9b..38afec8b4 100644
--- a/lib/v2/lightnovel/light-novel.js
+++ b/lib/v2/lightnovel/light-novel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got({
method: 'GET',
url: item.link,
diff --git a/lib/v2/line/publisher.js b/lib/v2/line/publisher.js
index f493679a9..8bdef00d0 100644
--- a/lib/v2/line/publisher.js
+++ b/lib/v2/line/publisher.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, parseList, parseItems } = require('./utils');
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
const list = parseList(listResponse.items);
- const items = await parseItems(list, ctx.cache.tryGet);
+ const items = await parseItems(list, cache.tryGet);
ctx.set('data', {
title: `${publisherInfo.data.name} - Line Today`,
diff --git a/lib/v2/line/today.js b/lib/v2/line/today.js
index d739af5c7..3f32db02c 100644
--- a/lib/v2/line/today.js
+++ b/lib/v2/line/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl: rootUrl, parseList, parseItems } = require('./utils');
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const list = parseList(response.data.items);
- const items = await parseItems(list, ctx.cache.tryGet);
+ const items = await parseItems(list, cache.tryGet);
ctx.set('data', {
title: `${title} - Line Today`,
diff --git a/lib/v2/linkedin/cn/utils.js b/lib/v2/linkedin/cn/utils.js
index 20e09ff81..2dee7495d 100644
--- a/lib/v2/linkedin/cn/utils.js
+++ b/lib/v2/linkedin/cn/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const crypto = require('crypto');
const path = require('path');
import { art } from '@/utils/render';
@@ -93,7 +94,7 @@ const parseSearchHit = async (ctx) => {
const parseJobPosting = (ctx, jobPosting) => {
const entityUrn = jobPosting.entityUrn;
- return ctx.cache.tryGet(`linkedincn:${entityUrn}`, async () => {
+ return cache.tryGet(`linkedincn:${entityUrn}`, async () => {
const resp = await got.post(apiUrl, {
headers: makeHeader(),
body: makeBody({
diff --git a/lib/v2/literotica/category.js b/lib/v2/literotica/category.js
index 34b07f3ea..5e1770a9a 100644
--- a/lib/v2/literotica/category.js
+++ b/lib/v2/literotica/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/literotica/new.js b/lib/v2/literotica/new.js
index b3cc98033..ee60aaf81 100644
--- a/lib/v2/literotica/new.js
+++ b/lib/v2/literotica/new.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/liulinblog/index.js b/lib/v2/liulinblog/index.js
index 80a965485..dbb063569 100644
--- a/lib/v2/liulinblog/index.js
+++ b/lib/v2/liulinblog/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/lkong/forum.js b/lib/v2/lkong/forum.js
index 99d419281..251f86d4c 100644
--- a/lib/v2/lkong/forum.js
+++ b/lib/v2/lkong/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: apiUrl,
diff --git a/lib/v2/logclub/index.js b/lib/v2/logclub/index.js
index 0dc7eb971..791586e30 100644
--- a/lib/v2/logclub/index.js
+++ b/lib/v2/logclub/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/logclub/report.js b/lib/v2/logclub/report.js
index 5ac384280..99cfd9087 100644
--- a/lib/v2/logclub/report.js
+++ b/lib/v2/logclub/report.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/logonews/index.js b/lib/v2/logonews/index.js
index f2a5d40ce..9bd40ddb4 100644
--- a/lib/v2/logonews/index.js
+++ b/lib/v2/logonews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/loltw/news.js b/lib/v2/loltw/news.js
index e186a0c01..76bd23593 100644
--- a/lib/v2/loltw/news.js
+++ b/lib/v2/loltw/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(`${baseUrl}/api/news/detail?news_id=${item.guid}`);
item.description = art(path.join(__dirname, 'templates/news.art'), detailResponse.data.data.news_detail);
return item;
diff --git a/lib/v2/lovelive-anime/news.js b/lib/v2/lovelive-anime/news.js
index e01139004..018b6f290 100644
--- a/lib/v2/lovelive-anime/news.js
+++ b/lib/v2/lovelive-anime/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
if (ctx.req.param('option') === 'detail') {
items = await Promise.all(
pageFace.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResp = await got(item.link);
const $ = load(detailResp.data);
diff --git a/lib/v2/lovelive-anime/topics.js b/lib/v2/lovelive-anime/topics.js
index 11208f933..d25c8d4ec 100644
--- a/lib/v2/lovelive-anime/topics.js
+++ b/lib/v2/lovelive-anime/topics.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -56,7 +57,7 @@ module.exports = async (ctx) => {
if (ctx.req.param('option') === 'detail' || ctx.req.param('category') === 'detail') {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResp = await got(item.link);
const $ = load(detailResp.data);
diff --git a/lib/v2/lsnu/jiaowc/tzgg.js b/lib/v2/lsnu/jiaowc/tzgg.js
index 42cfc7f4a..0fdb70b8a 100644
--- a/lib/v2/lsnu/jiaowc/tzgg.js
+++ b/lib/v2/lsnu/jiaowc/tzgg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const link = `https://jiaowc.lsnu.edu.cn/${$('a').attr('href')}`;
const date = $('td[width="80"]').text();
- const single = await ctx.cache.tryGet(link, async () => {
+ const single = await cache.tryGet(link, async () => {
const response = await got({
method: 'get',
url: link,
diff --git a/lib/v2/luogu/contest.js b/lib/v2/luogu/contest.js
index 48793aedc..c6117e06a 100644
--- a/lib/v2/luogu/contest.js
+++ b/lib/v2/luogu/contest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
const result = [];
for await (const item of asyncPool(4, data.currentData.contests.result, (item) =>
- ctx.cache.tryGet(`${baseUrl}/contest/${item.id}`, async () => {
+ cache.tryGet(`${baseUrl}/contest/${item.id}`, async () => {
const { data: response } = await got(`${baseUrl}/contest/${item.id}`);
const $ = load(response);
const data = JSON.parse(
diff --git a/lib/v2/luogu/user-blog.js b/lib/v2/luogu/user-blog.js
index bdd828da7..7b13ca732 100644
--- a/lib/v2/luogu/user-blog.js
+++ b/lib/v2/luogu/user-blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const blogBaseUrl = `https://www.luogu.com.cn/blog/${name}/`;
// Fetch the uid & title
- const { uid: blogUid, title: blogTitle } = await ctx.cache.tryGet(blogBaseUrl, async () => {
+ const { uid: blogUid, title: blogTitle } = await cache.tryGet(blogBaseUrl, async () => {
const rsp = await got(blogBaseUrl);
const $ = load(rsp.data);
const uid = $("meta[name='blog-uid']").attr('content');
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
// Get the full text
const item = await Promise.all(
posts.map((post) =>
- ctx.cache.tryGet(post.link, async () => {
+ cache.tryGet(post.link, async () => {
const rsp = await got(post.link);
const $ = load(rsp.data);
return {
diff --git a/lib/v2/luogu/user-feed.js b/lib/v2/luogu/user-feed.js
index c999d8526..0cd80a561 100644
--- a/lib/v2/luogu/user-feed.js
+++ b/lib/v2/luogu/user-feed.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import MarkdownIt from 'markdown-it';
@@ -5,7 +6,7 @@ const md = MarkdownIt();
module.exports = async (ctx) => {
const getUsernameFromUID = (uid) =>
- ctx.cache.tryGet('luogu:username:' + uid, async () => {
+ cache.tryGet('luogu:username:' + uid, async () => {
const { data } = await got(`https://www.luogu.com.cn/user/${uid}?_contentOnly=1`);
return data.currentData.user.name;
});
diff --git a/lib/v2/lvv2/news.js b/lib/v2/lvv2/news.js
index 1e0cea5e3..5e3df5eea 100644
--- a/lib/v2/lvv2/news.js
+++ b/lib/v2/lvv2/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -43,10 +44,10 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
item.description =
new URL(item.link).hostname === 'instant.lvv2.com'
- ? await ctx.cache.tryGet(item.link, async () => {
+ ? await cache.tryGet(item.link, async () => {
const articleResponse = await got(item.link);
const article = load(articleResponse.data);
diff --git a/lib/v2/lvv2/top.js b/lib/v2/lvv2/top.js
index f664f01e1..f462d79b4 100644
--- a/lib/v2/lvv2/top.js
+++ b/lib/v2/lvv2/top.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const content = load(detailResponse.data);
@@ -49,7 +50,7 @@ module.exports = async (ctx) => {
const link = content('h2.title > a.title').attr('href');
item.description =
new URL(link, item.link).hostname === 'instant.lvv2.com'
- ? await ctx.cache.tryGet(link, async () => {
+ ? await cache.tryGet(link, async () => {
const articleResponse = await got(link);
const article = load(articleResponse.data);
diff --git a/lib/v2/m4/index.js b/lib/v2/m4/index.js
index b5da74ed1..34a947bf7 100644
--- a/lib/v2/m4/index.js
+++ b/lib/v2/m4/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/macfilos/blog.js b/lib/v2/macfilos/blog.js
index 37175906c..e824551f0 100644
--- a/lib/v2/macfilos/blog.js
+++ b/lib/v2/macfilos/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/mail/imap.js b/lib/v2/mail/imap.js
index 55ffe9ad7..3a4bcdcc9 100644
--- a/lib/v2/mail/imap.js
+++ b/lib/v2/mail/imap.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { ImapFlow } = require('imapflow');
import { config } from '@/config';
const { simpleParser } = require('mailparser');
@@ -66,7 +67,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
mails.map((item) =>
- ctx.cache.tryGet(`mail:${email}:${item.envelope.messageId}`, async () => {
+ cache.tryGet(`mail:${email}:${item.envelope.messageId}`, async () => {
const parsed = await simpleParser(item.source);
let description = parsed.html || parsed.textAsHtml;
diff --git a/lib/v2/mastodon/utils.js b/lib/v2/mastodon/utils.js
index 6d8b42316..74d25cb19 100644
--- a/lib/v2/mastodon/utils.js
+++ b/lib/v2/mastodon/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -76,7 +77,7 @@ async function getAccountStatuses(site, account_id, only_media) {
return { account_data, data };
}
-async function getAccountIdByAcct(acct, ctx) {
+async function getAccountIdByAcct(acct) {
const mastodonConfig = config.mastodon;
// acctHost is from the acct param of the request, and acctDomain is from either acctHost or the config
@@ -90,7 +91,7 @@ async function getAccountIdByAcct(acct, ctx) {
const search_url = `https://${site}/api/v2/search`;
const cacheUid = `mastodon_acct_id/${site}/${acct}`;
- const account_id = await ctx.cache.tryGet(cacheUid, async () => {
+ const account_id = await cache.tryGet(cacheUid, async () => {
const search_response = await got({
method: 'get',
url: search_url,
diff --git a/lib/v2/medieval-china/post.js b/lib/v2/medieval-china/post.js
index 1e0257a31..fa68f6c00 100644
--- a/lib/v2/medieval-china/post.js
+++ b/lib/v2/medieval-china/post.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
}));
const items = await Promise.all(
posts.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
const imgSrc = $('img').attr('data-original');
diff --git a/lib/v2/medium/parse-article.js b/lib/v2/medium/parse-article.js
index 6eb46a634..aa6fe7f08 100644
--- a/lib/v2/medium/parse-article.js
+++ b/lib/v2/medium/parse-article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -46,7 +47,7 @@ async function parse(url, cookie = '') {
}
module.exports = function (ctx, url) {
- return ctx.cache.tryGet(`medium:article:${url}`, async () => {
+ return cache.tryGet(`medium:article:${url}`, async () => {
const { title, author, publishedTime, html } = await parse(url, config.medium.articleCookie);
return {
diff --git a/lib/v2/medsci/index.js b/lib/v2/medsci/index.js
index b69c4e88b..5a8a36ea1 100644
--- a/lib/v2/medsci/index.js
+++ b/lib/v2/medsci/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/meteor/boards.js b/lib/v2/meteor/boards.js
index 204c1d96a..ae35918b4 100644
--- a/lib/v2/meteor/boards.js
+++ b/lib/v2/meteor/boards.js
@@ -1,7 +1,8 @@
+import cache from '@/utils/cache';
const { baseUrl, getBoards } = require('./utils');
module.exports = async (ctx) => {
- const items = await getBoards(ctx.cache.tryGet);
+ const items = await getBoards(cache.tryGet);
ctx.set('data', {
title: '看板列表',
diff --git a/lib/v2/meteor/index.js b/lib/v2/meteor/index.js
index baf5ca0f0..6cea61ac3 100644
--- a/lib/v2/meteor/index.js
+++ b/lib/v2/meteor/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { baseUrl, getBoards, renderDesc } = require('./utils');
@@ -5,7 +6,7 @@ const { baseUrl, getBoards, renderDesc } = require('./utils');
module.exports = async (ctx) => {
let { board = 'all' } = ctx.params;
- const boards = await getBoards(ctx.cache.tryGet);
+ const boards = await getBoards(cache.tryGet);
let boardInfo;
if (board !== 'all') {
boardInfo = boards.find((b) => b.id === board || b.alias === board);
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
result.map((item) =>
- ctx.cache.tryGet(`meteor:${item.id}`, () => ({
+ cache.tryGet(`meteor:${item.id}`, () => ({
title: item.title,
description: renderDesc(item.content),
link: `${baseUrl}/article/${item.shortId}`,
diff --git a/lib/v2/mihoyo/bbs/cache.js b/lib/v2/mihoyo/bbs/cache.js
index 69b1ffbfc..2cd911d80 100644
--- a/lib/v2/mihoyo/bbs/cache.js
+++ b/lib/v2/mihoyo/bbs/cache.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
@@ -8,7 +9,7 @@ module.exports = {
}
uid ||= '';
const key = 'mihoyo:user-full-info-uid-' + uid;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const query = new URLSearchParams({
uid,
gids: 2,
diff --git a/lib/v2/mihoyo/ys/news.js b/lib/v2/mihoyo/ys/news.js
index ce16279ca..f42855342 100644
--- a/lib/v2/mihoyo/ys/news.js
+++ b/lib/v2/mihoyo/ys/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -130,7 +131,7 @@ module.exports = async (ctx) => {
if (location === 'main') {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/mingpao/index.js b/lib/v2/mingpao/index.js
index 35dc86172..e3ca19e11 100644
--- a/lib/v2/mingpao/index.js
+++ b/lib/v2/mingpao/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let response;
try {
response = await got(item.link, {
diff --git a/lib/v2/mittrchina/index.js b/lib/v2/mittrchina/index.js
index 53cc349ed..7633be77c 100644
--- a/lib/v2/mittrchina/index.js
+++ b/lib/v2/mittrchina/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -66,7 +67,7 @@ module.exports = async (ctx) => {
if (type !== 'video') {
items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const {
data: { data: details },
} = await got(`https://apii.mittrchina.com/information/details?id=${item.id}`);
diff --git a/lib/v2/modb/topic.js b/lib/v2/modb/topic.js
index 572f8c9c4..d7a319780 100644
--- a/lib/v2/modb/topic.js
+++ b/lib/v2/modb/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
const logger = require('@/utils/logger');
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('div.editor-content-styl.article-style').first().html();
diff --git a/lib/v2/modelscope/community.js b/lib/v2/modelscope/community.js
index 6cda3f07f..be2377cba 100644
--- a/lib/v2/modelscope/community.js
+++ b/lib/v2/modelscope/community.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
const path = require('path');
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
articles.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/modelscope/datasets.js b/lib/v2/modelscope/datasets.js
index a3f68de09..877790a2e 100644
--- a/lib/v2/modelscope/datasets.js
+++ b/lib/v2/modelscope/datasets.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const md = require('markdown-it')({
html: true,
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
datasets.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(`${baseUrl}/api/v1/datasets${item.slug}`);
const content = data.Data.ReadmeContent.replaceAll(/img src="(?!http)(.*?)"/g, `img src="${baseUrl}/api/v1/datasets${item.slug}/repo?Revision=master&FilePath=$1&View=true"`);
diff --git a/lib/v2/modelscope/models.js b/lib/v2/modelscope/models.js
index 3c71a33f4..c300534be 100644
--- a/lib/v2/modelscope/models.js
+++ b/lib/v2/modelscope/models.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const md = require('markdown-it')({
html: true,
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
models.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(`${baseUrl}/api/v1/models${item.slug}`);
const content = data.Data.ReadMeContent.replaceAll(/img src="(?!http)(.*?)"/g, `img src="${baseUrl}/api/v1/models${item.slug}/repo?Revision=master&FilePath=$1&View=true"`);
diff --git a/lib/v2/modelscope/studios.js b/lib/v2/modelscope/studios.js
index 4fae2f9fd..27dfbc6e6 100644
--- a/lib/v2/modelscope/studios.js
+++ b/lib/v2/modelscope/studios.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const md = require('markdown-it')({
html: true,
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
studios.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(`${baseUrl}/api/v1/studio${item.slug}`);
const content = data.Data.ReadMeContent;
diff --git a/lib/v2/mohw/clarification.js b/lib/v2/mohw/clarification.js
index 22b848073..0d5654bd3 100644
--- a/lib/v2/mohw/clarification.js
+++ b/lib/v2/mohw/clarification.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/mox/index.js b/lib/v2/mox/index.js
index 481c5840a..c05ba4abe 100644
--- a/lib/v2/mox/index.js
+++ b/lib/v2/mox/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/mpaypass/main.js b/lib/v2/mpaypass/main.js
index d1ff3a47c..ab5e300b0 100644
--- a/lib/v2/mpaypass/main.js
+++ b/lib/v2/mpaypass/main.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((info) =>
- ctx.cache.tryGet(info.link, async () => {
+ cache.tryGet(info.link, async () => {
const response = await got(info.link);
const $ = load(response.data);
const newsbody = $('div.newsbody').html();
diff --git a/lib/v2/mpaypass/news.js b/lib/v2/mpaypass/news.js
index e8d81f973..869d3e386 100644
--- a/lib/v2/mpaypass/news.js
+++ b/lib/v2/mpaypass/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const title = $a.text();
const date = $el.find('.Newslist-time span').text();
- return ctx.cache.tryGet(href, async () => {
+ return cache.tryGet(href, async () => {
const contentData = await got.get(href);
const $content = load(contentData.data);
const description = $content('.newslist-body').html();
diff --git a/lib/v2/mrdx/daily.js b/lib/v2/mrdx/daily.js
index 0d4bcd4c5..8ff3505de 100644
--- a/lib/v2/mrdx/daily.js
+++ b/lib/v2/mrdx/daily.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const { getElementChildrenInnerText } = require('./utils');
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const passages = await Promise.all(
passagesList.map((passage) =>
- ctx.cache.tryGet(passage.link, async () => {
+ cache.tryGet(passage.link, async () => {
const response = await got({
url: passage.link,
method: 'get',
diff --git a/lib/v2/mrm/index.js b/lib/v2/mrm/index.js
index d47cdbe33..6f04153f8 100644
--- a/lib/v2/mrm/index.js
+++ b/lib/v2/mrm/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/mvm/index.js b/lib/v2/mvm/index.js
index 5a6e2fa4d..222e201d3 100644
--- a/lib/v2/mvm/index.js
+++ b/lib/v2/mvm/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/mydrivers/cid.js b/lib/v2/mydrivers/cid.js
index 05d956603..74a1e2451 100644
--- a/lib/v2/mydrivers/cid.js
+++ b/lib/v2/mydrivers/cid.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
const parser = require('@/utils/rss-parser');
@@ -25,11 +26,11 @@ module.exports = async (ctx) => {
}));
if (id) {
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
}
ctx.set('data', {
- ...(await getInfo(currentUrl, ctx.cache.tryGet)),
+ ...(await getInfo(currentUrl, cache.tryGet)),
item: items,
title: `${title} - ${feed.title.split(/_/).pop() || categories.zhibo}`,
diff --git a/lib/v2/mydrivers/index.js b/lib/v2/mydrivers/index.js
index 973362351..bffbd1132 100644
--- a/lib/v2/mydrivers/index.js
+++ b/lib/v2/mydrivers/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -47,10 +48,10 @@ module.exports = async (ctx) => {
};
});
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
ctx.set('data', {
- ...(await getInfo(currentUrl, ctx.cache.tryGet)),
+ ...(await getInfo(currentUrl, cache.tryGet)),
...Object.fromEntries(
Object.entries({
item: items,
diff --git a/lib/v2/mydrivers/rank.js b/lib/v2/mydrivers/rank.js
index 9fa21d603..adc6259e3 100644
--- a/lib/v2/mydrivers/rank.js
+++ b/lib/v2/mydrivers/rank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -31,10 +32,10 @@ module.exports = async (ctx) => {
};
});
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
ctx.set('data', {
item: items,
- ...(await getInfo(currentUrl, ctx.cache.tryGet, Number.parseInt(range, 10))),
+ ...(await getInfo(currentUrl, cache.tryGet, Number.parseInt(range, 10))),
});
};
diff --git a/lib/v2/myfigurecollection/index.js b/lib/v2/myfigurecollection/index.js
index 1cee5159b..216d16d4a 100644
--- a/lib/v2/myfigurecollection/index.js
+++ b/lib/v2/myfigurecollection/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/mysql/release.js b/lib/v2/mysql/release.js
index 57614b505..e8801ca2c 100644
--- a/lib/v2/mysql/release.js
+++ b/lib/v2/mysql/release.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { load } from 'cheerio';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nasa/apod-ncku.js b/lib/v2/nasa/apod-ncku.js
index dd1848294..a7bcf9b79 100644
--- a/lib/v2/nasa/apod-ncku.js
+++ b/lib/v2/nasa/apod-ncku.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nasa/apod.js b/lib/v2/nasa/apod.js
index af88e76b7..b2db07200 100644
--- a/lib/v2/nasa/apod.js
+++ b/lib/v2/nasa/apod.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/natgeo/dailyphoto.js b/lib/v2/natgeo/dailyphoto.js
index 065dd8176..c3f96aae6 100644
--- a/lib/v2/natgeo/dailyphoto.js
+++ b/lib/v2/natgeo/dailyphoto.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -8,7 +9,7 @@ import { config } from '@/config';
module.exports = async (ctx) => {
const rootUrl = 'https://www.nationalgeographic.com';
const apiUrl = `${rootUrl}/photo-of-the-day`;
- const response = await ctx.cache.tryGet(apiUrl, async () => (await got(apiUrl)).data, config.cache.contentExpire, false);
+ const response = await cache.tryGet(apiUrl, async () => (await got(apiUrl)).data, config.cache.contentExpire, false);
const $ = load(response);
const natgeo = JSON.parse($.html().match(/window\['__natgeo__']=(.*);/)[1]);
diff --git a/lib/v2/natgeo/natgeo.js b/lib/v2/natgeo/natgeo.js
index f58b6a21f..d2cb84c8e 100644
--- a/lib/v2/natgeo/natgeo.js
+++ b/lib/v2/natgeo/natgeo.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const single = {
link,
};
- const other = await ctx.cache.tryGet(link, () => loadContent(link));
+ const other = await cache.tryGet(link, () => loadContent(link));
return { ...single, ...other };
})
);
diff --git a/lib/v2/nationalgeographic/latest-stories.js b/lib/v2/nationalgeographic/latest-stories.js
index 347671123..642cb9162 100644
--- a/lib/v2/nationalgeographic/latest-stories.js
+++ b/lib/v2/nationalgeographic/latest-stories.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
category: i.tags.map((t) => t.name),
}))
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
const mods = findNatgeo($).page.content.article.frms.find((f) => f.cmsType === 'ArticleBodyFrame').mods;
diff --git a/lib/v2/nature/cover.js b/lib/v2/nature/cover.js
index 52a015db8..2963f47ef 100644
--- a/lib/v2/nature/cover.js
+++ b/lib/v2/nature/cover.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// The content is generateed by undocumentated API of nature journals
// This router has **just** been tested in:
// nature: Nature
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
journals.map((journal) =>
- ctx.cache.tryGet(journal.link, async () => {
+ cache.tryGet(journal.link, async () => {
const { id, name, link } = journal;
const response = await got(link, { cookieJar });
diff --git a/lib/v2/nature/news.js b/lib/v2/nature/news.js
index e1f354a66..9e1761b54 100644
--- a/lib/v2/nature/news.js
+++ b/lib/v2/nature/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
};
});
- items = await Promise.all(items.map((item) => ctx.cache.tryGet(item.link, () => getArticle(item, ctx))));
+ items = await Promise.all(items.map((item) => cache.tryGet(item.link, () => getArticle(item, ctx))));
ctx.set('data', {
title: 'Nature | Latest News',
diff --git a/lib/v2/nature/siteindex.js b/lib/v2/nature/siteindex.js
index d4b274338..dfac4ae0d 100644
--- a/lib/v2/nature/siteindex.js
+++ b/lib/v2/nature/siteindex.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, cookieJar } = require('./utils');
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(`nature:siteindex:${item.title}`, async () => {
+ cache.tryGet(`nature:siteindex:${item.title}`, async () => {
const response = await got(item.link, { cookieJar });
const $ = load(response.data);
diff --git a/lib/v2/nature/utils.js b/lib/v2/nature/utils.js
index ded7e0638..b77700518 100644
--- a/lib/v2/nature/utils.js
+++ b/lib/v2/nature/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -49,8 +50,8 @@ const getArticleList = (html) =>
};
});
-const getArticle = (item, ctx) =>
- ctx.cache.tryGet(item.link, async () => {
+const getArticle = (item) =>
+ cache.tryGet(item.link, async () => {
const response = await got(item.link, {
cookieJar,
});
diff --git a/lib/v2/nautil/topics.js b/lib/v2/nautil/topics.js
index 546f41cd5..b6587fb17 100644
--- a/lib/v2/nautil/topics.js
+++ b/lib/v2/nautil/topics.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -6,7 +7,7 @@ const path = require('path');
const baseUrl = 'https://nautil.us';
module.exports = async (ctx) => {
- const categoryIdMap = await ctx.cache.tryGet('nautil:categories', async () => {
+ const categoryIdMap = await cache.tryGet('nautil:categories', async () => {
const { data } = await got(`${baseUrl}/wp-json/wp/v2/categories`, {
searchParams: {
per_page: 100,
diff --git a/lib/v2/nbd/index.js b/lib/v2/nbd/index.js
index 1d6e0dbec..fabb8da76 100644
--- a/lib/v2/nbd/index.js
+++ b/lib/v2/nbd/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nber/index.js b/lib/v2/nber/index.js
index e5d245785..34f647a7f 100644
--- a/lib/v2/nber/index.js
+++ b/lib/v2/nber/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -13,13 +14,13 @@ async function getData(url) {
module.exports = async (ctx) => {
const url = 'https://www.nber.org/api/v1/working_page_listing/contentType/working_paper/_/_/search';
const baseUrl = 'https://www.nber.org';
- const data = await ctx.cache.tryGet(url, () => getData(url), config.cache.routeExpire, false);
+ const data = await cache.tryGet(url, () => getData(url), config.cache.routeExpire, false);
const items = await Promise.all(
data
.filter((article) => ctx.path === '/papers' || article.newthisweek)
.map((article) => {
const link = `${baseUrl}${article.url}`;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response = await got(link);
const $ = load(response.data);
const downloadLink = $('meta[name="citation_pdf_url"]').attr('content');
diff --git a/lib/v2/ncepu/master/masterinfo.js b/lib/v2/ncepu/master/masterinfo.js
index 9c408b9e6..9d3992003 100644
--- a/lib/v2/ncepu/master/masterinfo.js
+++ b/lib/v2/ncepu/master/masterinfo.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
- const itemData = await ctx.cache.tryGet(item.link, async () => (await got(item.link)).data);
+ const itemData = await cache.tryGet(item.link, async () => (await got(item.link)).data);
const content = load(itemData);
const articleAuthor = content('.articleAuthor').html().replace('作者: ', '').replace('来源: ', '');
diff --git a/lib/v2/ndss-symposium/ndss.js b/lib/v2/ndss-symposium/ndss.js
index 68d7c4f83..b63acb9da 100644
--- a/lib/v2/ndss-symposium/ndss.js
+++ b/lib/v2/ndss-symposium/ndss.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = 'https://www.ndss-symposium.org';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
divMatch.map((item) => {
if (item.link) {
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
// some titles and authos are not complete
const response = await got(item.link);
const $ = load(response.body);
diff --git a/lib/v2/neea/index.js b/lib/v2/neea/index.js
index 60c30682c..c5b717ce4 100644
--- a/lib/v2/neea/index.js
+++ b/lib/v2/neea/index.js
@@ -1,7 +1,8 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
-function loadContent(link, ctx) {
- return ctx.cache.tryGet(link, async () => {
+function loadContent(link) {
+ return cache.tryGet(link, async () => {
// 开始加载页面
const response = await got.get(link);
const $ = load(response.data);
diff --git a/lib/v2/neea/jlpt.js b/lib/v2/neea/jlpt.js
index 73608e594..bdd35cd3d 100644
--- a/lib/v2/neea/jlpt.js
+++ b/lib/v2/neea/jlpt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nenu/sohac.js b/lib/v2/nenu/sohac.js
index a013a8c6c..a233d0151 100644
--- a/lib/v2/nenu/sohac.js
+++ b/lib/v2/nenu/sohac.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nenu/yjsy.js b/lib/v2/nenu/yjsy.js
index 6a90b985b..cfe90488d 100644
--- a/lib/v2/nenu/yjsy.js
+++ b/lib/v2/nenu/yjsy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/yjsy\.nenu\.edu\.cn/.test(item.link)) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/neu/bmie.js b/lib/v2/neu/bmie.js
index dfc2da466..c0dfe1626 100644
--- a/lib/v2/neu/bmie.js
+++ b/lib/v2/neu/bmie.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
const $ = load(item);
const title = $('a').attr('title');
const url = baseUrl + $('a').attr('href');
- const data = await ctx.cache.tryGet(url, async () => {
+ const data = await cache.tryGet(url, async () => {
const result = await got(url);
const $ = load(result.data);
diff --git a/lib/v2/neu/news.js b/lib/v2/neu/news.js
index 7ee5847d0..c6068ed3f 100644
--- a/lib/v2/neu/news.js
+++ b/lib/v2/neu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const results = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const result = await got(item.link);
const $ = load(result.data);
diff --git a/lib/v2/newrank/utils.js b/lib/v2/newrank/utils.js
index d677e3fb3..26364abf1 100644
--- a/lib/v2/newrank/utils.js
+++ b/lib/v2/newrank/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import md5 from '@/utils/md5';
import got from '@/utils/got';
import { config } from '@/config';
@@ -45,31 +46,31 @@ const flatten = (arr) => arr.reduce((acc, val) => [...acc, ...(Array.isArray(val
function shouldUpdateCookie(ctx, forcedUpdate = false) {
if (forcedUpdate) {
- ctx.cache.set(query_count, 0);
+ cache.set(query_count, 0);
} else {
- const count = ctx.cache.get(query_count);
+ const count = cache.get(query_count);
if (count) {
if (count > max_query_count) {
- ctx.cache.set(query_count, 0);
+ cache.set(query_count, 0);
clearCookie(ctx);
} else {
- ctx.cache.set(query_count, count + 1);
+ cache.set(query_count, count + 1);
}
} else {
- ctx.cache.set(query_count, 1);
+ cache.set(query_count, 1);
}
}
}
-function clearCookie(ctx) {
- ctx.cache.set(newrank_cookie_token, null);
+function clearCookie() {
+ cache.set(newrank_cookie_token, null);
}
// 加了验证码失效了
async function getCookie(ctx) {
// Check if this key should be replace? every 30 times should be fine.
shouldUpdateCookie(ctx);
- let token = await ctx.cache.get(newrank_cookie_token);
+ let token = await cache.get(newrank_cookie_token);
const username = String(config.newrank.username);
const password = md5(md5(String(config.newrank.password)) + 'daddy');
const nonce = random_nonce(9);
@@ -94,7 +95,7 @@ async function getCookie(ctx) {
}
}
}
- ctx.cache.set(newrank_cookie_token, token, 600);
+ cache.set(newrank_cookie_token, token, 600);
// We have acquired new cookie. It may due to cache timeout.
// Force update counter and don't wait it finished.
shouldUpdateCookie(ctx, true);
diff --git a/lib/v2/news/xhsxw.js b/lib/v2/news/xhsxw.js
index ddc705570..db81ca001 100644
--- a/lib/v2/news/xhsxw.js
+++ b/lib/v2/news/xhsxw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/newsmarket/index.js b/lib/v2/newsmarket/index.js
index fff65a625..c81dd2c4e 100644
--- a/lib/v2/newsmarket/index.js
+++ b/lib/v2/newsmarket/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/newzmz/index.js b/lib/v2/newzmz/index.js
index dcfdc672e..b82691edd 100644
--- a/lib/v2/newzmz/index.js
+++ b/lib/v2/newzmz/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
const currentUrl = new URL(isCategory ? 'index.html' : `details-${id}.html`, rootUrl).href;
- const response = await ctx.cache.tryGet(currentUrl, async () => {
+ const response = await cache.tryGet(currentUrl, async () => {
const { data: response } = await got(currentUrl);
return response;
@@ -30,14 +31,14 @@ module.exports = async (ctx) => {
// add that item alone to the "to be processed" array.
let items = isCategory
- ? await getItems(ctx.cache.tryGet, currentUrl, id, 'div.rowMod', 'ul.slides li a')
+ ? await getItems(cache.tryGet, currentUrl, id, 'div.rowMod', 'ul.slides li a')
: [
{
link: currentUrl,
},
];
- items = await Promise.all(items.slice(0, limit).map((item) => getItemInfo(ctx.cache.tryGet, item.link)));
+ items = await Promise.all(items.slice(0, limit).map((item) => getItemInfo(cache.tryGet, item.link)));
// If the link of the entry is "#",
// it indicates that there are currently no relevant resources available for that specific item.
diff --git a/lib/v2/newzmz/util.js b/lib/v2/newzmz/util.js
index de580ea0e..ce1a0ec96 100644
--- a/lib/v2/newzmz/util.js
+++ b/lib/v2/newzmz/util.js
@@ -8,7 +8,7 @@ const rootUrl = 'https://nzmz.xyz';
/**
* Retrieve all movies and TV shows under a specified category on the homepage and obtain their detail links.
- * @param {function} tryGet - ctx.cache.tryGet
+ * @param {function} tryGet - cache.tryGet
* @param {string} homeUrl - Homepage URL
* @param {string} id - Category id
* @param {string} modSelector - Selector for mods
@@ -39,7 +39,7 @@ const getItems = async (tryGet, homeUrl, id, modSelector, itemSelector) => {
/**
* Obtain the information corresponding to a given movie or TV show item based on the provided URL.
- * @param {function} tryGet - ctx.cache.tryGet
+ * @param {function} tryGet - cache.tryGet
* @param {string} itemUrl - Item URL
* @returns {Object} An object containing information of the item.
*/
diff --git a/lib/v2/nextapple/realtime.js b/lib/v2/nextapple/realtime.js
index 408d211da..1c101144e 100644
--- a/lib/v2/nextapple/realtime.js
+++ b/lib/v2/nextapple/realtime.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const items = [];
for await (const item of asyncPool(5, $('article.infScroll'), (item) => {
const link = $(item).find('.post-title').attr('href');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response = await got(link);
const $ = load(response.data);
const mainContent = $('#main-content');
diff --git a/lib/v2/nga/forum.js b/lib/v2/nga/forum.js
index 9a3b7fcd1..19a926e8a 100644
--- a/lib/v2/nga/forum.js
+++ b/lib/v2/nga/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { parseDate } from '@/utils/parse-date';
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
pubDate: parseDate(postdate, 'X'),
};
- const description = await ctx.cache.tryGet(`nga-forum: ${link}`, async () => {
+ const description = await cache.tryGet(`nga-forum: ${link}`, async () => {
const response = await got.post('https://ngabbs.com/app_api.php?__lib=post&__act=list', {
headers: {
'X-User-Agent': X_UA,
diff --git a/lib/v2/ngocn2/index.js b/lib/v2/ngocn2/index.js
index fd87b6ee2..c692f4aa7 100644
--- a/lib/v2/ngocn2/index.js
+++ b/lib/v2/ngocn2/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nhk/news-web-easy.js b/lib/v2/nhk/news-web-easy.js
index 5cc876dc3..5365d0908 100644
--- a/lib/v2/nhk/news-web-easy.js
+++ b/lib/v2/nhk/news-web-easy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
item.description += $('.article-body').html();
diff --git a/lib/v2/nhk/news.js b/lib/v2/nhk/news.js
index 9f1672fa2..9fe104127 100644
--- a/lib/v2/nhk/news.js
+++ b/lib/v2/nhk/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(`${apiUrl}/nhkworld/rdnewsweb/v6b/${lang}/detail/${item.id}.json`);
item.category = Object.values(data.data.categories);
item.description = art(path.join(__dirname, 'templates/news.art'), {
diff --git a/lib/v2/niaogebiji/cat.js b/lib/v2/niaogebiji/cat.js
index b3a82b8f9..edb52a405 100644
--- a/lib/v2/niaogebiji/cat.js
+++ b/lib/v2/niaogebiji/cat.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
articles.map((element) =>
- ctx.cache.tryGet(element.link, async () => {
+ cache.tryGet(element.link, async () => {
const response = await got(element.link);
const $ = load(response.data);
diff --git a/lib/v2/niaogebiji/index.js b/lib/v2/niaogebiji/index.js
index 9391f4f36..b09bac393 100644
--- a/lib/v2/niaogebiji/index.js
+++ b/lib/v2/niaogebiji/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
postList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/nifd/research.js b/lib/v2/nifd/research.js
index 834215e84..c5b821df7 100644
--- a/lib/v2/nifd/research.js
+++ b/lib/v2/nifd/research.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const content = load(detailResponse.data);
item.description = content('div.qrd-content').html();
diff --git a/lib/v2/nikkei/asia/index.js b/lib/v2/nikkei/asia/index.js
index e60340957..fd31633e2 100644
--- a/lib/v2/nikkei/asia/index.js
+++ b/lib/v2/nikkei/asia/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
stories.map((item) =>
- ctx.cache.tryGet(item.url, async () => {
+ cache.tryGet(item.url, async () => {
const fulltext = await got({
method: 'get',
url: `https://main-asianreview-nikkei.content.pugpig.com/editionfeed/4519/${item.url}`,
diff --git a/lib/v2/nikkei/cn/index.js b/lib/v2/nikkei/cn/index.js
index a7b373412..3c8f51c99 100644
--- a/lib/v2/nikkei/cn/index.js
+++ b/lib/v2/nikkei/cn/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -56,7 +57,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: `${item.link}?print=1`,
diff --git a/lib/v2/nikkei/news.js b/lib/v2/nikkei/news.js
index 6cd1a7321..14fcbb57c 100644
--- a/lib/v2/nikkei/news.js
+++ b/lib/v2/nikkei/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/nintendo/eshop-hk.js b/lib/v2/nintendo/eshop-hk.js
index 4842ddd8d..27881f8a0 100644
--- a/lib/v2/nintendo/eshop-hk.js
+++ b/lib/v2/nintendo/eshop-hk.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
// 获取游戏描述
const result = await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/nippon/index.js b/lib/v2/nippon/index.js
index a90bae6ab..0418a3ce4 100644
--- a/lib/v2/nippon/index.js
+++ b/lib/v2/nippon/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
list.slice(0, 10).map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
const $ = load(res.data);
item.description = $('.editArea').html();
diff --git a/lib/v2/njglyy/utils/index.js b/lib/v2/njglyy/utils/index.js
index f875d0e43..7552ccbaf 100644
--- a/lib/v2/njglyy/utils/index.js
+++ b/lib/v2/njglyy/utils/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ async function getNoticeList(ctx, url, host, listSelector, itemSelector, titleSe
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
if (response.redirectUrls.length) {
item.link = response.redirectUrls[0];
diff --git a/lib/v2/njit/jwc.js b/lib/v2/njit/jwc.js
index 8f4673127..14d65b9fd 100644
--- a/lib/v2/njit/jwc.js
+++ b/lib/v2/njit/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
urlList.map((itemUrl, index) => {
itemUrl = new URL(itemUrl, host).href;
if (itemUrl.includes('.htm')) {
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const response = await got({
method: 'get',
url: itemUrl,
diff --git a/lib/v2/njit/tzgg.js b/lib/v2/njit/tzgg.js
index 509732cd2..b3da834d8 100644
--- a/lib/v2/njit/tzgg.js
+++ b/lib/v2/njit/tzgg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
};
return single;
} else {
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const response = await got({
method: 'get',
url: itemUrl,
diff --git a/lib/v2/nju/rczp.js b/lib/v2/nju/rczp.js
index 31431d8e9..c1f8cb0ab 100644
--- a/lib/v2/nju/rczp.js
+++ b/lib/v2/nju/rczp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
};
const link = `https://rczp.nju.edu.cn/sylm/${type}/index.html`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`nju:rczp:${type}`,
async () => {
const { data } = await got.post('https://rczp.nju.edu.cn/njdx/openapi/t/info/list.do', {
diff --git a/lib/v2/njucm/utils/index.js b/lib/v2/njucm/utils/index.js
index 641b1fb12..b02cf5b16 100644
--- a/lib/v2/njucm/utils/index.js
+++ b/lib/v2/njucm/utils/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ async function getNoticeList(ctx, url, host, listSelector, titleSelector, conten
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
if (response.redirectUrls.length) {
item.link = response.redirectUrls[0];
diff --git a/lib/v2/njupt/jwc.js b/lib/v2/njupt/jwc.js
index b0a1cf47c..7bedb0398 100644
--- a/lib/v2/njupt/jwc.js
+++ b/lib/v2/njupt/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
urlList.map((itemUrl, index) => {
itemUrl = new URL(itemUrl, host).href;
if (itemUrl.includes('.htm')) {
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const response = await got.get(itemUrl);
if (response.redirectUrls.length !== 0) {
const single = {
diff --git a/lib/v2/njxzc/utils/index.js b/lib/v2/njxzc/utils/index.js
index 3984c1034..27775e600 100644
--- a/lib/v2/njxzc/utils/index.js
+++ b/lib/v2/njxzc/utils/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ async function getNoticeList(ctx, url, host, titleSelector, dateSelector, conten
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
if (response.redirectUrls.length) {
item.link = response.redirectUrls[0];
diff --git a/lib/v2/nltimes/news.js b/lib/v2/nltimes/news.js
index 8aed1e82c..a6b38fc6a 100644
--- a/lib/v2/nltimes/news.js
+++ b/lib/v2/nltimes/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -61,7 +62,7 @@ module.exports = async (ctx) => {
const link = rootUrl + item.link;
const category = item.category;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response = await got({
method: 'get',
url: link,
diff --git a/lib/v2/nodejs/blog.js b/lib/v2/nodejs/blog.js
index c557d2bd6..f4bfd9081 100644
--- a/lib/v2/nodejs/blog.js
+++ b/lib/v2/nodejs/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/notion/database.js b/lib/v2/notion/database.js
index 1218036ed..93747b94b 100644
--- a/lib/v2/notion/database.js
+++ b/lib/v2/notion/database.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { Client, isNotionClientError, APIErrorCode } = require('@notionhq/client');
const logger = require('@/utils/logger');
import { config } from '@/config';
@@ -58,7 +59,7 @@ module.exports = async (ctx) => {
const pagePubTime = notionText(page.properties[properties.pubTime]);
// Convert Notion page blocks to markdown string
- const articleContent = await ctx.cache.tryGet(`${pageLink}-${pageLastEditedTime}`, async () => {
+ const articleContent = await cache.tryGet(`${pageLink}-${pageLastEditedTime}`, async () => {
const mdblocks = await n2m.pageToMarkdown(page.id);
const mdString = n2m.toMarkdownString(mdblocks);
return mdString.parent;
@@ -68,7 +69,7 @@ module.exports = async (ctx) => {
let pubTime = pagePubTime || pageLastEditedTime;
// Try to get author info
if (articleLink && !pageAuthor) {
- const { articleAuthor, articlePubTime } = await ctx.cache.tryGet(`${pageLink}-${articleLink}`, async () => {
+ const { articleAuthor, articlePubTime } = await cache.tryGet(`${pageLink}-${articleLink}`, async () => {
try {
const response = await got({
method: 'get',
diff --git a/lib/v2/now/news.js b/lib/v2/now/news.js
index 4b189ee99..35c2b03e3 100644
--- a/lib/v2/now/news.js
+++ b/lib/v2/now/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nowcoder/discuss.js b/lib/v2/nowcoder/discuss.js
index 090a19e2e..2ef9b05da 100644
--- a/lib/v2/nowcoder/discuss.js
+++ b/lib/v2/nowcoder/discuss.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const title = info.title || 'tzgg';
const itemUrl = new URL(info.link, host).href.replace(/^(.*)\?(.*)$/, '$1');
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const response = await got.get(itemUrl);
const $ = load(response.data);
diff --git a/lib/v2/nowcoder/experience.js b/lib/v2/nowcoder/experience.js
index 0da57ab34..796d661c4 100644
--- a/lib/v2/nowcoder/experience.js
+++ b/lib/v2/nowcoder/experience.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((info) =>
- ctx.cache.tryGet(info.link, async () => {
+ cache.tryGet(info.link, async () => {
const response = await got.get(info.link);
const $ = load(response.data);
diff --git a/lib/v2/nowcoder/jobcenter.js b/lib/v2/nowcoder/jobcenter.js
index 50bec560d..23d692746 100644
--- a/lib/v2/nowcoder/jobcenter.js
+++ b/lib/v2/nowcoder/jobcenter.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const url = require('url');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/npr/full.js b/lib/v2/npr/full.js
index b23a6b061..b3e62db34 100644
--- a/lib/v2/npr/full.js
+++ b/lib/v2/npr/full.js
@@ -1,9 +1,10 @@
+import cache from '@/utils/cache';
const parser = require('@/utils/rss-parser');
import got from '@/utils/got';
import { load } from 'cheerio';
-const getArticleDetail = (link, ctx) =>
- ctx.cache.tryGet(link, async () => {
+const getArticleDetail = (link) =>
+ cache.tryGet(link, async () => {
const response = await got(link);
const $ = load(response.data);
diff --git a/lib/v2/ntdtv/channel.js b/lib/v2/ntdtv/channel.js
index e86d9c484..c04bc0b2f 100644
--- a/lib/v2/ntdtv/channel.js
+++ b/lib/v2/ntdtv/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/nua/utils.js b/lib/v2/nua/utils.js
index 79f39d8d2..4f2883815 100644
--- a/lib/v2/nua/utils.js
+++ b/lib/v2/nua/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -45,10 +46,10 @@ async function ProcessList(newsUrl, baseUrl, listName, listDate, webPageName) {
return [items, pageName];
}
-const ProcessFeed = (items, artiContent, ctx) =>
+const ProcessFeed = (items, artiContent) =>
Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
switch (item.type) {
case 'in-nua':
case 'nua': {
diff --git a/lib/v2/nuaa/college/cae.js b/lib/v2/nuaa/college/cae.js
index 3af4e2efa..8e22bebb8 100644
--- a/lib/v2/nuaa/college/cae.js
+++ b/lib/v2/nuaa/college/cae.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
let description = title + '
查看原文';
if (getDescription) {
- description = await ctx.cache.tryGet(itemUrl, async () => {
+ description = await cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr.at(-1);
if (pageType === 'htm' || pageType === 'html') {
diff --git a/lib/v2/nuaa/college/cs.js b/lib/v2/nuaa/college/cs.js
index a84c9f001..5cd70a5a1 100644
--- a/lib/v2/nuaa/college/cs.js
+++ b/lib/v2/nuaa/college/cs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -49,7 +50,7 @@ module.exports = async (ctx) => {
let description = title + '
查看原文';
if (getDescription) {
- description = await ctx.cache.tryGet(itemUrl, async () => {
+ description = await cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr.at(-1);
if (pageType === 'htm' || pageType === 'html') {
diff --git a/lib/v2/nuaa/jwc/jwc.js b/lib/v2/nuaa/jwc/jwc.js
index 7f58a076b..286b7a4db 100644
--- a/lib/v2/nuaa/jwc/jwc.js
+++ b/lib/v2/nuaa/jwc/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
let description = title + '
查看原文';
if (getDescription) {
- description = await ctx.cache.tryGet(itemUrl, async () => {
+ description = await cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr.at(-1);
if (pageType === 'htm' || pageType === 'html') {
diff --git a/lib/v2/nuaa/yjsy/yjsy.js b/lib/v2/nuaa/yjsy/yjsy.js
index 0532c8509..3ccac38d3 100644
--- a/lib/v2/nuaa/yjsy/yjsy.js
+++ b/lib/v2/nuaa/yjsy/yjsy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
let description = title + '
查看原文';
if (getDescription) {
- description = await ctx.cache.tryGet(itemUrl, async () => {
+ description = await cache.tryGet(itemUrl, async () => {
const arr = itemUrl.split('.');
const pageType = arr.at(-1);
if (pageType === 'htm' || pageType === 'html') {
diff --git a/lib/v2/nuist/cas.js b/lib/v2/nuist/cas.js
index 09e906222..5203a332c 100644
--- a/lib/v2/nuist/cas.js
+++ b/lib/v2/nuist/cas.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let response;
try {
response = await got(item.link);
diff --git a/lib/v2/nuist/jwc.js b/lib/v2/nuist/jwc.js
index f4f2e5ab1..3c86fbc0d 100644
--- a/lib/v2/nuist/jwc.js
+++ b/lib/v2/nuist/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/nuist/library/lib.js b/lib/v2/nuist/library/lib.js
index c475757df..608d11f4b 100644
--- a/lib/v2/nuist/library/lib.js
+++ b/lib/v2/nuist/library/lib.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/nuist/scs.js b/lib/v2/nuist/scs.js
index eef4078d9..56cd072e5 100644
--- a/lib/v2/nuist/scs.js
+++ b/lib/v2/nuist/scs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/nuist/sese.js b/lib/v2/nuist/sese.js
index 4c6a7d307..be77117f6 100644
--- a/lib/v2/nuist/sese.js
+++ b/lib/v2/nuist/sese.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/nuist/xgc.js b/lib/v2/nuist/xgc.js
index 700c741f6..92bf85110 100644
--- a/lib/v2/nuist/xgc.js
+++ b/lib/v2/nuist/xgc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let response;
try {
response = await got(item.link);
diff --git a/lib/v2/nuist/yjs.js b/lib/v2/nuist/yjs.js
index 75821dc7a..12dbd9452 100644
--- a/lib/v2/nuist/yjs.js
+++ b/lib/v2/nuist/yjs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nwafu/all.js b/lib/v2/nwafu/all.js
index 0882e0887..917cc652c 100644
--- a/lib/v2/nwafu/all.js
+++ b/lib/v2/nwafu/all.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (nwafuMap.get('forbiddenList').includes(new URL(item.link).hostname)) {
return item;
}
diff --git a/lib/v2/nytimes/daily-briefing-chinese.js b/lib/v2/nytimes/daily-briefing-chinese.js
index 64b888735..96e1f16de 100644
--- a/lib/v2/nytimes/daily-briefing-chinese.js
+++ b/lib/v2/nytimes/daily-briefing-chinese.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/nytimes/index.js b/lib/v2/nytimes/index.js
index 2002d2296..ae1090540 100644
--- a/lib/v2/nytimes/index.js
+++ b/lib/v2/nytimes/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
const utils = require('./utils');
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
link = link.replace('/?utm_source=RSS', '') + '/dual';
try {
- response = await ctx.cache.tryGet(`nyt: ${link}`, async () => {
+ response = await cache.tryGet(`nyt: ${link}`, async () => {
const response = await got(link);
return response.data;
@@ -61,14 +62,14 @@ module.exports = async (ctx) => {
dual = true;
} catch {
- response = await ctx.cache.tryGet(`nyt: ${item.link}`, async () => {
+ response = await cache.tryGet(`nyt: ${item.link}`, async () => {
const response = await got(item.link);
return response.data;
});
}
} else {
- response = await ctx.cache.tryGet(`nyt: ${item.link}`, async () => {
+ response = await cache.tryGet(`nyt: ${item.link}`, async () => {
const response = await got(item.link);
return response.data;
diff --git a/lib/v2/nytimes/utils.js b/lib/v2/nytimes/utils.js
index df77369ce..06ebc2ba9 100644
--- a/lib/v2/nytimes/utils.js
+++ b/lib/v2/nytimes/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -14,7 +15,7 @@ const ProcessImage = ($, e) => {
};
const PuppeterGetter = async (ctx, browser, link) => {
- const result = await ctx.cache.tryGet(`nyt: ${link}`, async () => {
+ const result = await cache.tryGet(`nyt: ${link}`, async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
diff --git a/lib/v2/oceanengine/arithmetic-index.js b/lib/v2/oceanengine/arithmetic-index.js
index 9d22b86fb..fa06d9a4c 100644
--- a/lib/v2/oceanengine/arithmetic-index.js
+++ b/lib/v2/oceanengine/arithmetic-index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const dayjs = require('dayjs');
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';
@@ -94,7 +95,7 @@ module.exports = async (ctx) => {
const link = `https://trendinsight.oceanengine.com/arithmetic-index/analysis?keyword=${keyword}&appName=${channel}`;
- const item = await ctx.cache.tryGet(
+ const item = await cache.tryGet(
link,
async () => {
const browser = puppeteer();
diff --git a/lib/v2/odaily/activity.js b/lib/v2/odaily/activity.js
index 18577d334..5ab89a85c 100644
--- a/lib/v2/odaily/activity.js
+++ b/lib/v2/odaily/activity.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/odaily/post.js b/lib/v2/odaily/post.js
index 0d049fba2..1439882fe 100644
--- a/lib/v2/odaily/post.js
+++ b/lib/v2/odaily/post.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const ssr = JSON.parse(`{${detailResponse.data.match(/window\.__INITIAL_STATE__ = {(.*)}/)[1]}}`);
diff --git a/lib/v2/odaily/user.js b/lib/v2/odaily/user.js
index 752e10dd7..22f248188 100644
--- a/lib/v2/odaily/user.js
+++ b/lib/v2/odaily/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/oeeee/app/channel.js b/lib/v2/oeeee/app/channel.js
index deb6c0644..58de9d8ec 100644
--- a/lib/v2/oeeee/app/channel.js
+++ b/lib/v2/oeeee/app/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const channel = list[1] ? list[1].channel : '';
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `南方都市报客户端 - ${channel}`,
diff --git a/lib/v2/oeeee/app/reporter.js b/lib/v2/oeeee/app/reporter.js
index 729f75f04..0dc34aaf4 100644
--- a/lib/v2/oeeee/app/reporter.js
+++ b/lib/v2/oeeee/app/reporter.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseArticle } = require('../utils');
import { art } from '@/utils/render';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const author = response.data.info ? response.data.info.name : '';
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `南方都市报奥一网 - ${author}`,
diff --git a/lib/v2/oeeee/web.js b/lib/v2/oeeee/web.js
index d527be11b..ecd4da29e 100644
--- a/lib/v2/oeeee/web.js
+++ b/lib/v2/oeeee/web.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const channelEname = list[1] ? list[1].channelEname : '';
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `南方都市报奥一网`,
diff --git a/lib/v2/oilchem/index.js b/lib/v2/oilchem/index.js
index f8710111a..1a21bea46 100644
--- a/lib/v2/oilchem/index.js
+++ b/lib/v2/oilchem/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const routes = require('./routes');
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/oncc/index.js b/lib/v2/oncc/index.js
index 9e00bb4aa..b295095c6 100644
--- a/lib/v2/oncc/index.js
+++ b/lib/v2/oncc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -57,7 +58,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
- const desc = await ctx.cache.tryGet(item.link, async () => {
+ const desc = await cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const $ = load(detailResponse.data);
const imageUrl = rootUrl + $('img').eq(0).attr('src');
diff --git a/lib/v2/oncc/money18.js b/lib/v2/oncc/money18.js
index dc77e3706..6034d27a6 100644
--- a/lib/v2/oncc/money18.js
+++ b/lib/v2/oncc/money18.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const dayjs = require('dayjs');
@@ -86,7 +87,7 @@ module.exports = async (ctx) => {
if (id !== 'ipo') {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/onet/news.js b/lib/v2/onet/news.js
index bbe8c025a..858610325 100644
--- a/lib/v2/onet/news.js
+++ b/lib/v2/onet/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const parser = require('@/utils/rss-parser');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const feed = await parser.parseURL(rssUrl);
const items = await Promise.all(
feed.items.map(async (item) => {
- const { description, author, category } = await ctx.cache.tryGet(item.link, async () => {
+ const { description, author, category } = await cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
headers: {
referer: 'https://www.onet.pl/', // for some reason onet.pl will redirect to the main page if referer is not set
diff --git a/lib/v2/openai/chatgpt.js b/lib/v2/openai/chatgpt.js
index 0a5daaef2..3b516e8a1 100644
--- a/lib/v2/openai/chatgpt.js
+++ b/lib/v2/openai/chatgpt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const dayjs = require('dayjs');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -8,7 +9,7 @@ dayjs.extend(require('dayjs/plugin/isSameOrBefore'));
module.exports = async (ctx) => {
const articleUrl = 'https://help.openai.com/en/articles/6825453-chatgpt-release-notes';
- const cache = await ctx.cache.tryGet(
+ const cacheIn = await cache.tryGet(
articleUrl,
async () => {
const returns = [];
@@ -90,9 +91,9 @@ module.exports = async (ctx) => {
);
ctx.set('data', {
- title: cache.feedTitle,
- description: cache.feedDesc,
+ title: cacheIn.feedTitle,
+ description: cacheIn.feedDesc,
link: articleUrl,
- item: cache.items,
+ item: cacheIn.items,
});
};
diff --git a/lib/v2/openai/common.js b/lib/v2/openai/common.js
index 5e6eeb8fa..e3b38cfc7 100644
--- a/lib/v2/openai/common.js
+++ b/lib/v2/openai/common.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -21,7 +22,7 @@ const getApiUrl = async () => {
};
const parseArticle = (ctx, rootUrl, attributes) =>
- ctx.cache.tryGet(attributes.slug, async () => {
+ cache.tryGet(attributes.slug, async () => {
const textUrl = `${rootUrl}/${attributes.slug}`;
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/oreno3d/main.js b/lib/v2/oreno3d/main.js
index 082caaac5..7afdbd12c 100644
--- a/lib/v2/oreno3d/main.js
+++ b/lib/v2/oreno3d/main.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
@@ -79,7 +80,7 @@ module.exports = async (ctx) => {
oreno3d_link,
});
const title = `${video_name} - ${authors}`;
- const realData = await ctx.cache.tryGet(oreno3d_link, () => {
+ const realData = await cache.tryGet(oreno3d_link, () => {
const result = {
title,
author: authors,
diff --git a/lib/v2/oschina/news.js b/lib/v2/oschina/news.js
index 686884b1a..7f5783708 100644
--- a/lib/v2/oschina/news.js
+++ b/lib/v2/oschina/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
import timezone from '@/utils/timezone';
@@ -58,7 +59,7 @@ module.exports = async (ctx) => {
const resultItem = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/^https?:\/\/(my|www)\.oschina.net\/.*$/.test(item.link)) {
const detail = await got(item.link, {
headers: {
diff --git a/lib/v2/oschina/topic.js b/lib/v2/oschina/topic.js
index 5a671e32a..9f657595c 100644
--- a/lib/v2/oschina/topic.js
+++ b/lib/v2/oschina/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const resultItem = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const content = await loadContent(item.link);
content('.ad-wrap').remove();
diff --git a/lib/v2/oschina/user.js b/lib/v2/oschina/user.js
index 8c3015ef9..aecb9a6df 100644
--- a/lib/v2/oschina/user.js
+++ b/lib/v2/oschina/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const resultItem = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.accessible) {
const detail = await got(item.link);
const content = load(detail.data);
diff --git a/lib/v2/oshwhub/explore.js b/lib/v2/oshwhub/explore.js
index 03a00b36f..ed249c699 100644
--- a/lib/v2/oshwhub/explore.js
+++ b/lib/v2/oshwhub/explore.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -65,7 +66,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
projects.map((id, item) => {
const detailUrl = `${baseUrl}${item.attribs.href}`;
- return ctx.cache.tryGet(detailUrl, async () => {
+ return cache.tryGet(detailUrl, async () => {
const response = await got({
method: 'get',
url: detailUrl,
@@ -86,7 +87,7 @@ module.exports = async (ctx) => {
// request images
const dataUuid = $$('div[class="projects-detail"]').attr()['data-uuid'];
- const { images, boms } = await requestImages(`${baseUrl}/api/project/${dataUuid}/pro_images`, ctx.cache.tryGet);
+ const { images, boms } = await requestImages(`${baseUrl}/api/project/${dataUuid}/pro_images`, cache.tryGet);
const description = art(path.join(__dirname, 'templates/description.art'), {
title,
diff --git a/lib/v2/otobanana/cast.js b/lib/v2/otobanana/cast.js
index 50002da5c..9b646b432 100644
--- a/lib/v2/otobanana/cast.js
+++ b/lib/v2/otobanana/cast.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiBase, baseUrl, getUserInfo, renderCast } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const userInfo = await getUserInfo(id, ctx.cache.tryGet);
+ const userInfo = await getUserInfo(id, cache.tryGet);
const { data: castData } = await got(`${apiBase}/users/${id}/casts/`);
const casts = castData.results.map((item) => renderCast(item));
diff --git a/lib/v2/otobanana/livestream.js b/lib/v2/otobanana/livestream.js
index d47eda905..9fce4136a 100644
--- a/lib/v2/otobanana/livestream.js
+++ b/lib/v2/otobanana/livestream.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiBase, baseUrl, getUserInfo, renderLive } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const userInfo = await getUserInfo(id, ctx.cache.tryGet);
+ const userInfo = await getUserInfo(id, cache.tryGet);
const { data: liveData } = await got(`${apiBase}/users/${id}/livestreams/`);
const casts = liveData.results.map((item) => renderLive(item));
diff --git a/lib/v2/otobanana/timeline.js b/lib/v2/otobanana/timeline.js
index 8d1298e97..007e472cd 100644
--- a/lib/v2/otobanana/timeline.js
+++ b/lib/v2/otobanana/timeline.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { apiBase, baseUrl, getUserInfo, renderPost } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
- const userInfo = await getUserInfo(id, ctx.cache.tryGet);
+ const userInfo = await getUserInfo(id, cache.tryGet);
const { data: postData } = await got(`${apiBase}/users/${id}/posts/`);
const posts = postData.results.map((item) => renderPost(item));
diff --git a/lib/v2/ouc/it-tx.js b/lib/v2/ouc/it-tx.js
index d31d8707a..8c869d1f4 100644
--- a/lib/v2/ouc/it-tx.js
+++ b/lib/v2/ouc/it-tx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.author = '中国海洋大学信息科学与工程学院';
diff --git a/lib/v2/ouc/it.js b/lib/v2/ouc/it.js
index 665f5dd22..92d977112 100644
--- a/lib/v2/ouc/it.js
+++ b/lib/v2/ouc/it.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.author = '中国海洋大学信息科学与工程学院';
diff --git a/lib/v2/ouc/jwc.js b/lib/v2/ouc/jwc.js
index 61aa7f7c2..6caf6af1a 100644
--- a/lib/v2/ouc/jwc.js
+++ b/lib/v2/ouc/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got('https://jwc.ouc.edu.cn' + item.link);
const $ = load(response.data);
item.author = '中国海洋大学教务处';
diff --git a/lib/v2/ouc/jwgl.js b/lib/v2/ouc/jwgl.js
index b9648825e..ffd459ef0 100644
--- a/lib/v2/ouc/jwgl.js
+++ b/lib/v2/ouc/jwgl.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('div.notice').html();
diff --git a/lib/v2/oup/index.js b/lib/v2/oup/index.js
index 01b150bed..e7db46846 100644
--- a/lib/v2/oup/index.js
+++ b/lib/v2/oup/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
Cookie: cookies,
diff --git a/lib/v2/panewslab/author.js b/lib/v2/panewslab/author.js
index 9018f241c..2755098ed 100644
--- a/lib/v2/panewslab/author.js
+++ b/lib/v2/panewslab/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/panewslab/index.js b/lib/v2/panewslab/index.js
index fc34cce18..300d71c25 100644
--- a/lib/v2/panewslab/index.js
+++ b/lib/v2/panewslab/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/panewslab/topic.js b/lib/v2/panewslab/topic.js
index 6a4a61921..593388bb0 100644
--- a/lib/v2/panewslab/topic.js
+++ b/lib/v2/panewslab/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/paradigm/writing.js b/lib/v2/paradigm/writing.js
index 6836b6ff7..e745b3efa 100644
--- a/lib/v2/paradigm/writing.js
+++ b/lib/v2/paradigm/writing.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.api);
const $ = load(response.data.pageProps.content, null, false);
diff --git a/lib/v2/parliament/section77.js b/lib/v2/parliament/section77.js
index c82913713..8f18587bd 100644
--- a/lib/v2/parliament/section77.js
+++ b/lib/v2/parliament/section77.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -79,7 +80,7 @@ module.exports = async (ctx) => {
const actListFull = await Promise.all(
actList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got({
url: item.link,
cookieJar,
diff --git a/lib/v2/paulgraham/article.js b/lib/v2/paulgraham/article.js
index ace6713d9..a38f47f03 100644
--- a/lib/v2/paulgraham/article.js
+++ b/lib/v2/paulgraham/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/penguin-random-house/utils.js b/lib/v2/penguin-random-house/utils.js
index adf244fad..4918159b5 100644
--- a/lib/v2/penguin-random-house/utils.js
+++ b/lib/v2/penguin-random-house/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { art } from '@/utils/render';
@@ -94,7 +95,7 @@ const parseArticle = (element) => {
const parseList = (items, ctx, contentParser) =>
Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.url, async () => {
+ cache.tryGet(item.url, async () => {
const itemRes = await got(item.url);
const itemPage = itemRes.data;
diff --git a/lib/v2/people/index.js b/lib/v2/people/index.js
index eb3078afd..895056ca0 100644
--- a/lib/v2/people/index.js
+++ b/lib/v2/people/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -48,7 +49,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
diff --git a/lib/v2/people/liuyan.js b/lib/v2/people/liuyan.js
index f1f4585d0..d17e40ace 100644
--- a/lib/v2/people/liuyan.js
+++ b/lib/v2/people/liuyan.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/people/xjpjh.js b/lib/v2/people/xjpjh.js
index 5364519f7..5b3fc8f41 100644
--- a/lib/v2/people/xjpjh.js
+++ b/lib/v2/people/xjpjh.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = require('url');
@@ -41,9 +42,9 @@ module.exports = async (ctx) => {
const title = info.title;
const itemUrl = url.resolve(host, info.link);
- const cache = await ctx.cache.get(itemUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(itemUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got.get(itemUrl);
@@ -55,7 +56,7 @@ module.exports = async (ctx) => {
link: itemUrl,
description,
};
- ctx.cache.set(itemUrl, JSON.stringify(single));
+ cache.set(itemUrl, JSON.stringify(single));
return single;
})
);
diff --git a/lib/v2/peopo/topic.js b/lib/v2/peopo/topic.js
index d3a19f0ae..66b52b258 100644
--- a/lib/v2/peopo/topic.js
+++ b/lib/v2/peopo/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/phoronix/index.js b/lib/v2/phoronix/index.js
index fe2af0e46..edaa312e0 100644
--- a/lib/v2/phoronix/index.js
+++ b/lib/v2/phoronix/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -64,7 +65,7 @@ const webFetchCb = (response) => {
};
const webFetch = (ctx, url) =>
- ctx.cache.tryGet(`${webArticlesCacheKey}:${url}`, async () => {
+ cache.tryGet(`${webArticlesCacheKey}:${url}`, async () => {
try {
return webFetchCb(await got(url));
} catch (error) {
@@ -87,13 +88,13 @@ const legacyFetch = async (ctx, page, queryOrItem) => {
}
let response;
- const webUrl = await ctx.cache.tryGet(`${redirectCacheKey}:${legacyUrl.toString()}`, async () => {
+ const webUrl = await cache.tryGet(`${redirectCacheKey}:${legacyUrl.toString()}`, async () => {
response = await got(legacyUrl.toString());
return response.url;
});
if (response) {
const feed = webFetchCb(response);
- ctx.cache.set(`${webArticlesCacheKey}:${webUrl}`, feed);
+ cache.set(`${webArticlesCacheKey}:${webUrl}`, feed);
return feed;
}
return await webFetch(ctx, webUrl);
@@ -126,7 +127,7 @@ module.exports = async (ctx) => {
feed.item = await Promise.all(
feed.item.map((item) =>
- ctx.cache.tryGet(`${articleCacheKey}:${item.link}`, async () => {
+ cache.tryGet(`${articleCacheKey}:${item.link}`, async () => {
const response = await got(item.link);
const html = response.body;
const $ = load(html);
@@ -188,7 +189,7 @@ module.exports = async (ctx) => {
if (links.length) {
const pages = await Promise.all(
links.map((link) =>
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
const response = await got(link);
const html = response.data;
const $$ = load(html);
diff --git a/lib/v2/pianyuan/search.js b/lib/v2/pianyuan/search.js
index c5b30dea3..b6807b6fb 100644
--- a/lib/v2/pianyuan/search.js
+++ b/lib/v2/pianyuan/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
await Promise.all(
searchLinks.map(async (e) => {
const link = new URL(e, link_base).href;
- const single = await ctx.cache.tryGet(link, async () => {
+ const single = await cache.tryGet(link, async () => {
const res = await utils.request(link, ctx.cache);
const content = load(res.data);
content('.ico.ico_bt')
diff --git a/lib/v2/picnob/user.js b/lib/v2/picnob/user.js
index 169b10d8a..5b1f02ed3 100644
--- a/lib/v2/picnob/user.js
+++ b/lib/v2/picnob/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -54,7 +55,7 @@ module.exports = async (ctx) => {
const { shortcode, type, sum_pure, time } = item;
const link = `${baseUrl}/post/${shortcode}/`;
if (type === 'img_multi') {
- item.images = await ctx.cache.tryGet(link, async () => {
+ item.images = await cache.tryGet(link, async () => {
let html;
if (usePuppeteer) {
html = await puppeteerGet(link, browser);
diff --git a/lib/v2/picuki/profile.js b/lib/v2/picuki/profile.js
index 98ca28a93..13580e6e1 100644
--- a/lib/v2/picuki/profile.js
+++ b/lib/v2/picuki/profile.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
const chrono = require('chrono-node');
import { art } from '@/utils/render';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const profileUrl = `https://www.picuki.com/profile/${id}`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`picuki-${id}-profile-${includeStories}`,
async () => {
const _r = await puppeteerGet(profileUrl, browser, includeStories);
@@ -93,12 +94,12 @@ module.exports = async (ctx) => {
async function getMedia(url) {
const getPost = () => puppeteerGet(url, browser);
- let data = await ctx.cache.tryGet(url, getPost);
+ let data = await cache.tryGet(url, getPost);
if (Object.prototype.toString.call(data) === '[object Object]') {
// oops, it's a json, maybe it's an old cache from the old version of this route!
data = await getPost();
// re-cache it
- await ctx.cache.set(url, data);
+ await cache.set(url, data);
}
const $ = load(data);
// Instagram 允许最多 10 条图片/视频任意混合于一条 post,picuki 在所有情况下都会将它(们)置于 .single-photo 内
diff --git a/lib/v2/pingwest/tag.js b/lib/v2/pingwest/tag.js
index 84f0a3907..16543ccff 100644
--- a/lib/v2/pingwest/tag.js
+++ b/lib/v2/pingwest/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const baseUrl = 'https://www.pingwest.com';
const tagUrl = `${baseUrl}/tag/${tag}`;
- const { tagId, tagName } = await ctx.cache.tryGet(`pingwest:tag:${tag}`, async () => {
+ const { tagId, tagName } = await cache.tryGet(`pingwest:tag:${tag}`, async () => {
const res = await got(tagUrl, {
headers: {
Referer: baseUrl,
diff --git a/lib/v2/pingwest/user.js b/lib/v2/pingwest/user.js
index 7722ee74d..7eb7ef709 100644
--- a/lib/v2/pingwest/user.js
+++ b/lib/v2/pingwest/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -6,7 +7,7 @@ module.exports = async (ctx) => {
const { uid, type = 'article', option } = ctx.params;
const baseUrl = 'https://www.pingwest.com';
const aimUrl = `${baseUrl}/user/${uid}/${type}`;
- const { userName, realUid, userSign, userAvatar } = await ctx.cache.tryGet(`pingwest:user:info:${uid}`, async () => {
+ const { userName, realUid, userSign, userAvatar } = await cache.tryGet(`pingwest:user:info:${uid}`, async () => {
const res = await got(aimUrl, {
headers: {
Referer: baseUrl,
diff --git a/lib/v2/pixabay/search.js b/lib/v2/pixabay/search.js
index 31b516cf6..73f31a4cd 100644
--- a/lib/v2/pixabay/search.js
+++ b/lib/v2/pixabay/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { art } from '@/utils/render';
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const key = config.pixabay?.key ?? '7329690-bbadad6d872ba577d5a358679';
const baseUrl = 'https://pixabay.com';
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`pixabay:search:${q}:${order}`,
async () => {
const { data } = await got(`${baseUrl}/api/`, {
diff --git a/lib/v2/pixiv/bookmarks.js b/lib/v2/pixiv/bookmarks.js
index 98b28ebb6..ea5791c9f 100644
--- a/lib/v2/pixiv/bookmarks.js
+++ b/lib/v2/pixiv/bookmarks.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getToken } = require('./token');
const getBookmarks = require('./api/get-bookmarks');
const getUserDetail = require('./api/get-user-detail');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const id = ctx.req.param('id');
- const token = await getToken(ctx.cache.tryGet);
+ const token = await getToken(cache.tryGet);
if (!token) {
throw new Error('pixiv not login');
}
diff --git a/lib/v2/pixiv/illustfollow.js b/lib/v2/pixiv/illustfollow.js
index e9e5c60a6..7a8f7fb59 100644
--- a/lib/v2/pixiv/illustfollow.js
+++ b/lib/v2/pixiv/illustfollow.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getToken } = require('./token');
const getIllustFollows = require('./api/get-illust-follows');
import { config } from '@/config';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
throw new Error('pixiv RSS is disabled due to the lack of relevant config');
}
- const token = await getToken(ctx.cache.tryGet);
+ const token = await getToken(cache.tryGet);
if (!token) {
throw new Error('pixiv not login');
}
diff --git a/lib/v2/pixiv/ranking.js b/lib/v2/pixiv/ranking.js
index 8322906b7..4afd87f1b 100644
--- a/lib/v2/pixiv/ranking.js
+++ b/lib/v2/pixiv/ranking.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getToken } = require('./token');
const getRanking = require('./api/get-ranking');
import { config } from '@/config';
@@ -63,7 +64,7 @@ module.exports = async (ctx) => {
const mode = alias[ctx.req.param('mode')] ?? ctx.req.param('mode');
const date = ctx.req.param('date') ? new Date(ctx.req.param('date')) : new Date();
- const token = await getToken(ctx.cache.tryGet);
+ const token = await getToken(cache.tryGet);
if (!token) {
throw new Error('pixiv not login');
}
diff --git a/lib/v2/pixiv/search.js b/lib/v2/pixiv/search.js
index aa11c7e0e..8ecfd30b1 100644
--- a/lib/v2/pixiv/search.js
+++ b/lib/v2/pixiv/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getToken } = require('./token');
const searchPopularIllust = require('./api/search-popular-illust');
const searchIllust = require('./api/search-illust');
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const order = ctx.req.param('order') || 'date';
const mode = ctx.req.param('mode');
- const token = await getToken(ctx.cache.tryGet);
+ const token = await getToken(cache.tryGet);
if (!token) {
throw new Error('pixiv not login');
}
diff --git a/lib/v2/pixiv/user.js b/lib/v2/pixiv/user.js
index 1e2fbfa3e..e5d3d766a 100644
--- a/lib/v2/pixiv/user.js
+++ b/lib/v2/pixiv/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getToken } = require('./token');
const getIllusts = require('./api/get-illusts');
import { config } from '@/config';
@@ -10,7 +11,7 @@ module.exports = async (ctx) => {
}
const id = ctx.req.param('id');
- const token = await getToken(ctx.cache.tryGet);
+ const token = await getToken(cache.tryGet);
if (!token) {
throw new Error('pixiv not login');
}
diff --git a/lib/v2/piyao/jrpy.js b/lib/v2/piyao/jrpy.js
index ecf604b47..5d06a217f 100644
--- a/lib/v2/piyao/jrpy.js
+++ b/lib/v2/piyao/jrpy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/pku/bbs/hot.js b/lib/v2/pku/bbs/hot.js
index 0c999815a..d1b12c0d8 100644
--- a/lib/v2/pku/bbs/hot.js
+++ b/lib/v2/pku/bbs/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
listItems.map(({ url, title }) =>
- ctx.cache.tryGet(url, async () => {
+ cache.tryGet(url, async () => {
// try catch 处理部分无 Cookie 时无法访问的帖子
try {
const r = await got(url, { headers });
diff --git a/lib/v2/pku/cls/announcement.js b/lib/v2/pku/cls/announcement.js
index 18f6a3ab4..3004da393 100644
--- a/lib/v2/pku/cls/announcement.js
+++ b/lib/v2/pku/cls/announcement.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/pku/eecs.js b/lib/v2/pku/eecs.js
index e4c8915e8..ace5db701 100644
--- a/lib/v2/pku/eecs.js
+++ b/lib/v2/pku/eecs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detail = await got(item.link);
const content = load(detail.data);
diff --git a/lib/v2/pku/hr.js b/lib/v2/pku/hr.js
index 5e55728a0..df065757c 100644
--- a/lib/v2/pku/hr.js
+++ b/lib/v2/pku/hr.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/pku/nsd.js b/lib/v2/pku/nsd.js
index 53e9aaa44..8b5123b61 100644
--- a/lib/v2/pku/nsd.js
+++ b/lib/v2/pku/nsd.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { finishArticleItem } = require('@/utils/wechat-mp');
@@ -42,14 +43,14 @@ module.exports = async (ctx) => {
case 'wechat-mp':
return finishArticleItem(item);
case 'pku-news':
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const detailResponse = await got({ url: item.link, https: { rejectUnauthorized: false } });
const content = load(detailResponse.data);
item.description = content('div.pageArticle > div.col.lf').html();
return item;
});
case 'in-site':
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const detailResponse = await got({ url: item.link, https: { rejectUnauthorized: false } });
const content = load(detailResponse.data);
item.description = content('div.article').html();
diff --git a/lib/v2/pku/scc/recruit.js b/lib/v2/pku/scc/recruit.js
index bbe7305d5..52b6c4159 100644
--- a/lib/v2/pku/scc/recruit.js
+++ b/lib/v2/pku/scc/recruit.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
link: rootUrl,
item: await Promise.all(
sorted.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detail_page = await got(item.link);
const detail = load(detail_page.data);
const script = detail('script', 'div#content-div').html();
diff --git a/lib/v2/pku/ss/admission.js b/lib/v2/pku/ss/admission.js
index 77ef87cc8..3845eb5d9 100644
--- a/lib/v2/pku/ss/admission.js
+++ b/lib/v2/pku/ss/admission.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
const { baseUrl, getSingleRecord, getArticle } = require('./common');
const host = `${baseUrl}/admission/admnotice/`;
module.exports = async (ctx) => {
const items = await getSingleRecord(host);
- const out = await Promise.all(items.map((item) => getArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(items.map((item) => getArticle(item, cache.tryGet)));
ctx.set('data', {
title: '北大软微-招生通知',
diff --git a/lib/v2/pku/ss/notice.js b/lib/v2/pku/ss/notice.js
index 261ee28de..ca80203f8 100644
--- a/lib/v2/pku/ss/notice.js
+++ b/lib/v2/pku/ss/notice.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
const { baseUrl, getSingleRecord, getArticle } = require('./common');
const host = `${baseUrl}/newscenter/notice/`;
module.exports = async (ctx) => {
const items = await getSingleRecord(host);
- const out = await Promise.all(items.map((item) => getArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(items.map((item) => getArticle(item, cache.tryGet)));
ctx.set('data', {
title: '北大软微-通知公告',
diff --git a/lib/v2/pku/ss/pg-admin.js b/lib/v2/pku/ss/pg-admin.js
index f4d32f16c..a4f0a062e 100644
--- a/lib/v2/pku/ss/pg-admin.js
+++ b/lib/v2/pku/ss/pg-admin.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
const { baseUrl, getSingleRecord, getArticle } = require('./common');
const host = `${baseUrl}/admission/admbrochure/`;
module.exports = async (ctx) => {
const items = await getSingleRecord(host);
- const out = await Promise.all(items.map((item) => getArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(items.map((item) => getArticle(item, cache.tryGet)));
ctx.set('data', {
title: '北大软微-硕士统考招生',
diff --git a/lib/v2/plurk/anonymous.js b/lib/v2/plurk/anonymous.js
index 7fdbc45dc..6c1cd3fe5 100644
--- a/lib/v2/plurk/anonymous.js
+++ b/lib/v2/plurk/anonymous.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, getPlurk } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
delete apiResponse.pids;
delete apiResponse.count;
- const items = await Promise.all(Object.values(apiResponse).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, 'ಠ_ಠ', ctx.cache.tryGet)));
+ const items = await Promise.all(Object.values(apiResponse).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, 'ಠ_ಠ', cache.tryGet)));
ctx.set('data', {
title: 'Anonymous - Plurk',
diff --git a/lib/v2/plurk/hotlinks.js b/lib/v2/plurk/hotlinks.js
index 292a1f31b..0220921cb 100644
--- a/lib/v2/plurk/hotlinks.js
+++ b/lib/v2/plurk/hotlinks.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, getPlurk } = require('./utils');
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
},
});
- const items = await Promise.all(apiResponse.map((item) => getPlurk(item.link_url.startsWith('https://www.plurk.com/p/') ? item.link_url : `plurk:${item.link_url}`, item, null, ctx.cache.tryGet)));
+ const items = await Promise.all(apiResponse.map((item) => getPlurk(item.link_url.startsWith('https://www.plurk.com/p/') ? item.link_url : `plurk:${item.link_url}`, item, null, cache.tryGet)));
ctx.set('data', {
title: `Hot Links - Plurk`,
diff --git a/lib/v2/plurk/news.js b/lib/v2/plurk/news.js
index 024201126..033c3b0b1 100644
--- a/lib/v2/plurk/news.js
+++ b/lib/v2/plurk/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, fetchFriends, getPlurk } = require('./utils');
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const userIds = apiResponse.map((item) => item.user_id);
const names = await fetchFriends(userIds);
- const items = await Promise.all(apiResponse.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, ctx.cache.tryGet)));
+ const items = await Promise.all(apiResponse.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, cache.tryGet)));
ctx.set('data', {
title: 'Plurk News - Plurk',
diff --git a/lib/v2/plurk/search.js b/lib/v2/plurk/search.js
index 3749596a3..922f8028d 100644
--- a/lib/v2/plurk/search.js
+++ b/lib/v2/plurk/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const dayjs = require('dayjs');
const { baseUrl, getPlurk } = require('./utils');
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
const users = apiResponse.users;
const plurks = apiResponse.plurks;
- const items = await Promise.all(plurks.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, users[item.user_id].display_name, ctx.cache.tryGet)));
+ const items = await Promise.all(plurks.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, users[item.user_id].display_name, cache.tryGet)));
ctx.set('data', {
title: `Search "${keyword}" - Plurk`,
diff --git a/lib/v2/plurk/top.js b/lib/v2/plurk/top.js
index 0732ac270..3422fe531 100644
--- a/lib/v2/plurk/top.js
+++ b/lib/v2/plurk/top.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, getPlurk } = require('./utils');
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
},
});
- const items = await Promise.all(apiResponse.stats.map((item) => item[1]).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, item.owner.display_name, ctx.cache.tryGet)));
+ const items = await Promise.all(apiResponse.stats.map((item) => item[1]).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, item.owner.display_name, cache.tryGet)));
ctx.set('data', {
title: 'Top Plurk - Plurk',
diff --git a/lib/v2/plurk/topic.js b/lib/v2/plurk/topic.js
index 3d7326777..169385926 100644
--- a/lib/v2/plurk/topic.js
+++ b/lib/v2/plurk/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, fetchFriends, getPlurk } = require('./utils');
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const userIds = Object.values(apiResponse).map((item) => item.user_id);
const names = await fetchFriends(userIds);
- const items = await Promise.all(Object.values(apiResponse).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, ctx.cache.tryGet)));
+ const items = await Promise.all(Object.values(apiResponse).map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, cache.tryGet)));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/plurk/user.js b/lib/v2/plurk/user.js
index 7d2ca876f..101c6cb77 100644
--- a/lib/v2/plurk/user.js
+++ b/lib/v2/plurk/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, fetchFriends, getPlurk } = require('./utils');
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const userIds = publicPlurks.map((item) => item.user_id);
const names = await fetchFriends(userIds);
- const items = await Promise.all(publicPlurks.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, ctx.cache.tryGet)));
+ const items = await Promise.all(publicPlurks.map((item) => getPlurk(`plurk:${item.plurk_id}`, item, names[item.user_id].display_name, cache.tryGet)));
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/pnas/index.js b/lib/v2/pnas/index.js
index 3d01ce639..cbb185d53 100644
--- a/lib/v2/pnas/index.js
+++ b/lib/v2/pnas/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -13,14 +14,14 @@ module.exports = async (ctx) => {
const { topicPath } = ctx.params;
const link = `${baseUrl}/${topicPath ?? 'latest'}`;
- let cookieJar = await ctx.cache.get('pnas:cookieJar');
+ let cookieJar = await cache.get('pnas:cookieJar');
const cacheMiss = !cookieJar;
cookieJar = cacheMiss ? new CookieJar() : CookieJar.fromJSON(cookieJar);
const { data: res } = await got(link, {
cookieJar,
});
if (cacheMiss) {
- await ctx.cache.set('pnas:cookieJar', cookieJar.toJSON());
+ await cache.set('pnas:cookieJar', cookieJar.toJSON());
}
const $ = load(res);
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const page = await browser.newPage();
await setCookies(page, await cookieJar.getCookieString(item.link), '.pnas.org');
await page.setRequestInterception(true);
diff --git a/lib/v2/pornhub/category.js b/lib/v2/pornhub/category.js
index 0358fcc7c..ba90f95b3 100644
--- a/lib/v2/pornhub/category.js
+++ b/lib/v2/pornhub/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { defaultDomain, renderDescription } = require('./utils');
@@ -6,7 +7,7 @@ import { config } from '@/config';
module.exports = async (ctx) => {
const category = ctx.req.param('caty');
- const categories = await ctx.cache.tryGet('pornhub:categories', async () => {
+ const categories = await cache.tryGet('pornhub:categories', async () => {
const { data } = await got(`${defaultDomain}/webmasters/categories`);
return data.categories;
});
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const categoryId = isNaN(category) ? categories.find((item) => item.category === category)?.id : category;
const categoryName = isNaN(category) ? category : categories.find((item) => item.id === Number.parseInt(category)).category;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
`pornhub:category:${categoryName}`,
async () => {
const { data } = await got(`${defaultDomain}/webmasters/search?category=${categoryName}`);
diff --git a/lib/v2/producthunt/today.js b/lib/v2/producthunt/today.js
index 8ae1527e6..2ed981577 100644
--- a/lib/v2/producthunt/today.js
+++ b/lib/v2/producthunt/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.slug, async () => {
+ cache.tryGet(item.slug, async () => {
const detailresponse = await got(`https://www.producthunt.com/posts/${item.slug}`);
const data = JSON.parse(load(detailresponse.data)('#__NEXT_DATA__').html());
diff --git a/lib/v2/pts/index.js b/lib/v2/pts/index.js
index 6f340c47c..bf8758596 100644
--- a/lib/v2/pts/index.js
+++ b/lib/v2/pts/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/pts/live.js b/lib/v2/pts/live.js
index 28e505d61..0f8e242dc 100644
--- a/lib/v2/pts/live.js
+++ b/lib/v2/pts/live.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/pubmed/trending.js b/lib/v2/pubmed/trending.js
index c5a66214d..2b285e62a 100644
--- a/lib/v2/pubmed/trending.js
+++ b/lib/v2/pubmed/trending.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/pumc/mdadmission.js b/lib/v2/pumc/mdadmission.js
index c4c4dc3ba..97836256a 100644
--- a/lib/v2/pumc/mdadmission.js
+++ b/lib/v2/pumc/mdadmission.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/qbittorrent/news.js b/lib/v2/qbittorrent/news.js
index 9493abdb3..26ff0170f 100644
--- a/lib/v2/qbittorrent/news.js
+++ b/lib/v2/qbittorrent/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -6,7 +7,7 @@ import { config } from '@/config';
module.exports = async (ctx) => {
const baseUrl = 'https://www.qbittorrent.org';
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
`${baseUrl}/news.php`,
async () =>
(
diff --git a/lib/v2/qdu/houqin.js b/lib/v2/qdu/houqin.js
index b397e6ec2..70a487131 100644
--- a/lib/v2/qdu/houqin.js
+++ b/lib/v2/qdu/houqin.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
let itemDate = timezone(parseDate(item.find('span').text()), 8);
const path = item.find('a').attr('href');
const itemUrl = base + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
const result = await got(itemUrl);
const $ = load(result.data);
diff --git a/lib/v2/qdu/jwc.js b/lib/v2/qdu/jwc.js
index 5fb81c040..3b0fa14bf 100644
--- a/lib/v2/qdu/jwc.js
+++ b/lib/v2/qdu/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const path = item.find('.active').attr('href');
let itemUrl = '';
itemUrl = path.startsWith('http') ? path : base + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
if (path.startsWith('http')) {
description = itemTitle;
diff --git a/lib/v2/qianp/news.js b/lib/v2/qianp/news.js
index 134db2e60..e0c1f3714 100644
--- a/lib/v2/qianp/news.js
+++ b/lib/v2/qianp/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const { path = 'news/recommend' } = ctx.params;
const url = `${baseUrl}/${path}/`;
- const { token, secret } = await getTokenAndSecret(ctx.cache.tryGet);
+ const { token, secret } = await getTokenAndSecret(cache.tryGet);
const headers = {
cookie: token ? `t=${token}; r=${secret - 100}` : undefined,
};
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
headers,
});
diff --git a/lib/v2/qianzhan/column.js b/lib/v2/qianzhan/column.js
index 82dc3d0ca..845fc675f 100644
--- a/lib/v2/qianzhan/column.js
+++ b/lib/v2/qianzhan/column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
links.map((_, item) =>
- ctx.cache.tryGet(item, async () => {
+ cache.tryGet(item, async () => {
const detailResponse = await got(item);
const $ = load(detailResponse.data);
const description = $('#divArtBody').html();
diff --git a/lib/v2/qianzhan/rank.js b/lib/v2/qianzhan/rank.js
index 66dfb8872..37b75fabd 100644
--- a/lib/v2/qianzhan/rank.js
+++ b/lib/v2/qianzhan/rank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
links.map((_, item) =>
- ctx.cache.tryGet(item, async () => {
+ cache.tryGet(item, async () => {
const detailResponse = await got(item);
const $ = load(detailResponse.data);
const description = $('#divArtBody').html();
diff --git a/lib/v2/qingting/channel.js b/lib/v2/qingting/channel.js
index 522056615..d35843a4e 100644
--- a/lib/v2/qingting/channel.js
+++ b/lib/v2/qingting/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
link: `https://www.qingting.fm/channels/${ctx.req.param('id')}`,
item: await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
response = await got(item.link);
const data = JSON.parse(response.data.match(/},"program":(.*?),"plist":/)[1]);
item.description = data.richtext;
diff --git a/lib/v2/qingting/podcast.js b/lib/v2/qingting/podcast.js
index 0e53e344c..1939e9dae 100644
--- a/lib/v2/qingting/podcast.js
+++ b/lib/v2/qingting/podcast.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const crypto = require('crypto');
import got from '@/utils/got';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const resultItems = await Promise.all(
response.data.data.programs.map((item) =>
- ctx.cache.tryGet(`qingting:podcast:${ctx.req.param('id')}:${item.id}`, async () => {
+ cache.tryGet(`qingting:podcast:${ctx.req.param('id')}:${item.id}`, async () => {
const link = `https://www.qingting.fm/channels/${ctx.req.param('id')}/programs/${item.id}/`;
const path = `/audiostream/redirect/${ctx.req.param('id')}/${item.id}?access_token=&device_id=MOBILESITE&qingting_id=&t=${Date.now()}`;
diff --git a/lib/v2/qlu/notice.js b/lib/v2/qlu/notice.js
index ba47ea798..d40d26fbe 100644
--- a/lib/v2/qlu/notice.js
+++ b/lib/v2/qlu/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const itemDate = item.find('.news_year').text() + item.find('.news_days').text();
const path = item.find('.news_title').children().attr('href');
const itemUrl = path.startsWith('https') ? path : host + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
if (path.startsWith('https')) {
description = itemTitle;
diff --git a/lib/v2/qm120/news.js b/lib/v2/qm120/news.js
index fbce6e123..6b425931e 100644
--- a/lib/v2/qm120/news.js
+++ b/lib/v2/qm120/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/qoo-app/apps/note.js b/lib/v2/qoo-app/apps/note.js
index 3855decda..04e2fabca 100644
--- a/lib/v2/qoo-app/apps/note.js
+++ b/lib/v2/qoo-app/apps/note.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/qoo-app/apps/post.js b/lib/v2/qoo-app/apps/post.js
index 450915af5..9d27f637b 100644
--- a/lib/v2/qoo-app/apps/post.js
+++ b/lib/v2/qoo-app/apps/post.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(`${newsUrl}${lang ? `/${lang}` : ''}/wp-json/wp/v2/posts/${item.postId}`);
const $ = load(data.content.rendered, null, false);
diff --git a/lib/v2/qq/ac/utils.js b/lib/v2/qq/ac/utils.js
index f8fa90dfa..d6ebe6978 100644
--- a/lib/v2/qq/ac/utils.js
+++ b/lib/v2/qq/ac/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -32,7 +33,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/qq/fact/index.js b/lib/v2/qq/fact/index.js
index 45512d82f..65e3e1b32 100644
--- a/lib/v2/qq/fact/index.js
+++ b/lib/v2/qq/fact/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/qq/kg/cache.js b/lib/v2/qq/kg/cache.js
index 4e6db0747..8b0ec9798 100644
--- a/lib/v2/qq/kg/cache.js
+++ b/lib/v2/qq/kg/cache.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { JSDOM } = require('jsdom');
@@ -5,7 +6,7 @@ module.exports = {
getPlayInfo: async (ctx, shareId, ksong_mid = '') => {
const link = `https://node.kg.qq.com/play?s=${shareId}`;
const cache_key = ksong_mid ? `ksong:${ksong_mid}` : link;
- const data = await ctx.cache.tryGet(cache_key, async () => {
+ const data = await cache.tryGet(cache_key, async () => {
const response = await got(link);
const { window } = new JSDOM(response.data, {
runScripts: 'dangerously',
diff --git a/lib/v2/qq88/index.js b/lib/v2/qq88/index.js
index b47811915..cac2ff0f1 100644
--- a/lib/v2/qq88/index.js
+++ b/lib/v2/qq88/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/qqorw/index.js b/lib/v2/qqorw/index.js
index 773a08051..5d59e3cd8 100644
--- a/lib/v2/qqorw/index.js
+++ b/lib/v2/qqorw/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/questmobile/report.js b/lib/v2/questmobile/report.js
index fb22b93f0..e62d5444c 100644
--- a/lib/v2/questmobile/report.js
+++ b/lib/v2/questmobile/report.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -77,7 +78,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/quicker/qa.js b/lib/v2/quicker/qa.js
index 98b732d97..9ab92f761 100644
--- a/lib/v2/quicker/qa.js
+++ b/lib/v2/quicker/qa.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/quicker/share.js b/lib/v2/quicker/share.js
index 623bf86b3..ef50428f2 100644
--- a/lib/v2/quicker/share.js
+++ b/lib/v2/quicker/share.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/quicker/user.js b/lib/v2/quicker/user.js
index 8686e7980..3e4222c40 100644
--- a/lib/v2/quicker/user.js
+++ b/lib/v2/quicker/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/qweather/3days.js b/lib/v2/qweather/3days.js
index 9f6cf76d7..a90235184 100644
--- a/lib/v2/qweather/3days.js
+++ b/lib/v2/qweather/3days.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
@@ -12,11 +13,11 @@ module.exports = async (ctx) => {
if (!config.hefeng.key) {
throw new Error('QWeather RSS is disabled due to the lack of relevant config');
}
- const id = await ctx.cache.tryGet(ctx.req.param('location') + '_id', async () => {
+ const id = await cache.tryGet(ctx.req.param('location') + '_id', async () => {
const response = await got(`${CIRY_LOOKUP_API}?location=${ctx.req.param('location')}&key=${config.hefeng.key}`);
return response.data.location[0].id;
});
- const weatherData = await ctx.cache.tryGet(
+ const weatherData = await cache.tryGet(
ctx.req.param('location'),
async () => {
const response = await got(`${WEATHER_API}?key=${config.hefeng.key}&location=${id}`);
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
config.cache.contentExpire,
false
);
- const airQualityData = await ctx.cache.tryGet(
+ const airQualityData = await cache.tryGet(
`qweather:air:${ctx.req.param('location')}`,
async () => {
const airQualityResponse = await got(`${AIR_QUALITY_API}?location=${id}&key=${config.hefeng.key}`);
diff --git a/lib/v2/qweather/now.js b/lib/v2/qweather/now.js
index 1455ea66c..50b39152f 100644
--- a/lib/v2/qweather/now.js
+++ b/lib/v2/qweather/now.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
@@ -5,7 +6,7 @@ import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
const rootUrl = 'https://devapi.qweather.com/v7/weather/now?';
module.exports = async (ctx) => {
- const id = await ctx.cache.tryGet(ctx.req.param('location') + '_id', async () => {
+ const id = await cache.tryGet(ctx.req.param('location') + '_id', async () => {
const response = await got(`https://geoapi.qweather.com/v2/city/lookup?location=${ctx.req.param('location')}&key=${config.hefeng.key}`);
const data = [];
for (const i in response.data.location) {
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
return data[0].id;
});
const requestUrl = rootUrl + 'key=' + config.hefeng.key + '&location=' + id;
- const responseData = await ctx.cache.tryGet(
+ const responseData = await cache.tryGet(
ctx.req.param('location') + '_now',
async () => {
const response = await got(requestUrl);
diff --git a/lib/v2/radio-canada/latest.js b/lib/v2/radio-canada/latest.js
index 39ff5b5e1..4a7bb731f 100644
--- a/lib/v2/radio-canada/latest.js
+++ b/lib/v2/radio-canada/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/rattibha/user.js b/lib/v2/rattibha/user.js
index 31725908e..58b74a062 100644
--- a/lib/v2/rattibha/user.js
+++ b/lib/v2/rattibha/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
// Get tweet full text
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: data1 } = await got(item.threadData1URL, { headers: { accept: 'application/json' } });
const { data: data2 } = await got(item.threadData2URL, { headers: { accept: 'application/json' } });
item.description = [...data1.tweets, ...data2].reduce((accumulator, tweet) => `${accumulator}${tweet.tweet_detail.info.text}
`, '');
diff --git a/lib/v2/rawkuma/manga.js b/lib/v2/rawkuma/manga.js
index 9c8bf55bb..bc27c6709 100644
--- a/lib/v2/rawkuma/manga.js
+++ b/lib/v2/rawkuma/manga.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/readhub/daily.js b/lib/v2/readhub/daily.js
index bbcd53047..78109abc5 100644
--- a/lib/v2/readhub/daily.js
+++ b/lib/v2/readhub/daily.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
guid: item.uid,
}));
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
const $ = load(currentResponse);
diff --git a/lib/v2/readhub/index.js b/lib/v2/readhub/index.js
index a71fe1aaa..2215753b9 100644
--- a/lib/v2/readhub/index.js
+++ b/lib/v2/readhub/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.publishDate),
}));
- items = await processItems(items, ctx.cache.tryGet);
+ items = await processItems(items, cache.tryGet);
const $ = load(currentResponse);
diff --git a/lib/v2/researchgate/publications.js b/lib/v2/researchgate/publications.js
index af2914cf4..85811f576 100644
--- a/lib/v2/researchgate/publications.js
+++ b/lib/v2/researchgate/publications.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import puppeteer from '@/utils/puppeteer';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (request) => {
diff --git a/lib/v2/reuters/common.js b/lib/v2/reuters/common.js
index c4a0641f0..73cc145d5 100644
--- a/lib/v2/reuters/common.js
+++ b/lib/v2/reuters/common.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -78,7 +79,7 @@ module.exports = async (ctx) => {
const results = await Promise.allSettled(
items.map((item) =>
ctx.req.query('mode') === 'fulltext'
- ? ctx.cache.tryGet(item.link, async () => {
+ ? cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/reuters/investigates.js b/lib/v2/reuters/investigates.js
index 2c337bb2f..344a191dc 100644
--- a/lib/v2/reuters/investigates.js
+++ b/lib/v2/reuters/investigates.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/rfa/index.js b/lib/v2/rfa/index.js
index 9f94cee2f..0c1d55959 100644
--- a/lib/v2/rfa/index.js
+++ b/lib/v2/rfa/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const content = await got(item.link);
const description = load(content.data);
diff --git a/lib/v2/rfi/news.js b/lib/v2/rfi/news.js
index 698bcd0d1..936fcb687 100644
--- a/lib/v2/rfi/news.js
+++ b/lib/v2/rfi/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/right/forum.js b/lib/v2/right/forum.js
index e7a9d252f..012eae3fa 100644
--- a/lib/v2/right/forum.js
+++ b/lib/v2/right/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/rodong/news.js b/lib/v2/rodong/news.js
index 7aac6c2e0..316c0d51f 100644
--- a/lib/v2/rodong/news.js
+++ b/lib/v2/rodong/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/routledge/book-series.js b/lib/v2/routledge/book-series.js
index 1be90d983..b7ff34232 100644
--- a/lib/v2/routledge/book-series.js
+++ b/lib/v2/routledge/book-series.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
const isbn = $('meta[property="books:isbn"]').attr('content');
diff --git a/lib/v2/rsc/journal.js b/lib/v2/rsc/journal.js
index 6ba36a32c..a35cf7e89 100644
--- a/lib/v2/rsc/journal.js
+++ b/lib/v2/rsc/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -62,7 +63,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
if (item.category.pop()) {
const { data: detailResponse } = await got(item.link.replace(/\/articlelanding\//, '/articlehtml/'));
diff --git a/lib/v2/ruancan/utils.js b/lib/v2/ruancan/utils.js
index b3b475b04..3af71a158 100644
--- a/lib/v2/ruancan/utils.js
+++ b/lib/v2/ruancan/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx, currentUrl) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/ruc/hr.js b/lib/v2/ruc/hr.js
index b2565e9b0..5d4eefdc4 100644
--- a/lib/v2/ruc/hr.js
+++ b/lib/v2/ruc/hr.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/sakurazaka46/blog.js b/lib/v2/sakurazaka46/blog.js
index 42a5a5dea..a2713f6da 100644
--- a/lib/v2/sakurazaka46/blog.js
+++ b/lib/v2/sakurazaka46/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sakurazaka46/news.js b/lib/v2/sakurazaka46/news.js
index 6934da0e4..7a841e088 100644
--- a/lib/v2/sakurazaka46/news.js
+++ b/lib/v2/sakurazaka46/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/samsung/research/blog.js b/lib/v2/samsung/research/blog.js
index 3d5237547..ad9a51e3f 100644
--- a/lib/v2/samsung/research/blog.js
+++ b/lib/v2/samsung/research/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/saraba1st/digest.js b/lib/v2/saraba1st/digest.js
index 628da33c3..365eca525 100644
--- a/lib/v2/saraba1st/digest.js
+++ b/lib/v2/saraba1st/digest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { config } from '@/config';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const resultItems = await Promise.all(
count.map((i) =>
- ctx.cache.tryGet(i.link, async () => {
+ cache.tryGet(i.link, async () => {
i.description = await fetchContent(i.link);
return i;
})
diff --git a/lib/v2/sass/gs/index.js b/lib/v2/sass/gs/index.js
index dbb4a7342..fe0396afd 100644
--- a/lib/v2/sass/gs/index.js
+++ b/lib/v2/sass/gs/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const { href: path, title: itemTitle } = titleLink.children[0].attribs;
const itemUrl = path.startsWith('http') ? path : host + path;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = '';
if (itemUrl) {
const result = await got(itemUrl);
diff --git a/lib/v2/science/blogs.js b/lib/v2/science/blogs.js
index 10aad2587..44bf88683 100644
--- a/lib/v2/science/blogs.js
+++ b/lib/v2/science/blogs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const { baseUrl } = require('./utils');
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const { name = 'pipeline' } = ctx.params;
const link = `${baseUrl}/blogs/${name}/feed`;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
link,
async () => {
const browser = puppeteer();
diff --git a/lib/v2/science/current.js b/lib/v2/science/current.js
index 05bf8bba6..ced724b7f 100644
--- a/lib/v2/science/current.js
+++ b/lib/v2/science/current.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// journals form AAAS publishing group
//
// science: Science
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
.map((item) => getItem(item, $));
const browser = puppeteer();
- const items = await fetchDesc(list, browser, ctx.cache.tryGet);
+ const items = await fetchDesc(list, browser, cache.tryGet);
await browser.close();
ctx.set('data', {
diff --git a/lib/v2/science/early.js b/lib/v2/science/early.js
index fa4837354..15fe2fb9c 100644
--- a/lib/v2/science/early.js
+++ b/lib/v2/science/early.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import puppeteer from '@/utils/puppeteer';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
.map((item) => getItem(item, $));
const browser = puppeteer();
- const items = await fetchDesc(list, browser, ctx.cache.tryGet);
+ const items = await fetchDesc(list, browser, cache.tryGet);
await browser.close();
ctx.set('data', {
diff --git a/lib/v2/sciencedirect/journal.js b/lib/v2/sciencedirect/journal.js
index 1578cfe24..1762d8efc 100644
--- a/lib/v2/sciencedirect/journal.js
+++ b/lib/v2/sciencedirect/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sciencenet/blog.js b/lib/v2/sciencenet/blog.js
index 49e62663e..c681eb7b7 100644
--- a/lib/v2/sciencenet/blog.js
+++ b/lib/v2/sciencenet/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sciencenet/user.js b/lib/v2/sciencenet/user.js
index 9b3cb99b9..e716f6047 100644
--- a/lib/v2/sciencenet/user.js
+++ b/lib/v2/sciencenet/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/scmp/index.js b/lib/v2/scmp/index.js
index 185c78341..68de9f424 100644
--- a/lib/v2/scmp/index.js
+++ b/lib/v2/scmp/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem)));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem)));
ctx.set('json', {
items,
diff --git a/lib/v2/scmp/topic.js b/lib/v2/scmp/topic.js
index cbc562f43..f92620de2 100644
--- a/lib/v2/scmp/topic.js
+++ b/lib/v2/scmp/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
updated: parseDate(node.updatedDate, 'x'),
}));
- const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
+ const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('json', {
nextData,
diff --git a/lib/v2/sctv/programme.js b/lib/v2/sctv/programme.js
index e2ea04b75..fad60e7cd 100644
--- a/lib/v2/sctv/programme.js
+++ b/lib/v2/sctv/programme.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
await Promise.all(
array.map((list) =>
- ctx.cache.tryGet(list.link, async () => {
+ cache.tryGet(list.link, async () => {
const detailResponse = await got({
method: 'get',
url: list.link,
diff --git a/lib/v2/scut/jwc/news.js b/lib/v2/scut/jwc/news.js
index c6d2d504f..ddda6b1b7 100644
--- a/lib/v2/scut/jwc/news.js
+++ b/lib/v2/scut/jwc/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const url = require('url');
const querystring = require('querystring');
@@ -65,9 +66,9 @@ module.exports = async (ctx) => {
articleMetaArray.map(async (articleMeta) => {
const articleUrl = getArticleUrlById(articleMeta.id);
- const cache = await ctx.cache.get(articleUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(articleUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const qs = querystring.stringify({
@@ -98,7 +99,7 @@ module.exports = async (ctx) => {
pubDate: generateArticlePubDate(articleData.createDate).toUTCString(),
};
- ctx.cache.set(articleUrl, JSON.stringify(item));
+ cache.set(articleUrl, JSON.stringify(item));
return item;
})
);
diff --git a/lib/v2/scut/jwc/notice.js b/lib/v2/scut/jwc/notice.js
index e8d207b3f..a19043133 100644
--- a/lib/v2/scut/jwc/notice.js
+++ b/lib/v2/scut/jwc/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const url = require('url');
const querystring = require('querystring');
@@ -77,9 +78,9 @@ module.exports = async (ctx) => {
articleMetaArray.map(async (articleMeta) => {
const articleUrl = getArticleUrlById(articleMeta.id);
- const cache = await ctx.cache.get(articleUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(articleUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const qs = querystring.stringify({
@@ -110,7 +111,7 @@ module.exports = async (ctx) => {
pubDate: generateArticlePubDate(articleData.createDate).toUTCString(),
};
- ctx.cache.set(articleUrl, JSON.stringify(item));
+ cache.set(articleUrl, JSON.stringify(item));
return item;
})
);
diff --git a/lib/v2/scut/jwc/school.js b/lib/v2/scut/jwc/school.js
index a5e643150..a0315104a 100644
--- a/lib/v2/scut/jwc/school.js
+++ b/lib/v2/scut/jwc/school.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const url = require('url');
const querystring = require('querystring');
@@ -75,9 +76,9 @@ module.exports = async (ctx) => {
articleMetaArray.map(async (articleMeta) => {
const articleUrl = getArticleUrlById(articleMeta.id);
- const cache = await ctx.cache.get(articleUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(articleUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const qs = querystring.stringify({
@@ -108,7 +109,7 @@ module.exports = async (ctx) => {
pubDate: generateArticlePubDate(articleData.createDate).toUTCString(),
};
- ctx.cache.set(articleUrl, JSON.stringify(item));
+ cache.set(articleUrl, JSON.stringify(item));
return item;
})
);
diff --git a/lib/v2/scut/seie/news-ccenter.js b/lib/v2/scut/seie/news-ccenter.js
index f59b5273c..4f185178a 100644
--- a/lib/v2/scut/seie/news-ccenter.js
+++ b/lib/v2/scut/seie/news-ccenter.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
articleList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(`${rootUrl}${item.link}`);
const content = load(detailResponse.data);
diff --git a/lib/v2/scut/smae/notice.js b/lib/v2/scut/smae/notice.js
index b5c22d13f..fb6b8448b 100644
--- a/lib/v2/scut/smae/notice.js
+++ b/lib/v2/scut/smae/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
});
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/scvtc/xygg.js b/lib/v2/scvtc/xygg.js
index f0b43b9ff..d8cb2da90 100644
--- a/lib/v2/scvtc/xygg.js
+++ b/lib/v2/scvtc/xygg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/sdu/cmse.js b/lib/v2/sdu/cmse.js
index 74755f840..121726d52 100644
--- a/lib/v2/sdu/cmse.js
+++ b/lib/v2/sdu/cmse.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
.filter((e) => e.link.startsWith('../info'))
.map((item) => {
item.link = new URL(item.link.slice('3'), host).href;
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/sdu/cs.js b/lib/v2/sdu/cs.js
index a4310e351..e5eabf48d 100644
--- a/lib/v2/sdu/cs.js
+++ b/lib/v2/sdu/cs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
item = await Promise.all(
item.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (new URL(item.link).hostname === 'mp.weixin.qq.com') {
return finishArticleItem(item);
} else if (new URL(item.link).hostname !== 'www.cs.sdu.edu.cn') {
diff --git a/lib/v2/sdu/epe.js b/lib/v2/sdu/epe.js
index 0467596b5..35dc4294b 100644
--- a/lib/v2/sdu/epe.js
+++ b/lib/v2/sdu/epe.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
.filter((e) => e.link.startsWith('../info'))
.map((item) => {
item.link = new URL(item.link.slice('3'), host).href;
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/sdu/extractor/sdrj.js b/lib/v2/sdu/extractor/sdrj.js
index 1e43c125c..53d7c37e2 100644
--- a/lib/v2/sdu/extractor/sdrj.js
+++ b/lib/v2/sdu/extractor/sdrj.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-module.exports = (link, ctx) =>
- ctx.cache.tryGet(link, async () => {
+module.exports = (link) =>
+ cache.tryGet(link, async () => {
let content, author, exactDate;
try {
const result = await got(link);
diff --git a/lib/v2/sdu/extractor/view.js b/lib/v2/sdu/extractor/view.js
index e9393ac46..d0772e815 100644
--- a/lib/v2/sdu/extractor/view.js
+++ b/lib/v2/sdu/extractor/view.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-module.exports = (link, ctx) =>
- ctx.cache.tryGet(link, async () => {
+module.exports = (link) =>
+ cache.tryGet(link, async () => {
let content, author, exactDate;
try {
const result = await got(link);
diff --git a/lib/v2/sdu/extractor/wh/jwc.js b/lib/v2/sdu/extractor/wh/jwc.js
index 88083fb5d..c8b151053 100644
--- a/lib/v2/sdu/extractor/wh/jwc.js
+++ b/lib/v2/sdu/extractor/wh/jwc.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-module.exports = (link, ctx) =>
- ctx.cache.tryGet(link, async () => {
+module.exports = (link) =>
+ cache.tryGet(link, async () => {
let content, exactDate;
try {
const result = await got(link);
diff --git a/lib/v2/sdu/extractor/wh/news.js b/lib/v2/sdu/extractor/wh/news.js
index 63a0135be..4c8a3717e 100644
--- a/lib/v2/sdu/extractor/wh/news.js
+++ b/lib/v2/sdu/extractor/wh/news.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
-module.exports = (link, ctx) =>
- ctx.cache.tryGet(link, async () => {
+module.exports = (link) =>
+ cache.tryGet(link, async () => {
let content, author, exactDate;
try {
const result = await got(link);
diff --git a/lib/v2/sdu/mech.js b/lib/v2/sdu/mech.js
index c332e3967..a0ee0d5e3 100644
--- a/lib/v2/sdu/mech.js
+++ b/lib/v2/sdu/mech.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
if (isFromMech) {
item.link = new URL(item.link.slice('3'), host).href;
}
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/sdu/sc.js b/lib/v2/sdu/sc.js
index 69fac7b3c..2804164be 100644
--- a/lib/v2/sdu/sc.js
+++ b/lib/v2/sdu/sc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
item = await Promise.all(
item.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/sdu/wh/jwc.js b/lib/v2/sdu/wh/jwc.js
index e00c546ff..f744df42f 100644
--- a/lib/v2/sdu/wh/jwc.js
+++ b/lib/v2/sdu/wh/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const data = require('../data').wh.jwc;
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const href = anchor.attr('href');
const link = href.startsWith('http') ? href : baseUrl + href;
const title = item.text();
- const { description, author: exactAuthor, exactDate } = await ctx.cache.tryGet(link, () => extractor(link, ctx));
+ const { description, author: exactAuthor, exactDate } = await cache.tryGet(link, () => extractor(link, ctx));
const author = exactAuthor ?? '教务处';
const pubDate = exactDate ?? timezone(parseDate(dateText.slice(1, -1), 'YYYY-MM-DD'), +8);
return {
diff --git a/lib/v2/sdu/wh/news.js b/lib/v2/sdu/wh/news.js
index 93d8d64ee..4efa829d1 100644
--- a/lib/v2/sdu/wh/news.js
+++ b/lib/v2/sdu/wh/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const data = require('../data').wh.news;
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const title = anchor.attr('title');
const href = anchor.attr('href');
const link = href.startsWith('http') ? href : baseUrl + href;
- const { description, author, exactDate } = await ctx.cache.tryGet(link, () => extractor(link, ctx));
+ const { description, author, exactDate } = await cache.tryGet(link, () => extractor(link, ctx));
const span = item.find('span');
const pubDate = exactDate ?? parseDate(span.text(), 'YYYY/MM/DD');
return {
diff --git a/lib/v2/sdust/yjsy/zhaosheng.js b/lib/v2/sdust/yjsy/zhaosheng.js
index 1c52bb5b8..5ea92db35 100644
--- a/lib/v2/sdust/yjsy/zhaosheng.js
+++ b/lib/v2/sdust/yjsy/zhaosheng.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sdzk/index.js b/lib/v2/sdzk/index.js
index eaa52c32e..310ce5e2a 100644
--- a/lib/v2/sdzk/index.js
+++ b/lib/v2/sdzk/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/secrss/author.js b/lib/v2/secrss/author.js
index df9a8e95b..302c0debb 100644
--- a/lib/v2/secrss/author.js
+++ b/lib/v2/secrss/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
dataArray.map((item) => {
const itemUrl = `${host}${item.url}`;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const result = await got(itemUrl);
const $ = load(result.data);
const description = $('.article-body').html().trim();
diff --git a/lib/v2/secrss/category.js b/lib/v2/secrss/category.js
index 8e0982d57..0958930a1 100644
--- a/lib/v2/secrss/category.js
+++ b/lib/v2/secrss/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
dataArray.map((item) => {
const itemUrl = `${host}/articles/${item.id}`;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const result = await got(itemUrl);
const $ = load(result.data);
const description = $('.article-body').html().trim();
diff --git a/lib/v2/seekingalpha/index.js b/lib/v2/seekingalpha/index.js
index 1e5ec817c..0b1b3c150 100644
--- a/lib/v2/seekingalpha/index.js
+++ b/lib/v2/seekingalpha/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = list
? await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/segmentfault/blogs.js b/lib/v2/segmentfault/blogs.js
index 975b25119..5aadbdb4b 100644
--- a/lib/v2/segmentfault/blogs.js
+++ b/lib/v2/segmentfault/blogs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { host, acw_sc__v2, parseList, parseItems } = require('./utils');
@@ -9,9 +10,9 @@ module.exports = async (ctx) => {
const list = parseList(data);
- const acwScV2Cookie = await acw_sc__v2(list[0].link, ctx.cache.tryGet);
+ const acwScV2Cookie = await acw_sc__v2(list[0].link, cache.tryGet);
- const items = await Promise.all(list.map((item) => parseItems(acwScV2Cookie, item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItems(acwScV2Cookie, item, cache.tryGet)));
ctx.set('data', {
title: `segmentfault-Blogs-${tag}`,
diff --git a/lib/v2/segmentfault/channel.js b/lib/v2/segmentfault/channel.js
index 21e67bc42..ab2356cb7 100644
--- a/lib/v2/segmentfault/channel.js
+++ b/lib/v2/segmentfault/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { host, acw_sc__v2, parseList, parseItems } = require('./utils');
@@ -22,9 +23,9 @@ module.exports = async (ctx) => {
const list = parseList(apiResponse.rows);
- const acwScV2Cookie = await acw_sc__v2(list[0].link, ctx.cache.tryGet);
+ const acwScV2Cookie = await acw_sc__v2(list[0].link, cache.tryGet);
- const items = await Promise.all(list.map((item) => parseItems(acwScV2Cookie, item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItems(acwScV2Cookie, item, cache.tryGet)));
ctx.set('data', {
title: `segmentfault - ${channelName}`,
diff --git a/lib/v2/segmentfault/user.js b/lib/v2/segmentfault/user.js
index f645e0cac..9866b20c6 100644
--- a/lib/v2/segmentfault/user.js
+++ b/lib/v2/segmentfault/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { host, acw_sc__v2, parseList, parseItems } = require('./utils');
@@ -11,9 +12,9 @@ module.exports = async (ctx) => {
const list = parseList(data);
const { author } = list[0];
- const acwScV2Cookie = await acw_sc__v2(list[0].link, ctx.cache.tryGet);
+ const acwScV2Cookie = await acw_sc__v2(list[0].link, cache.tryGet);
- const items = await Promise.all(list.map((item) => parseItems(acwScV2Cookie, item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItems(acwScV2Cookie, item, cache.tryGet)));
ctx.set('data', {
title: `segmentfault - ${author}`,
diff --git a/lib/v2/sehuatang/index.js b/lib/v2/sehuatang/index.js
index b7dfdee72..3a08f7e36 100644
--- a/lib/v2/sehuatang/index.js
+++ b/lib/v2/sehuatang/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -71,7 +72,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((info) =>
- ctx.cache.tryGet(info.link, async () => {
+ cache.tryGet(info.link, async () => {
const response = await got(info.link, {
cookieJar,
headers,
diff --git a/lib/v2/sehuatang/user.js b/lib/v2/sehuatang/user.js
index 5bd151d6d..51f403cb5 100644
--- a/lib/v2/sehuatang/user.js
+++ b/lib/v2/sehuatang/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 导入必要的模组
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((info) =>
- ctx.cache.tryGet(info.link, async () => {
+ cache.tryGet(info.link, async () => {
const response = await got(info.link, {
headers: {
Cookie: config.sehuatang.cookie,
diff --git a/lib/v2/sensortower/blog.js b/lib/v2/sensortower/blog.js
index ddcb88b43..7256a66fd 100644
--- a/lib/v2/sensortower/blog.js
+++ b/lib/v2/sensortower/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/setn/index.js b/lib/v2/setn/index.js
index 13d7d4b04..0d08a56ef 100644
--- a/lib/v2/setn/index.js
+++ b/lib/v2/setn/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -72,7 +73,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/seu/cse/index.js b/lib/v2/seu/cse/index.js
index c66daf2fd..a4dee41cd 100644
--- a/lib/v2/seu/cse/index.js
+++ b/lib/v2/seu/cse/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let response;
try {
response = await got(item.link);
diff --git a/lib/v2/seu/radio/academic.js b/lib/v2/seu/radio/academic.js
index ccafeff0b..2e3f1e669 100644
--- a/lib/v2/seu/radio/academic.js
+++ b/lib/v2/seu/radio/academic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/seu/yjs.js b/lib/v2/seu/yjs.js
index 1862e5b94..665ad4b0d 100644
--- a/lib/v2/seu/yjs.js
+++ b/lib/v2/seu/yjs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('.wp_articlecontent').html();
diff --git a/lib/v2/seu/yzb/index.js b/lib/v2/seu/yzb/index.js
index 773243829..8558ba456 100644
--- a/lib/v2/seu/yzb/index.js
+++ b/lib/v2/seu/yzb/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/shcstheatre/programs.js b/lib/v2/shcstheatre/programs.js
index c33ad3796..b8efcace9 100644
--- a/lib/v2/shcstheatre/programs.js
+++ b/lib/v2/shcstheatre/programs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
$('#datarow .program-name a').map((_, elem) => {
const link = new URL($(elem).attr('href'), url);
- return ctx.cache.tryGet(link.toString(), async () => {
+ return cache.tryGet(link.toString(), async () => {
const id = link.searchParams.get('id');
const res2 = await got.post('https://www.shcstheatre.com/webapi.ashx?op=GettblprogramCache', {
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
diff --git a/lib/v2/shiep/index.js b/lib/v2/shiep/index.js
index 9850146da..655b2685d 100644
--- a/lib/v2/shiep/index.js
+++ b/lib/v2/shiep/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const dayjs = require('dayjs');
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/shisu/news.js b/lib/v2/shisu/news.js
index 78da8b50a..348cb7bc4 100644
--- a/lib/v2/shisu/news.js
+++ b/lib/v2/shisu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
}
const items = await Promise.all(
itemsoup.map((j) =>
- ctx.cache.tryGet(j.link, async () => {
+ cache.tryGet(j.link, async () => {
const { data: r } = await got(j.link);
const $ = load(r);
const img = $('.tempWrap > ul > li:nth-child(1)> img').attr('src');
diff --git a/lib/v2/shmeea/index.js b/lib/v2/shmeea/index.js
index 87aba2d6e..6f2a502e7 100644
--- a/lib/v2/shmeea/index.js
+++ b/lib/v2/shmeea/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.endsWith('.html') || new URL(item.link).hostname !== new URL(baseURL).hostname) {
return item;
}
diff --git a/lib/v2/shoac/recent-show.js b/lib/v2/shoac/recent-show.js
index 1e6893786..d72ea4e76 100644
--- a/lib/v2/shoac/recent-show.js
+++ b/lib/v2/shoac/recent-show.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const path = require('path');
import { art } from '@/utils/render';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detail } = await got(`${baseUrl}/platform-backend/good/project/detail/old/${item.projectId}`, {
headers,
searchParams: {
diff --git a/lib/v2/shoppingdesign/posts.js b/lib/v2/shoppingdesign/posts.js
index cd977c4d1..e42305c85 100644
--- a/lib/v2/shoppingdesign/posts.js
+++ b/lib/v2/shoppingdesign/posts.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
for await (const data of asyncPool(10, $('article-item'), (item) => {
item = $(item);
const link = item.attr('url');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response = await got(`${link}?sn_f=1`);
const $ = load(response.data);
const article = $('.left article .htmlview');
diff --git a/lib/v2/shu/index.js b/lib/v2/shu/index.js
index 1dd264a36..456bb7e89 100644
--- a/lib/v2/shu/index.js
+++ b/lib/v2/shu/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const all = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got.get(item.link);
const $ = load(response.data);
item.author = $('.xx>:nth-child(2)').text().trim().slice(3); // 投稿:xxx
diff --git a/lib/v2/shu/jwb.js b/lib/v2/shu/jwb.js
index 56ce30e0e..3f8e1b654 100644
--- a/lib/v2/shu/jwb.js
+++ b/lib/v2/shu/jwb.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const all = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got.get(item.link);
const $ = load(response.data);
item.author = $('[id$=_lblUser]').text().trim();
diff --git a/lib/v2/shuiguopai/index.js b/lib/v2/shuiguopai/index.js
index fd8a236ef..d98b22bfb 100644
--- a/lib/v2/shuiguopai/index.js
+++ b/lib/v2/shuiguopai/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sicau/dky.js b/lib/v2/sicau/dky.js
index 226fd6452..a3e119104 100644
--- a/lib/v2/sicau/dky.js
+++ b/lib/v2/sicau/dky.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sicau/yan.js b/lib/v2/sicau/yan.js
index ab0d4449e..7b1d16f2b 100644
--- a/lib/v2/sicau/yan.js
+++ b/lib/v2/sicau/yan.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sicau/zsjy.js b/lib/v2/sicau/zsjy.js
index d0c0ea335..d5252c650 100644
--- a/lib/v2/sicau/zsjy.js
+++ b/lib/v2/sicau/zsjy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/simpleinfo/index.js b/lib/v2/simpleinfo/index.js
index b129527b5..167b5cafb 100644
--- a/lib/v2/simpleinfo/index.js
+++ b/lib/v2/simpleinfo/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const result = await got(item.link);
const content = load(result.data);
item.author = content('meta[property="article:author"]').attr('content');
diff --git a/lib/v2/sina/chuangshiji.js b/lib/v2/sina/chuangshiji.js
index d15ab4aa7..b57b6dcb4 100644
--- a/lib/v2/sina/chuangshiji.js
+++ b/lib/v2/sina/chuangshiji.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getRollNewsList, parseRollNewsList, parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const response = await getRollNewsList(pageid, lid, limit);
const list = parseRollNewsList(response.data.result.data);
- const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: '新浪专栏-创事记',
diff --git a/lib/v2/sina/discovery.js b/lib/v2/sina/discovery.js
index 2c5066d5d..2217b5a78 100644
--- a/lib/v2/sina/discovery.js
+++ b/lib/v2/sina/discovery.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getRollNewsList, parseRollNewsList, parseArticle } = require('./utils');
const link = 'https://tech.sina.com.cn/discovery/';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const response = await getRollNewsList(pageid, lid, limit);
const list = parseRollNewsList(response.data.result.data);
- const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `${title}-新浪科技科学探索`,
diff --git a/lib/v2/sina/finance/china.js b/lib/v2/sina/finance/china.js
index 906bf0bfb..df11310c8 100644
--- a/lib/v2/sina/finance/china.js
+++ b/lib/v2/sina/finance/china.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getRollNewsList, parseRollNewsList, parseArticle } = require('../utils');
module.exports = async (ctx) => {
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
const response = await getRollNewsList(pageid, lid, limit);
const list = parseRollNewsList(response.data.result.data);
- const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `新浪财经-${map[lid]}`,
diff --git a/lib/v2/sina/finance/stock/usstock.js b/lib/v2/sina/finance/stock/usstock.js
index 86f34207c..2e75d10b3 100644
--- a/lib/v2/sina/finance/stock/usstock.js
+++ b/lib/v2/sina/finance/stock/usstock.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { parseArticle } = require('../../utils');
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
author: item.media,
}));
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: '美股|美股行情|美股新闻 - 新浪财经',
diff --git a/lib/v2/sina/rollnews.js b/lib/v2/sina/rollnews.js
index ac8b81f47..55ee2eae2 100644
--- a/lib/v2/sina/rollnews.js
+++ b/lib/v2/sina/rollnews.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getRollNewsList, parseRollNewsList, parseArticle } = require('./utils');
module.exports = async (ctx) => {
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const response = await getRollNewsList(pageid, lid, limit);
const list = parseRollNewsList(response.data.result.data);
- const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const out = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `新浪${map[lid]}滚动新闻`,
diff --git a/lib/v2/sina/sports.js b/lib/v2/sina/sports.js
index a4237e10c..b51e91ca5 100644
--- a/lib/v2/sina/sports.js
+++ b/lib/v2/sina/sports.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseArticle } = require('./utils');
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `${$('title').text().split('_')[0]} - 新浪体育`,
diff --git a/lib/v2/sinchew/index.js b/lib/v2/sinchew/index.js
index 2869b09f6..51ee41444 100644
--- a/lib/v2/sinchew/index.js
+++ b/lib/v2/sinchew/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sis001/forum.js b/lib/v2/sis001/forum.js
index 5be80938c..14d348663 100644
--- a/lib/v2/sis001/forum.js
+++ b/lib/v2/sis001/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/sjtu/gs.js b/lib/v2/sjtu/gs.js
index 74fabccae..f08a04c98 100644
--- a/lib/v2/sjtu/gs.js
+++ b/lib/v2/sjtu/gs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (new URL(item.link).hostname === 'mp.weixin.qq.com') {
item.description = (await fetchArticle(item.link)).description;
} else {
diff --git a/lib/v2/sjtu/jwc.js b/lib/v2/sjtu/jwc.js
index 3861d12e6..d7599148d 100644
--- a/lib/v2/sjtu/jwc.js
+++ b/lib/v2/sjtu/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -96,7 +97,7 @@ module.exports = async (ctx) => {
const day = timeElement.find('h2').text();
const yearAndMonth = timeElement.find('p').text();
const pubDate = parseDate(`${yearAndMonth}.${day}`, 'YYYY.MM.DD');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const description = await getFullArticle(link);
return {
title,
diff --git a/lib/v2/sjtu/seiee/utils.js b/lib/v2/sjtu/seiee/utils.js
index 35808c52a..32eb00ed0 100644
--- a/lib/v2/sjtu/seiee/utils.js
+++ b/lib/v2/sjtu/seiee/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -16,7 +17,7 @@ module.exports = function (meta, extract) {
const out = await Promise.all(
list.map((item) => {
const itemUrl = new URL(item.link, host).href;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const response = await got(itemUrl);
const $ = load(response.data);
diff --git a/lib/v2/skysports/news.js b/lib/v2/skysports/news.js
index 93a32ae0a..b881ab704 100644
--- a/lib/v2/skysports/news.js
+++ b/lib/v2/skysports/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/smashingmagazine/category.js b/lib/v2/smashingmagazine/category.js
index 260af7b5d..44692451c 100644
--- a/lib/v2/smashingmagazine/category.js
+++ b/lib/v2/smashingmagazine/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
listItems.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.category = $('li.meta-box--tags a')
diff --git a/lib/v2/smzdm/article.js b/lib/v2/smzdm/article.js
index ce3e72e50..c44532a20 100644
--- a/lib/v2/smzdm/article.js
+++ b/lib/v2/smzdm/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('.m-contant article').html();
diff --git a/lib/v2/smzdm/baoliao.js b/lib/v2/smzdm/baoliao.js
index 0b11579f5..171b49a70 100644
--- a/lib/v2/smzdm/baoliao.js
+++ b/lib/v2/smzdm/baoliao.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('article.txt-detail').html();
diff --git a/lib/v2/smzdm/haowen-fenlei.js b/lib/v2/smzdm/haowen-fenlei.js
index 9e0176487..f8727ef64 100644
--- a/lib/v2/smzdm/haowen-fenlei.js
+++ b/lib/v2/smzdm/haowen-fenlei.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/smzdm/haowen.js b/lib/v2/smzdm/haowen.js
index 83b9610da..27b9774a9 100644
--- a/lib/v2/smzdm/haowen.js
+++ b/lib/v2/smzdm/haowen.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
const content = $('#articleId');
diff --git a/lib/v2/sobooks/utils.js b/lib/v2/sobooks/utils.js
index 04c8202e6..aae919a90 100644
--- a/lib/v2/sobooks/utils.js
+++ b/lib/v2/sobooks/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx, currentUrl) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sogou/search.js b/lib/v2/sogou/search.js
index c38a81379..10cb1998b 100644
--- a/lib/v2/sogou/search.js
+++ b/lib/v2/sogou/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const { keyword } = ctx.params;
const url = `https://www.sogou.com/web?query=${encodeURIComponent(keyword)}`;
const key = `sogou-search:${url}`;
- const items = await ctx.cache.tryGet(
+ const items = await cache.tryGet(
key,
async () => {
const response = (await got(url)).data;
diff --git a/lib/v2/sohu/mp.js b/lib/v2/sohu/mp.js
index 58342fa01..2fc8c886b 100644
--- a/lib/v2/sohu/mp.js
+++ b/lib/v2/sohu/mp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((e) =>
- ctx.cache.tryGet(e.link, async () => {
+ cache.tryGet(e.link, async () => {
const { data: response } = await got(e.link);
const $ = load(response);
diff --git a/lib/v2/solidot/main.js b/lib/v2/solidot/main.js
index bc6f9f259..c1d94765f 100644
--- a/lib/v2/solidot/main.js
+++ b/lib/v2/solidot/main.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// Warning: The author still knows nothing about javascript!
// params:
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
}
// get articles
- const msg_list = await Promise.all(urls.map((u) => ctx.cache.tryGet(u, () => get_article(u))));
+ const msg_list = await Promise.all(urls.map((u) => cache.tryGet(u, () => get_article(u))));
// feed the data
ctx.set('data', {
diff --git a/lib/v2/soundofhope/channel.js b/lib/v2/soundofhope/channel.js
index 61b05771a..83abc79fc 100644
--- a/lib/v2/soundofhope/channel.js
+++ b/lib/v2/soundofhope/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/southcn/nfapp/column.js b/lib/v2/southcn/nfapp/column.js
index a5f8c2351..dc637854e 100644
--- a/lib/v2/southcn/nfapp/column.js
+++ b/lib/v2/southcn/nfapp/column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
shareUrl: item.shareUrl,
}));
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: columnName,
diff --git a/lib/v2/southcn/nfapp/reporter.js b/lib/v2/southcn/nfapp/reporter.js
index 5e8b91e96..9faf3bd2e 100644
--- a/lib/v2/southcn/nfapp/reporter.js
+++ b/lib/v2/southcn/nfapp/reporter.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
shareUrl: item.shareUrl,
}));
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `南方+ - ${response.data.reportInfo.reporterName}`,
diff --git a/lib/v2/springer/journal.js b/lib/v2/springer/journal.js
index a3d9ea7d8..8c541349b 100644
--- a/lib/v2/springer/journal.js
+++ b/lib/v2/springer/journal.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const path = require('path');
@@ -52,7 +53,7 @@ module.exports = async (ctx) => {
});
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response3 = await got(item.link, {
cookieJar,
});
diff --git a/lib/v2/sputniknews/index.js b/lib/v2/sputniknews/index.js
index 7356da49d..34cb50993 100644
--- a/lib/v2/sputniknews/index.js
+++ b/lib/v2/sputniknews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -62,7 +63,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/sqmc/www.js b/lib/v2/sqmc/www.js
index 026dcc895..d57015dd7 100644
--- a/lib/v2/sqmc/www.js
+++ b/lib/v2/sqmc/www.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const link = new URL(item.find('dt a').attr('href'), rootUrl).href;
const pubDate = parseDate(item.find('dd').eq(0).text(), 'YYYY-MM-DD');
- const cache = await ctx.cache.tryGet(link, async () => {
+ const cacheIn = await cache.tryGet(link, async () => {
const detailResponse = await got({
method: 'get',
url: link,
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
};
});
- return cache;
+ return cacheIn;
})
),
});
diff --git a/lib/v2/sse/lawandrules.js b/lib/v2/sse/lawandrules.js
index 63ec096fe..fffc79433 100644
--- a/lib/v2/sse/lawandrules.js
+++ b/lib/v2/sse/lawandrules.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/sspai/author.js b/lib/v2/sspai/author.js
index 2ec642847..00a9d4d87 100644
--- a/lib/v2/sspai/author.js
+++ b/lib/v2/sspai/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
let description = '';
const key = `sspai: ${item.id}`;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const response = await got(link);
description = response.data.data.body;
diff --git a/lib/v2/sspai/column.js b/lib/v2/sspai/column.js
index 33920acf7..5f8ecb356 100644
--- a/lib/v2/sspai/column.js
+++ b/lib/v2/sspai/column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const itemUrl = `https://sspai.com/post/${item.id}`;
const author = item.author.nickname;
- return ctx.cache.tryGet(`sspai: ${item.id}`, async () => {
+ return cache.tryGet(`sspai: ${item.id}`, async () => {
const response = await got(link);
const description = response.data.data.body;
diff --git a/lib/v2/sspai/index.js b/lib/v2/sspai/index.js
index dac106627..aa3b9e01d 100644
--- a/lib/v2/sspai/index.js
+++ b/lib/v2/sspai/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
let description = '';
const key = `sspai: ${item.id}`;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const response = await got({ method: 'get', url: link });
description = response.data.data.body;
diff --git a/lib/v2/sspai/matrix.js b/lib/v2/sspai/matrix.js
index e0a376eeb..742e8b4b0 100644
--- a/lib/v2/sspai/matrix.js
+++ b/lib/v2/sspai/matrix.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
let description = '';
const key = `sspai: ${item.id}`;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const response = await got(link);
description = response.data.data.body;
diff --git a/lib/v2/sspai/series.js b/lib/v2/sspai/series.js
index c6db68c5a..abe6adfcf 100644
--- a/lib/v2/sspai/series.js
+++ b/lib/v2/sspai/series.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
products.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(`https://sspai.com/api/v1/series/info/get?id=${item.id}&view=second`);
const banner = `
`;
const description = banner + res.data.data.intro;
diff --git a/lib/v2/sspai/tag.js b/lib/v2/sspai/tag.js
index b7188aaa7..8a15d7133 100644
--- a/lib/v2/sspai/tag.js
+++ b/lib/v2/sspai/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const link = `https://sspai.com/api/v1/article/info/get?id=${item.id}&view=second`;
let description;
const key = `sspai: ${item.id}`;
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
const response = await got({ method: 'get', url: link, headers: { Referer: host } });
description = response.data.data.body;
diff --git a/lib/v2/sspai/topic.js b/lib/v2/sspai/topic.js
index 81b10fda7..a724cb8c6 100644
--- a/lib/v2/sspai/topic.js
+++ b/lib/v2/sspai/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
topic_link = `https://sspai.com/topic/${id}`;
topic_des = item.topics[0].intro;
}
- return ctx.cache.tryGet(`sspai: ${item.id}`, async () => {
+ return cache.tryGet(`sspai: ${item.id}`, async () => {
const response = await got(link);
const description = response.data.data.body;
diff --git a/lib/v2/sspai/topics.js b/lib/v2/sspai/topics.js
index d2436e4f1..77e2cd571 100644
--- a/lib/v2/sspai/topics.js
+++ b/lib/v2/sspai/topics.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
let description = '';
const key = `sspai:topics:${item.id}`;
- return ctx.cache.tryGet(key, () => {
+ return cache.tryGet(key, () => {
description = `${item.intro}

如有兴趣,请复制链接订阅
https://rsshub.app/sspai/topic/${item.id}
`;
return {
diff --git a/lib/v2/sspu/jwc.js b/lib/v2/sspu/jwc.js
index 2593e18f9..904f8bda8 100644
--- a/lib/v2/sspu/jwc.js
+++ b/lib/v2/sspu/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/sspu/pe.js b/lib/v2/sspu/pe.js
index 79ca12cc0..f3f0ab404 100644
--- a/lib/v2/sspu/pe.js
+++ b/lib/v2/sspu/pe.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.endsWith('htm')) {
const { data: detailResponse } = await got(item.link);
diff --git a/lib/v2/startuplatte/index.js b/lib/v2/startuplatte/index.js
index 8b74954ec..af9ddf4b5 100644
--- a/lib/v2/startuplatte/index.js
+++ b/lib/v2/startuplatte/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/stbu/jsjxy.js b/lib/v2/stbu/jsjxy.js
index 17c209d50..5aa1e945f 100644
--- a/lib/v2/stbu/jsjxy.js
+++ b/lib/v2/stbu/jsjxy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
responseType: 'buffer',
https: {
diff --git a/lib/v2/stbu/xyxw.js b/lib/v2/stbu/xyxw.js
index 4f98c0d35..e51c2dc51 100644
--- a/lib/v2/stbu/xyxw.js
+++ b/lib/v2/stbu/xyxw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
responseType: 'buffer',
https: {
diff --git a/lib/v2/stcn/index.js b/lib/v2/stcn/index.js
index a695a9987..b903f0b84 100644
--- a/lib/v2/stcn/index.js
+++ b/lib/v2/stcn/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (/\.html$/.test(item.link)) {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/stheadline/std/realtime.js b/lib/v2/stheadline/std/realtime.js
index b856b6d98..694be10ba 100644
--- a/lib/v2/stheadline/std/realtime.js
+++ b/lib/v2/stheadline/std/realtime.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/stockedge/daily-news.js b/lib/v2/stockedge/daily-news.js
index d8aa6ddc0..aaac0c549 100644
--- a/lib/v2/stockedge/daily-news.js
+++ b/lib/v2/stockedge/daily-news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getData, getList } = require('./utils');
module.exports = async (ctx) => {
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const list = getList(data);
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const info = await getData(`${apiInfo}/${item.securityID}`);
item.description = item.description + '
' + info?.AboutCompanyText;
return item;
diff --git a/lib/v2/storm/index.js b/lib/v2/storm/index.js
index fce165bf0..8b2965d1d 100644
--- a/lib/v2/storm/index.js
+++ b/lib/v2/storm/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/storyfm/episodes.js b/lib/v2/storyfm/episodes.js
index d8e31b7de..a6b1c93d3 100644
--- a/lib/v2/storyfm/episodes.js
+++ b/lib/v2/storyfm/episodes.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/studygolang/utils.js b/lib/v2/studygolang/utils.js
index ba47d8fc1..4c21e75cc 100644
--- a/lib/v2/studygolang/utils.js
+++ b/lib/v2/studygolang/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/subhd/index.js b/lib/v2/subhd/index.js
index b4adab465..56d23ce81 100644
--- a/lib/v2/subhd/index.js
+++ b/lib/v2/subhd/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/supchina/index.js b/lib/v2/supchina/index.js
index 8eb0dfc9f..e96eaeb75 100644
--- a/lib/v2/supchina/index.js
+++ b/lib/v2/supchina/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/supchina/podcasts.js b/lib/v2/supchina/podcasts.js
index 5fb8b7698..cb3ef67c7 100644
--- a/lib/v2/supchina/podcasts.js
+++ b/lib/v2/supchina/podcasts.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/surfshark/blog.js b/lib/v2/surfshark/blog.js
index 92d478718..ed6589025 100644
--- a/lib/v2/surfshark/blog.js
+++ b/lib/v2/surfshark/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/swissinfo/index.js b/lib/v2/swissinfo/index.js
index f0a04b8d2..a98ac5343 100644
--- a/lib/v2/swissinfo/index.js
+++ b/lib/v2/swissinfo/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/swpu/bgw.js b/lib/v2/swpu/bgw.js
index 86c16d822..8ea6672fa 100644
--- a/lib/v2/swpu/bgw.js
+++ b/lib/v2/swpu/bgw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { joinUrl } = require('./utils');
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
// 请求全文
const out = await Promise.all(
items.map(async (item) => {
- const $ = await ctx.cache.tryGet(item.link, async () => {
+ const $ = await cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
return load(res.data);
});
diff --git a/lib/v2/swpu/cjxy.js b/lib/v2/swpu/cjxy.js
index afe1a75f2..389a24728 100644
--- a/lib/v2/swpu/cjxy.js
+++ b/lib/v2/swpu/cjxy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link);
const $ = load(res.data);
if ($('title').text().startsWith('系统提示')) {
diff --git a/lib/v2/swpu/dean.js b/lib/v2/swpu/dean.js
index 56de26c3c..55768e37a 100644
--- a/lib/v2/swpu/dean.js
+++ b/lib/v2/swpu/dean.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { joinUrl } = require('./utils');
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
// 请求全文
const out = await Promise.all(
items.map(async (item) => {
- const $ = await ctx.cache.tryGet(item.link, async () => {
+ const $ = await cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
return load(res.data);
});
diff --git a/lib/v2/swpu/dxy.js b/lib/v2/swpu/dxy.js
index 20b72e739..f0fde8fa0 100644
--- a/lib/v2/swpu/dxy.js
+++ b/lib/v2/swpu/dxy.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { joinUrl } = require('./utils');
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
// 请求全文
const out = await Promise.all(
items.map(async (item) => {
- const $ = await ctx.cache.tryGet(item.link, async () => {
+ const $ = await cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
return load(res.data);
});
diff --git a/lib/v2/swpu/is.js b/lib/v2/swpu/is.js
index 219b22edb..ce9f8e3d8 100644
--- a/lib/v2/swpu/is.js
+++ b/lib/v2/swpu/is.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link);
const $ = load(res.data);
if ($('title').text().startsWith('系统提示')) {
diff --git a/lib/v2/swpu/scs.js b/lib/v2/swpu/scs.js
index 41643a4fb..5eb509774 100644
--- a/lib/v2/swpu/scs.js
+++ b/lib/v2/swpu/scs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { joinUrl } = require('./utils');
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
// 请求全文
const out = await Promise.all(
items.map(async (item) => {
- const $ = await ctx.cache.tryGet(item.link, async () => {
+ const $ = await cache.tryGet(item.link, async () => {
const res = await got.get(item.link);
return load(res.data);
});
diff --git a/lib/v2/syosetu/chapter.js b/lib/v2/syosetu/chapter.js
index 4e45d8142..8dfbb13f8 100644
--- a/lib/v2/syosetu/chapter.js
+++ b/lib/v2/syosetu/chapter.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const item_list = await Promise.all(
chapter_list.map((chapter) =>
- ctx.cache.tryGet(chapter.link, async () => {
+ cache.tryGet(chapter.link, async () => {
chapter.link = `https://ncode.syosetu.com${chapter.link}`;
const content = load(await get(chapter.link));
chapter.description = content('#novel_honbun').html();
diff --git a/lib/v2/sysu/ygafz.js b/lib/v2/sysu/ygafz.js
index f158865f7..1d77655f3 100644
--- a/lib/v2/sysu/ygafz.js
+++ b/lib/v2/sysu/ygafz.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -47,7 +48,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link, {
cookieJar,
});
diff --git a/lib/v2/szse/notice.js b/lib/v2/szse/notice.js
index 547dd26b6..230781fbb 100644
--- a/lib/v2/szse/notice.js
+++ b/lib/v2/szse/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = require('url');
@@ -44,9 +45,9 @@ module.exports = async (ctx) => {
const title = info.title;
const date = info.date;
const itemUrl = url.resolve(host, info.link);
- const cache = await ctx.cache.get(itemUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(itemUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got.get(itemUrl, {
Referer: host,
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
description,
pubDate: new Date(date).toDateString(),
};
- ctx.cache.set(itemUrl, JSON.stringify(single));
+ cache.set(itemUrl, JSON.stringify(single));
return single;
})
);
diff --git a/lib/v2/szse/projectdynamic.js b/lib/v2/szse/projectdynamic.js
index 826bafa14..77c57e680 100644
--- a/lib/v2/szse/projectdynamic.js
+++ b/lib/v2/szse/projectdynamic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -58,7 +59,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/szse/rule.js b/lib/v2/szse/rule.js
index c9d92f12e..97cdfa9d0 100644
--- a/lib/v2/szse/rule.js
+++ b/lib/v2/szse/rule.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/taiwannews/hot.js b/lib/v2/taiwannews/hot.js
index c4f3c3893..4d2e90f90 100644
--- a/lib/v2/taiwannews/hot.js
+++ b/lib/v2/taiwannews/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/tangshufang/index.js b/lib/v2/tangshufang/index.js
index 2d3125294..7723944cb 100644
--- a/lib/v2/tangshufang/index.js
+++ b/lib/v2/tangshufang/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/taoguba/blog.js b/lib/v2/taoguba/blog.js
index bfc7a70da..c0cfc1b8f 100644
--- a/lib/v2/taoguba/blog.js
+++ b/lib/v2/taoguba/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/taoguba/index.js b/lib/v2/taoguba/index.js
index d824b4fe1..ca5aa6f21 100644
--- a/lib/v2/taoguba/index.js
+++ b/lib/v2/taoguba/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/taptap/topic.js b/lib/v2/taptap/topic.js
index e693266c3..1f6cbb064 100644
--- a/lib/v2/taptap/topic.js
+++ b/lib/v2/taptap/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { getRootUrl, X_UA, appDetail, imagePost, topicPost, videoPost } = require('./utils');
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
topics_list.data.list.map((list) => {
const link = list.moment.sharing?.url || list.moment.extended_entities?.topics?.[0].sharing.url || list.moment.extended_entities?.videos?.[0].sharing.url;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const author = list.moment.author.user.name;
const topicId = list.moment.extended_entities?.topics?.[0].id;
// raw_text sometimes is "" so || is better than ??
diff --git a/lib/v2/tass/news.js b/lib/v2/tass/news.js
index 1a27a18c9..70ba025d4 100644
--- a/lib/v2/tass/news.js
+++ b/lib/v2/tass/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/techcrunch/news.js b/lib/v2/techcrunch/news.js
index 2a37bcc3f..86f4aaec3 100644
--- a/lib/v2/techcrunch/news.js
+++ b/lib/v2/techcrunch/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const parser = require('@/utils/rss-parser');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const feed = await parser.parseURL(rssUrl);
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const url = item.link;
const response = await got({
url,
diff --git a/lib/v2/techpowerup/index.js b/lib/v2/techpowerup/index.js
index d980723a8..a8833a2a6 100644
--- a/lib/v2/techpowerup/index.js
+++ b/lib/v2/techpowerup/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
headers,
});
diff --git a/lib/v2/techpowerup/review.js b/lib/v2/techpowerup/review.js
index 29394c73e..b49b298f0 100644
--- a/lib/v2/techpowerup/review.js
+++ b/lib/v2/techpowerup/review.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link, {
headers,
});
diff --git a/lib/v2/telecompaper/news.js b/lib/v2/telecompaper/news.js
index 7ef20c9c1..fd17a19f0 100644
--- a/lib/v2/telecompaper/news.js
+++ b/lib/v2/telecompaper/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const tough = require('tough-cookie');
@@ -79,7 +80,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/telecompaper/search.js b/lib/v2/telecompaper/search.js
index 62d612a04..ac4935304 100644
--- a/lib/v2/telecompaper/search.js
+++ b/lib/v2/telecompaper/search.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -54,7 +55,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/telegram/blog.js b/lib/v2/telegram/blog.js
index 69e7efb73..9cc949a70 100644
--- a/lib/v2/telegram/blog.js
+++ b/lib/v2/telegram/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const cherrio = require('cheerio');
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
.map((each) => {
const $ = $$(each);
const link = 'https://telegram.org' + $.attr('href');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const result = await got(link);
const $ = cherrio.load(result.body);
return {
diff --git a/lib/v2/telegram/channel.js b/lib/v2/telegram/channel.js
index ab9ed18a7..d4aff24bf 100644
--- a/lib/v2/telegram/channel.js
+++ b/lib/v2/telegram/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -84,7 +85,7 @@ module.exports = async (ctx) => {
const resourceUrl = searchQuery ? `https://t.me/s/${username}?q=${encodeURIComponent(searchQuery)}` : `https://t.me/s/${username}`;
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
resourceUrl,
async () => {
const _r = await got(resourceUrl);
diff --git a/lib/v2/tencent/news/author.js b/lib/v2/tencent/news/author.js
index 7ae74a2b8..f48e6f478 100644
--- a/lib/v2/tencent/news/author.js
+++ b/lib/v2/tencent/news/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -8,13 +9,13 @@ const path = require('path');
module.exports = async (ctx) => {
const mid = ctx.req.param('mid');
const homePageInfoUrl = `https://i.news.qq.com/i/getUserHomepageInfo?chlid=${mid}`;
- const userInfo = await ctx.cache.tryGet(homePageInfoUrl, async () => (await got(homePageInfoUrl)).data.userinfo);
+ const userInfo = await cache.tryGet(homePageInfoUrl, async () => (await got(homePageInfoUrl)).data.userinfo);
const title = userInfo.nick;
const description = userInfo.user_desc;
const suid = encodeURIComponent(userInfo.suid);
const newsListUrl = `https://i.news.qq.com/getSubNewsMixedList?guestSuid=${suid}&tabId=om_index`;
- const news = await ctx.cache.tryGet(newsListUrl, async () => (await got(newsListUrl)).data.newslist, config.cache.routeExpire, false);
+ const news = await cache.tryGet(newsListUrl, async () => (await got(newsListUrl)).data.newslist, config.cache.routeExpire, false);
const items = await Promise.all(
news.map((item) => {
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
author,
pubDate,
}
- : ctx.cache.tryGet(itemUrl, async () => {
+ : cache.tryGet(itemUrl, async () => {
const response = await got(itemUrl);
const $ = load(response.data);
const data = JSON.parse(
diff --git a/lib/v2/tesla/cx.js b/lib/v2/tesla/cx.js
index ff9870133..853a361c6 100644
--- a/lib/v2/tesla/cx.js
+++ b/lib/v2/tesla/cx.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -67,7 +68,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.parkingLocationId) {
item.guid = `tesla-user-right#${item.guid}`;
diff --git a/lib/v2/tfc-taiwan/index.js b/lib/v2/tfc-taiwan/index.js
index 186897746..dce45d6bd 100644
--- a/lib/v2/tfc-taiwan/index.js
+++ b/lib/v2/tfc-taiwan/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseList, parseItems } = require('./utils');
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
.toArray()
.map((item) => parseList($(item)));
- const items = await parseItems(list, ctx.cache.tryGet);
+ const items = await parseItems(list, cache.tryGet);
ctx.set('data', {
title: $('head title').text(),
diff --git a/lib/v2/theatlantic/utils.js b/lib/v2/theatlantic/utils.js
index dfdc9960a..cef49a78f 100644
--- a/lib/v2/theatlantic/utils.js
+++ b/lib/v2/theatlantic/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -7,10 +8,10 @@ import randUserAgent from '@/utils/rand-user-agent';
const UA = randUserAgent({ browser: 'chrome', os: 'android', device: 'mobile' });
-const getArticleDetails = async (items, ctx) => {
+const getArticleDetails = async (items) => {
const list = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const url = item.link;
const response = await got({
url,
diff --git a/lib/v2/theblockbeats/index.js b/lib/v2/theblockbeats/index.js
index f274549c8..812918912 100644
--- a/lib/v2/theblockbeats/index.js
+++ b/lib/v2/theblockbeats/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
if (channel !== 'newsflash') {
list = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
item.description = $('div.news-content').html();
diff --git a/lib/v2/thecatcity/index.js b/lib/v2/thecatcity/index.js
index 1e302cab3..6257e6cf7 100644
--- a/lib/v2/thecatcity/index.js
+++ b/lib/v2/thecatcity/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { termsMap } = require('./terms-map');
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.guid, async () => {
+ cache.tryGet(item.guid, async () => {
const { data } = await got(item.api, {
searchParams: {
pageId: 977_080_509_047_743,
diff --git a/lib/v2/thecover/channel.js b/lib/v2/thecover/channel.js
index 8dbff82d9..a0975eccc 100644
--- a/lib/v2/thecover/channel.js
+++ b/lib/v2/thecover/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/thehindu/topic.js b/lib/v2/thehindu/topic.js
index 3ef97f104..5d8a95183 100644
--- a/lib/v2/thehindu/topic.js
+++ b/lib/v2/thehindu/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/theinitium/full.js b/lib/v2/theinitium/full.js
index c4dd500c1..03e4d9b72 100644
--- a/lib/v2/theinitium/full.js
+++ b/lib/v2/theinitium/full.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { load } from 'cheerio';
@@ -39,12 +40,12 @@ module.exports = async (ctx) => {
const body = JSON.stringify(key);
let token;
- const cache = await ctx.cache.get('initium:token');
- if (cache) {
- token = cache;
+ const cacheIn = await cache.get('initium:token');
+ if (cacheIn) {
+ token = cacheIn;
} else if (config.initium.bearertoken) {
token = config.initium.bearertoken;
- ctx.cache.set('initium:token', config.initium.bearertoken);
+ cache.set('initium:token', config.initium.bearertoken);
} else if (key.email === undefined) {
token = TOKEN;
} else {
@@ -73,7 +74,7 @@ module.exports = async (ctx) => {
}
*/
token = 'Bearer ' + login.data.token;
- ctx.cache.set('initium:token', token);
+ cache.set('initium:token', token);
}
const headers = {
@@ -94,7 +95,7 @@ module.exports = async (ctx) => {
const image = response.data[model] && (response.data[model].cover || response.data[model].avatar);
const getFullText = (slug) =>
- ctx.cache.tryGet(`theinitium:${slug}:${language}`, async () => {
+ cache.tryGet(`theinitium:${slug}:${language}`, async () => {
let content = '';
const { data } = await got(`https://api.theinitium.com/api/v2/article/detail/?language=${language}&slug=${slug}`, {
headers,
diff --git a/lib/v2/thenewslens/index.js b/lib/v2/thenewslens/index.js
index dcb340d6e..894669afc 100644
--- a/lib/v2/thenewslens/index.js
+++ b/lib/v2/thenewslens/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/thepaper/factpaper.js b/lib/v2/thepaper/factpaper.js
index f35fface5..df0e91698 100644
--- a/lib/v2/thepaper/factpaper.js
+++ b/lib/v2/thepaper/factpaper.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: `${apiRootUrl}/fact-check/front/proveInfo`,
diff --git a/lib/v2/thepaper/utils.js b/lib/v2/thepaper/utils.js
index 91fa97374..b489fadfc 100644
--- a/lib/v2/thepaper/utils.js
+++ b/lib/v2/thepaper/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import got from '@/utils/got';
@@ -24,7 +25,7 @@ module.exports = {
return defaultRssItem(item);
}
const itemUrl = `https://m.thepaper.cn/detail/${item.contId}`;
- return ctx.cache.tryGet(`${itemUrl}${useOldMode ? ':old' : ''}`, async () => {
+ return cache.tryGet(`${itemUrl}${useOldMode ? ':old' : ''}`, async () => {
const res = await got(itemUrl);
const data = JSON.parse(load(res.data)('#__NEXT_DATA__').html());
const detailData = data.props.pageProps.detailData;
diff --git a/lib/v2/theverge/index.js b/lib/v2/theverge/index.js
index 1b1bee3f8..ec594bdf0 100644
--- a/lib/v2/theverge/index.js
+++ b/lib/v2/theverge/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/thoughtco/index.js b/lib/v2/thoughtco/index.js
index 64596d8cb..c468decf9 100644
--- a/lib/v2/thoughtco/index.js
+++ b/lib/v2/thoughtco/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/tiktok/user.js b/lib/v2/tiktok/user.js
index 4f86674ea..bd57c7ebd 100644
--- a/lib/v2/tiktok/user.js
+++ b/lib/v2/tiktok/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { config } from '@/config';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const { user, iframe } = ctx.params;
const useIframe = queryToBoolean(iframe);
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`tiktok:user:${user}`,
async () => {
const browser = puppeteer();
diff --git a/lib/v2/timednews/news.js b/lib/v2/timednews/news.js
index 509055f5a..17563cf74 100644
--- a/lib/v2/timednews/news.js
+++ b/lib/v2/timednews/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -73,7 +74,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/tingtingfm/program.js b/lib/v2/tingtingfm/program.js
index c1b2a1025..5dcca5bad 100644
--- a/lib/v2/tingtingfm/program.js
+++ b/lib/v2/tingtingfm/program.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { art } from '@/utils/render';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
h_program_id: programId,
};
- const radioInfo = await ctx.cache.tryGet(`tingtingfm:program:${programId}`, async () => {
+ const radioInfo = await cache.tryGet(`tingtingfm:program:${programId}`, async () => {
// the double slash here and below is not a typo
const { data: response } = await got.post(`${apiBaseUrl}//broadcast/get_program_v3_8`, {
searchParams: {
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
return response.data.info;
});
- const latestAudio = await ctx.cache.tryGet(
+ const latestAudio = await cache.tryGet(
`tingtingfm:audio_list:${programId}`,
async () => {
const { data: response } = await got.post(`${apiBaseUrl}//broadcast/get_program_audio_list`, {
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
false
);
- const audioList = await ctx.cache.tryGet(
+ const audioList = await cache.tryGet(
`tingtingfm:play_audio:${programId}`,
async () => {
const playAudioParams = {
diff --git a/lib/v2/tisi/index.js b/lib/v2/tisi/index.js
index 6f84dc951..7943d1872 100644
--- a/lib/v2/tisi/index.js
+++ b/lib/v2/tisi/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
item.description = content('div.article-content').html();
diff --git a/lib/v2/tju/cic/index.js b/lib/v2/tju/cic/index.js
index 027edf3c2..745a8d067 100644
--- a/lib/v2/tju/cic/index.js
+++ b/lib/v2/tju/cic/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -79,7 +80,7 @@ module.exports = async (ctx) => {
switch (item.type) {
case 'tju-cic':
case 'in-site':
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
let detailResponse = null;
try {
detailResponse = await got(item.link);
diff --git a/lib/v2/tju/news/index.js b/lib/v2/tju/news/index.js
index bccd9cd1b..9c034c9b5 100644
--- a/lib/v2/tju/news/index.js
+++ b/lib/v2/tju/news/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -91,7 +92,7 @@ module.exports = async (ctx) => {
switch (item.type) {
case 'tju-news':
case 'in-site':
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
let detailResponse = null;
try {
delete item.type;
diff --git a/lib/v2/tju/oaa/index.js b/lib/v2/tju/oaa/index.js
index 723f51291..f22300485 100644
--- a/lib/v2/tju/oaa/index.js
+++ b/lib/v2/tju/oaa/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { finishArticleItem } = require('@/utils/wechat-mp');
@@ -85,7 +86,7 @@ module.exports = async (ctx) => {
return finishArticleItem(item);
case 'tju-oaa':
case 'in-site':
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
let detailResponse = null;
try {
detailResponse = await got(item.link, { https: { rejectUnauthorized: false } });
diff --git a/lib/v2/tju/yzb/index.js b/lib/v2/tju/yzb/index.js
index 466423bd9..6fd0d4462 100644
--- a/lib/v2/tju/yzb/index.js
+++ b/lib/v2/tju/yzb/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -89,7 +90,7 @@ module.exports = async (ctx) => {
switch (item.type) {
case 'tju-yzb':
case 'in-site':
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
let detailResponse = null;
try {
detailResponse = await got(item.link, { responseType: 'buffer' });
diff --git a/lib/v2/tokeninsight/blog.js b/lib/v2/tokeninsight/blog.js
index 11509fded..ae8178ebd 100644
--- a/lib/v2/tokeninsight/blog.js
+++ b/lib/v2/tokeninsight/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const getBlogInfomation = async (blog) => {
const { publishDate, title, id } = blog;
const blogUrl = `${baseURL}${lang}/blogs/${id}`;
- const description = await ctx.cache.tryGet(blogUrl, async () => {
+ const description = await cache.tryGet(blogUrl, async () => {
const res = await got(blogUrl);
const $ = load(res.data);
const description = $('.detail_html_box').html();
diff --git a/lib/v2/tokeninsight/bulletin.js b/lib/v2/tokeninsight/bulletin.js
index 891bcd219..d742b8acd 100644
--- a/lib/v2/tokeninsight/bulletin.js
+++ b/lib/v2/tokeninsight/bulletin.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const get_article_info = async (article) => {
const { updateDate, titleEn, id, title } = article;
const articleUrl = `${baseURL}${lang}/latest/${id}`;
- const description = await ctx.cache.tryGet(articleUrl, async () => {
+ const description = await cache.tryGet(articleUrl, async () => {
const res = await got(articleUrl);
const $ = load(res.data);
return $('.detail_html_box').html();
diff --git a/lib/v2/tokeninsight/report.js b/lib/v2/tokeninsight/report.js
index 19b962d88..e1c224864 100644
--- a/lib/v2/tokeninsight/report.js
+++ b/lib/v2/tokeninsight/report.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const getReportInfomation = async (report) => {
const { publishDate, title, id } = report;
const reportUrl = `${baseURL}${lang}/report/${id}`;
- const description = await ctx.cache.tryGet(reportUrl, async () => {
+ const description = await cache.tryGet(reportUrl, async () => {
const res = await got(reportUrl);
const $ = load(res.data);
const description = $('.detail_html_box').html();
diff --git a/lib/v2/tongji/sse/notice.js b/lib/v2/tongji/sse/notice.js
index 8a279d1d5..d7f8bb4f1 100644
--- a/lib/v2/tongji/sse/notice.js
+++ b/lib/v2/tongji/sse/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// Warning: The author still knows nothing about javascript!
// params:
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
});
// get articles
- const articleList = await Promise.all(detailUrls.map((item) => ctx.cache.tryGet(item.link, () => getArticle(item))));
+ const articleList = await Promise.all(detailUrls.map((item) => cache.tryGet(item.link, () => getArticle(item))));
// feed the data
ctx.set('data', {
diff --git a/lib/v2/toodaylab/index.js b/lib/v2/toodaylab/index.js
index 3e288abc6..3fcd63fdc 100644
--- a/lib/v2/toodaylab/index.js
+++ b/lib/v2/toodaylab/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -54,7 +55,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/topys/index.js b/lib/v2/topys/index.js
index 5dee1f1ce..493ef07b9 100644
--- a/lib/v2/topys/index.js
+++ b/lib/v2/topys/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/tradingview/blog.js b/lib/v2/tradingview/blog.js
index cb91c0716..de806dffa 100644
--- a/lib/v2/tradingview/blog.js
+++ b/lib/v2/tradingview/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
});
for await (const item of asyncPool(3, items, (item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/transcriptforest/index.js b/lib/v2/transcriptforest/index.js
index 228fdd4f6..b1a5f76ec 100644
--- a/lib/v2/transcriptforest/index.js
+++ b/lib/v2/transcriptforest/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -62,7 +63,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.detailUrl);
const { data: textResponse } = await got(detailResponse.pageProps.currentEpisode.ps4_url);
diff --git a/lib/v2/tribalfootball/latest.js b/lib/v2/tribalfootball/latest.js
index 1e4bbdb35..b23162fb6 100644
--- a/lib/v2/tribalfootball/latest.js
+++ b/lib/v2/tribalfootball/latest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/twitter/list.js b/lib/v2/twitter/list.js
index 42934f60d..c2e4e01a3 100644
--- a/lib/v2/twitter/list.js
+++ b/lib/v2/twitter/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const utils = require('./utils');
import { config } from '@/config';
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const { id, name } = ctx.params;
const client = await utils.getAppClient();
- const list_data = await ctx.cache.tryGet(`twitter_lists_list_screen_name:${id}`, async () => {
+ const list_data = await cache.tryGet(`twitter_lists_list_screen_name:${id}`, async () => {
const data = await client.v1.get('lists/list.json', {
screen_name: id,
});
diff --git a/lib/v2/twitter/web-api/media.js b/lib/v2/twitter/web-api/media.js
index f41d24789..741cfb2d7 100644
--- a/lib/v2/twitter/web-api/media.js
+++ b/lib/v2/twitter/web-api/media.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const utils = require('../utils');
// import { config } from '@/config';
const { getUser, getUserMedia } = require('./twitter-api');
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const { count } = utils.parseRouteParams(ctx.req.param('routeParams'));
const params = count ? { count } : {};
- await initToken(ctx.cache.tryGet);
+ await initToken(cache.tryGet);
const userInfo = await getUser(ctx.cache, id);
const data = await getUserMedia(ctx.cache, id, params);
const profileImageUrl = userInfo.profile_image_url || userInfo.profile_image_url_https;
diff --git a/lib/v2/twitter/web-api/search.js b/lib/v2/twitter/web-api/search.js
index 8eda3c68a..efb0898f1 100644
--- a/lib/v2/twitter/web-api/search.js
+++ b/lib/v2/twitter/web-api/search.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
const utils = require('../utils');
const { getSearch } = require('./twitter-api');
const { initToken } = require('./token');
module.exports = async (ctx) => {
const keyword = ctx.req.param('keyword');
- await initToken(ctx.cache.tryGet);
+ await initToken(cache.tryGet);
const data = await getSearch(keyword);
ctx.set('data', {
diff --git a/lib/v2/twitter/web-api/tweet.js b/lib/v2/twitter/web-api/tweet.js
index 9825fd2d8..343e8c088 100644
--- a/lib/v2/twitter/web-api/tweet.js
+++ b/lib/v2/twitter/web-api/tweet.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// import { config } from '@/config';
const { getUser, getUserTweet } = require('./twitter-api');
const utils = require('../utils');
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
const routeParams = new URLSearchParams(ctx.req.param('original'));
const original = fallback(undefined, queryToBoolean(routeParams.get('original')), false);
const params = { focalTweetId: status };
- await initToken(ctx.cache.tryGet);
+ await initToken(cache.tryGet);
const userInfo = await getUser(ctx.cache, id);
const data = await getUserTweet(ctx.cache, id, params);
const profileImageUrl = userInfo.profile_image_url || userInfo.profile_image_url_https;
diff --git a/lib/v2/twitter/web-api/user.js b/lib/v2/twitter/web-api/user.js
index da1d8b397..d32093245 100644
--- a/lib/v2/twitter/web-api/user.js
+++ b/lib/v2/twitter/web-api/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const utils = require('../utils');
const { getUser, getUserTweets, getUserTweetsAndReplies, excludeRetweet } = require('./twitter-api');
const { initToken } = require('./token');
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const { count, exclude_replies, include_rts } = utils.parseRouteParams(ctx.req.param('routeParams'));
const params = count ? { count } : {};
- await initToken(ctx.cache.tryGet);
+ await initToken(cache.tryGet);
const userInfo = await getUser(ctx.cache, id);
let data = await (exclude_replies ? getUserTweets(ctx.cache, id, params) : getUserTweetsAndReplies(ctx.cache, id, params));
if (!include_rts) {
diff --git a/lib/v2/twreporter/newest.js b/lib/v2/twreporter/newest.js
index 793f7f613..40de9d0ad 100644
--- a/lib/v2/twreporter/newest.js
+++ b/lib/v2/twreporter/newest.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const $ = load(item);
const address = url + $('a').attr('href');
const title = $('.latest-section__Title-hzxpx3-6').text();
- return ctx.cache.tryGet(address, async () => {
+ return cache.tryGet(address, async () => {
const single = await fetch(address);
single.title = title;
return single;
diff --git a/lib/v2/txrjy/fornumtopic.js b/lib/v2/txrjy/fornumtopic.js
index fe86f662a..892c73c2d 100644
--- a/lib/v2/txrjy/fornumtopic.js
+++ b/lib/v2/txrjy/fornumtopic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
responseType: 'buffer',
});
diff --git a/lib/v2/tynu/tynu.js b/lib/v2/tynu/tynu.js
index 3fd4a24e0..077500313 100644
--- a/lib/v2/tynu/tynu.js
+++ b/lib/v2/tynu/tynu.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('#vsb_content').html() + ($('.content ul').not('.btm-cate').html() || '');
diff --git a/lib/v2/typora/changelog.js b/lib/v2/typora/changelog.js
index 5a920fbe4..ad77c4522 100644
--- a/lib/v2/typora/changelog.js
+++ b/lib/v2/typora/changelog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = load(data);
diff --git a/lib/v2/u3c3/index.js b/lib/v2/u3c3/index.js
index 229d2d0fe..22033ae7b 100644
--- a/lib/v2/u3c3/index.js
+++ b/lib/v2/u3c3/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -52,7 +53,7 @@ module.exports = async (ctx) => {
const items = preview
? await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/u9a9/index.js b/lib/v2/u9a9/index.js
index 8504e9d18..3e3e83a82 100644
--- a/lib/v2/u9a9/index.js
+++ b/lib/v2/u9a9/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
const items = preview
? await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/uber/blog.js b/lib/v2/uber/blog.js
index 1f0170ca8..2fbfa9721 100644
--- a/lib/v2/uber/blog.js
+++ b/lib/v2/uber/blog.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
pages.map((page) =>
Promise.all(
page.posts.map((post) =>
- ctx.cache.tryGet(`${rootURL}${post.link}`, async () => {
+ cache.tryGet(`${rootURL}${post.link}`, async () => {
let { data: article } = await got(`${apiURL}/wp-json/blog/v1/data`, {
searchParams: {
slug: post.link.replaceAll('/', '').replace('blog', ''),
diff --git a/lib/v2/ucas/index.js b/lib/v2/ucas/index.js
index 1cc53f309..7ad36f6cc 100644
--- a/lib/v2/ucas/index.js
+++ b/lib/v2/ucas/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const link = rootUrl + $(item).find('a').attr('href');
const pubDate = parseDate($(item).find('span').text());
- const desc = await ctx.cache.tryGet(link, async () => {
+ const desc = await cache.tryGet(link, async () => {
const response = await got.get(link);
const pageContent = load(response.data);
diff --git a/lib/v2/uchicago/current.js b/lib/v2/uchicago/current.js
index 3681f1c83..ce68dac58 100644
--- a/lib/v2/uchicago/current.js
+++ b/lib/v2/uchicago/current.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const { getCookies, setCookies } = require('@/utils/puppeteer-utils');
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const page = await browser.newPage();
await setCookies(page, cookies, 'journals.uchicago.edu');
await page.setRequestInterception(true);
diff --git a/lib/v2/udn/breaking-news.js b/lib/v2/udn/breaking-news.js
index 7e54fc050..493640d16 100644
--- a/lib/v2/udn/breaking-news.js
+++ b/lib/v2/udn/breaking-news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
linkUrl.query = linkUrl.search = '';
link = linkUrl.toString();
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
let result = await got(link);
// VIP article requires redirection
// e.g. https://udn.com/news/story/7331/6576320
@@ -76,7 +77,7 @@ module.exports = async (ctx) => {
const getLinkName = async (ctx, link) => {
const url = 'https://udn.com/news/breaknews';
- const links = await ctx.cache.tryGet(url, async () => {
+ const links = await cache.tryGet(url, async () => {
const result = await got(url);
const $ = load(result.data);
const data = $('.cate-list__subheader a')
diff --git a/lib/v2/udn/global/index.js b/lib/v2/udn/global/index.js
index 4dad7c543..086a8930d 100644
--- a/lib/v2/udn/global/index.js
+++ b/lib/v2/udn/global/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/udn/global/tag.js b/lib/v2/udn/global/tag.js
index d3bb96271..64944a824 100644
--- a/lib/v2/udn/global/tag.js
+++ b/lib/v2/udn/global/tag.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/uestc/gr.js b/lib/v2/uestc/gr.js
index d7e2c1d13..0a492aee5 100644
--- a/lib/v2/uestc/gr.js
+++ b/lib/v2/uestc/gr.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
items.map(async (newsUrl) => {
- const newsDetail = await ctx.cache.tryGet(newsUrl, async () => {
+ const newsDetail = await cache.tryGet(newsUrl, async () => {
const result = await got.get(newsUrl);
const $ = load(result.data);
diff --git a/lib/v2/uibe/hr.js b/lib/v2/uibe/hr.js
index aa332fbe6..52f147a25 100644
--- a/lib/v2/uibe/hr.js
+++ b/lib/v2/uibe/hr.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',
diff --git a/lib/v2/ulapia/research.js b/lib/v2/ulapia/research.js
index 986807065..18e4257e8 100644
--- a/lib/v2/ulapia/research.js
+++ b/lib/v2/ulapia/research.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -11,7 +12,7 @@ module.exports = async (ctx) => {
researchList.map((item) => {
const url = `${rootUrl}/reports/${item}`;
- return ctx.cache.tryGet(url, async () => {
+ return cache.tryGet(url, async () => {
const response = await got.get(url);
const $ = load(response.data);
const items = $('div.row > div.col-md-6')
diff --git a/lib/v2/upc/jsj.js b/lib/v2/upc/jsj.js
index c44701f71..222a6983b 100644
--- a/lib/v2/upc/jsj.js
+++ b/lib/v2/upc/jsj.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 计算机科学与技术学院:http://computer.upc.edu.cn/
// - 学院新闻:http://computer.upc.edu.cn/6277/list.htm
// - 学术关注:http://computer.upc.edu.cn/6278/list.htm
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
// ### 遍历列表,筛选出自己想要的内容
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
// 获取详情页面的介绍
const detail_response = await got({
method: 'get',
diff --git a/lib/v2/upc/main.js b/lib/v2/upc/main.js
index e285be646..7a4fffb6c 100644
--- a/lib/v2/upc/main.js
+++ b/lib/v2/upc/main.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
// 学校官网:http://www.upc.edu.cn/
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
// ### 遍历列表,筛选出自己想要的内容
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.startsWith(`${baseUrl}/`) || item.link.includes('content.jsp')) {
return item;
}
diff --git a/lib/v2/uraaka-joshi/uraaka-joshi-user.js b/lib/v2/uraaka-joshi/uraaka-joshi-user.js
index 2f73842d9..adf41bc78 100644
--- a/lib/v2/uraaka-joshi/uraaka-joshi-user.js
+++ b/lib/v2/uraaka-joshi/uraaka-joshi-user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const { id } = ctx.params;
const link = `https://www.uraaka-joshi.com/user/${id}`;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
link,
async () => {
const browser = puppeteer();
diff --git a/lib/v2/usenix/usenix.js b/lib/v2/usenix/usenix.js
index da80eb8cc..870c6ae79 100644
--- a/lib/v2/usenix/usenix.js
+++ b/lib/v2/usenix/usenix.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = 'https://www.usenix.org';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.description = $('.content').html();
diff --git a/lib/v2/ustb/yzxc/tzgg.js b/lib/v2/ustb/yzxc/tzgg.js
index 3ab5e88ea..2d8d0071c 100644
--- a/lib/v2/ustb/yzxc/tzgg.js
+++ b/lib/v2/ustb/yzxc/tzgg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
} else {
itemUrl = host + path;
}
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
let description = titleText;
const result = await got(itemUrl);
const $ = load(result.data);
diff --git a/lib/v2/ustc/eeis.js b/lib/v2/ustc/eeis.js
index 7b59151d3..246a480fb 100644
--- a/lib/v2/ustc/eeis.js
+++ b/lib/v2/ustc/eeis.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let desc = '';
try {
const response = await got(item.link);
diff --git a/lib/v2/ustc/gs.js b/lib/v2/ustc/gs.js
index d3f4399ae..330b197c0 100644
--- a/lib/v2/ustc/gs.js
+++ b/lib/v2/ustc/gs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let desc = '';
try {
const response = await got(item.link);
diff --git a/lib/v2/ustc/index.js b/lib/v2/ustc/index.js
index d35b8b69d..a9839affd 100644
--- a/lib/v2/ustc/index.js
+++ b/lib/v2/ustc/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -13,7 +14,7 @@ const notice_type = {
// 对防抓的措施
// function getCookie(ctx) {
// const cache_key = `ustc-cookie-${new Date().toLocaleDateString()}`;
-// return ctx.cache.tryGet(cache_key, async () => {
+// return cache.tryGet(cache_key, async () => {
// const { headers } = await got('https://ustc.edu.cn/system/resource/code/datainput.jsp', {
// headers: { 'user-agent': UA },
// });
@@ -55,7 +56,7 @@ module.exports = async (ctx) => {
items
.filter((item) => item.link)
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/ustc/job.js b/lib/v2/ustc/job.js
index ed01817bc..57e05b415 100644
--- a/lib/v2/ustc/job.js
+++ b/lib/v2/ustc/job.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -95,7 +96,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: (() => {
switch (category) {
diff --git a/lib/v2/ustc/jwc.js b/lib/v2/ustc/jwc.js
index 7298e9515..31c16ade6 100644
--- a/lib/v2/ustc/jwc.js
+++ b/lib/v2/ustc/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items
.filter((item) => item.link)
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
// www.teach ?? pms.cmet ?? news
diff --git a/lib/v2/ustc/sist.js b/lib/v2/ustc/sist.js
index 23ddcb12c..8543c362b 100644
--- a/lib/v2/ustc/sist.js
+++ b/lib/v2/ustc/sist.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
let desc = '';
try {
const response = await got(item.link);
diff --git a/lib/v2/usts/jwch.js b/lib/v2/usts/jwch.js
index 1e2f51ffe..9379bbab0 100644
--- a/lib/v2/usts/jwch.js
+++ b/lib/v2/usts/jwch.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/utgd/category.js b/lib/v2/utgd/category.js
index 8f4d4c7e1..cfab4f3e4 100644
--- a/lib/v2/utgd/category.js
+++ b/lib/v2/utgd/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.items.map((item) =>
- ctx.cache.tryGet(`untag-${item.id}`, async () => {
+ cache.tryGet(`untag-${item.id}`, async () => {
const authorResponse = await got({
method: 'get',
url: `${rootUrl}/api/v2/user/profile/${item.article_author.id}/`,
diff --git a/lib/v2/utgd/timeline.js b/lib/v2/utgd/timeline.js
index 3ffa413b3..e64fe21fd 100644
--- a/lib/v2/utgd/timeline.js
+++ b/lib/v2/utgd/timeline.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.results.slice(0, limit).map((item) =>
- ctx.cache.tryGet(`untag-${item.id}`, async () => {
+ cache.tryGet(`untag-${item.id}`, async () => {
const detailResponse = await got({
method: 'get',
url: `${rootUrl}/api/v2/article/${item.id}/`,
diff --git a/lib/v2/utgd/topic.js b/lib/v2/utgd/topic.js
index e416af791..a7e215204 100644
--- a/lib/v2/utgd/topic.js
+++ b/lib/v2/utgd/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -37,7 +38,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.slice(0, limit).map((item) =>
- ctx.cache.tryGet(`untag-${item.id}`, async () => {
+ cache.tryGet(`untag-${item.id}`, async () => {
const detailResponse = await got({
method: 'get',
url: `${rootUrl}/api/v2/article/${item.id}/`,
diff --git a/lib/v2/uw/gix/news.js b/lib/v2/uw/gix/news.js
index 982b7b81e..8be4a871c 100644
--- a/lib/v2/uw/gix/news.js
+++ b/lib/v2/uw/gix/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
const itemContent = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const descriptionResponse = await got(item.link);
const content = load(descriptionResponse.data);
diff --git a/lib/v2/v1tx/index.js b/lib/v2/v1tx/index.js
index c8daababd..c79948b84 100644
--- a/lib/v2/v1tx/index.js
+++ b/lib/v2/v1tx/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/v2ex/tab.js b/lib/v2/v2ex/tab.js
index 15c69d92d..62fc7ab61 100644
--- a/lib/v2/v2ex/tab.js
+++ b/lib/v2/v2ex/tab.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
links.map((link) =>
- ctx.cache.tryGet(`v2ex-${link}`, async () => {
+ cache.tryGet(`v2ex-${link}`, async () => {
const response = await got({
method: 'get',
url: link,
diff --git a/lib/v2/vcb-s/category.js b/lib/v2/vcb-s/category.js
index 78862e272..e7b26335f 100644
--- a/lib/v2/vcb-s/category.js
+++ b/lib/v2/vcb-s/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
const limit = ctx.req.query('limit') ?? 7;
const cateUrl = `${cateAPIUrl}?slug=${cate}`;
- const category = await ctx.cache.tryGet(cateUrl, async () => {
+ const category = await cache.tryGet(cateUrl, async () => {
const res = await got.get(cateUrl);
if (typeof res.data === 'string') {
diff --git a/lib/v2/vimeo/category.js b/lib/v2/vimeo/category.js
index db78e6ffe..d5e2d5ab4 100644
--- a/lib/v2/vimeo/category.js
+++ b/lib/v2/vimeo/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const feedlink = `https://vimeo.com/categories/${category}/videos/sort:latest`;
const feedlinkstaffpicks = '?staffpicked=ture';
- const feedDescription = await ctx.cache.tryGet(feedlink + (staffpicks ? feedlinkstaffpicks : ''), async () => {
+ const feedDescription = await cache.tryGet(feedlink + (staffpicks ? feedlinkstaffpicks : ''), async () => {
const response = await got({
url: feedlink + (staffpicks ? feedlinkstaffpicks : ''),
});
diff --git a/lib/v2/vimeo/channel.js b/lib/v2/vimeo/channel.js
index 359a4ea70..5b4c4ca28 100644
--- a/lib/v2/vimeo/channel.js
+++ b/lib/v2/vimeo/channel.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
list.get().map((item) => {
item = $(item);
const link = item.find('.more').attr('href');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const response2 = await got({
method: 'get',
url: `https://vimeo.com${link}/description?breeze=1`,
diff --git a/lib/v2/vocus/publication.js b/lib/v2/vocus/publication.js
index 46d67f497..d7a0d4036 100644
--- a/lib/v2/vocus/publication.js
+++ b/lib/v2/vocus/publication.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { processList, ProcessFeed, baseUrl, apiUrl } = require('./utils');
@@ -5,7 +6,7 @@ module.exports = async (ctx) => {
const { id } = ctx.params;
const link = `${baseUrl}/${id}/home`;
- const publicationData = await ctx.cache.tryGet(`vocus:publication:${id}`, async () => {
+ const publicationData = await cache.tryGet(`vocus:publication:${id}`, async () => {
const { data: publicationData } = await got(`${apiUrl}/api/publication/${id}`, {
headers: {
referer: link,
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const list = processList(articles);
- const items = await ProcessFeed(list, ctx.cache.tryGet);
+ const items = await ProcessFeed(list, cache.tryGet);
ctx.set('data', {
title: `${publicationData.title} - 文章列表|方格子 vocus`,
diff --git a/lib/v2/vocus/user.js b/lib/v2/vocus/user.js
index f18fcf5e5..e41979537 100644
--- a/lib/v2/vocus/user.js
+++ b/lib/v2/vocus/user.js
@@ -1,10 +1,11 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { processList, ProcessFeed, baseUrl, apiUrl } = require('./utils');
module.exports = async (ctx) => {
const { id } = ctx.params;
const link = `${baseUrl}/user/@${id}`;
- const userData = await ctx.cache.tryGet(`vocus:user:${id}`, async () => {
+ const userData = await cache.tryGet(`vocus:user:${id}`, async () => {
const { data: userData } = await got(`${apiUrl}/api/users/${id}`, {
headers: {
referer: link,
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const list = processList(articles);
- const items = await ProcessFeed(list, ctx.cache.tryGet);
+ const items = await ProcessFeed(list, cache.tryGet);
ctx.set('data', {
title: `${userData.fullname}|方格子 vocus`,
diff --git a/lib/v2/vom/featured.js b/lib/v2/vom/featured.js
index ccd8ca19a..9a720133c 100644
--- a/lib/v2/vom/featured.js
+++ b/lib/v2/vom/featured.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/wallhaven/index.js b/lib/v2/wallhaven/index.js
index 1c1edfd1b..40f05f1f2 100644
--- a/lib/v2/wallhaven/index.js
+++ b/lib/v2/wallhaven/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
if (needDetails) {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/wallstreetcn/hot.js b/lib/v2/wallstreetcn/hot.js
index 1c2f2156f..476f98ba1 100644
--- a/lib/v2/wallstreetcn/hot.js
+++ b/lib/v2/wallstreetcn/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: `${apiRootUrl}/apiv1/content/articles/${item.guid}?extract=0`,
diff --git a/lib/v2/wallstreetcn/news.js b/lib/v2/wallstreetcn/news.js
index 03491a642..aa24f1840 100644
--- a/lib/v2/wallstreetcn/news.js
+++ b/lib/v2/wallstreetcn/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: `${apiRootUrl}/apiv1/content/${item.type === 'live' ? `lives/${item.guid}` : `articles/${item.guid}?extract=0`}`,
diff --git a/lib/v2/web3caff/index.js b/lib/v2/web3caff/index.js
index e1389e4aa..58cb9e276 100644
--- a/lib/v2/web3caff/index.js
+++ b/lib/v2/web3caff/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -33,7 +34,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/wechat/ce.js b/lib/v2/wechat/ce.js
index 332b20047..b89132d60 100644
--- a/lib/v2/wechat/ce.js
+++ b/lib/v2/wechat/ce.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const parser = require('@/utils/rss-parser');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
// generally speaking, changing `item.link` of an existing route could potentially break `item.guid`
// but since the route has been down for at least 8 months, it's probably safe
item.link = item.link.replace(/^http:\/\//, 'https://');
- return ctx.cache.tryGet(item.link, async () => {
+ return cache.tryGet(item.link, async () => {
const response = await got.get(item.link, {
headers: {
'User-Agent': UA,
diff --git a/lib/v2/wechat/data258.js b/lib/v2/wechat/data258.js
index 93c9cd754..ddc0e1a74 100644
--- a/lib/v2/wechat/data258.js
+++ b/lib/v2/wechat/data258.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ const parsePage = ($item, hyperlinkSelector, timeSelector) => {
module.exports = async (ctx) => {
// !!! here we must use a lock to prevent other requests to break the anti-anti-crawler workarounds !!!
- if ((await ctx.cache.get('data258:lock', false)) === '1') {
+ if ((await cache.get('data258:lock', false)) === '1') {
throw new RequestInProgressError('Another request is in progress, please try again later.');
}
// !!! here no need to acquire the lock, because the MP/category page has no crawler detection !!!
@@ -54,11 +55,11 @@ module.exports = async (ctx) => {
items = items.slice(0, limit); // limit to avoid being anti-crawled
// !!! double-check !!!
- if ((await ctx.cache.get('data258:lock', false)) === '1') {
+ if ((await cache.get('data258:lock', false)) === '1') {
throw new RequestInProgressError('Another request is in progress, please try again later.');
} else {
// !!! here we acquire the lock because the jump page has crawler detection !!!
- await ctx.cache.set('data258:lock', '1', 60);
+ await cache.set('data258:lock', '1', 60);
}
// !!! here we must use a for-loop to ensure the concurrency is 1 !!!
@@ -71,7 +72,7 @@ module.exports = async (ctx) => {
// https://mp.data258.com/wx?id=${id}&t={token}, id is a permanent hex, token is a temporary base64
const cacheId = item.link.match(/id=([\da-f]+)/)[1];
item.link = item.link.startsWith('http') ? item.link : `${rootUrl}${item.link}`;
- const realLink = await ctx.cache.tryGet(`data258:${cacheId}`, async () => {
+ const realLink = await cache.tryGet(`data258:${cacheId}`, async () => {
try {
// !!! here we must sleep 1s to avoid being anti-crawled !!!
// !!! please do note that if the interval is less than 1s, your IP will be banned for a long time !!!
@@ -107,7 +108,7 @@ module.exports = async (ctx) => {
/* eslint-enable no-await-in-loop */
// !!! release the lock, let it expire immediately since no need to keep it in cache !!!
- await ctx.cache.set('data258:lock', '0', 1);
+ await cache.set('data258:lock', '0', 1);
// jump links are valid only for a short period of time, drop those un-jumped items
// http://mp.weixin.qq.com/s
diff --git a/lib/v2/wechat/uread.js b/lib/v2/wechat/uread.js
index 58c1a8d9d..e9c5c8a69 100644
--- a/lib/v2/wechat/uread.js
+++ b/lib/v2/wechat/uread.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -19,9 +20,9 @@ module.exports = async (ctx) => {
data.data.map(async (item) => {
const link = item.url;
- const cache = await ctx.cache.get(link);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(link);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got({
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
author: item.official_account,
pubDate: item.publish_time,
};
- ctx.cache.set(link, JSON.stringify(single));
+ cache.set(link, JSON.stringify(single));
return single;
})
);
diff --git a/lib/v2/wechat/wxnmh.js b/lib/v2/wechat/wxnmh.js
index 79b519e63..bf4c44e3d 100644
--- a/lib/v2/wechat/wxnmh.js
+++ b/lib/v2/wechat/wxnmh.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -20,7 +21,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
links.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const res = await got.get(item.link);
const $ = load(res.data);
diff --git a/lib/v2/weibo/friends.js b/lib/v2/weibo/friends.js
index e769a4c52..4739a6428 100644
--- a/lib/v2/weibo/friends.js
+++ b/lib/v2/weibo/friends.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('querystring');
import got from '@/utils/got';
import { config } from '@/config';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
}
}
- const uid = await ctx.cache.tryGet(
+ const uid = await cache.tryGet(
`weibo:friends:login-user`,
async () => {
const _r = await got({
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
false
);
- const containerData = await ctx.cache.tryGet(
+ const containerData = await cache.tryGet(
`weibo:user:index:${uid}`,
async () => {
const _r = await got({
@@ -64,7 +65,7 @@ module.exports = async (ctx) => {
const name = containerData.data.userInfo.screen_name;
const title = `${name} 的 最新关注时间线`;
- const responseData = await ctx.cache.tryGet(
+ const responseData = await cache.tryGet(
`weibo:friends:index:${uid}`,
async () => {
const _r = await got({
@@ -86,7 +87,7 @@ module.exports = async (ctx) => {
responseData.statuses.map(async (item) => {
const retweet = item.retweeted_status;
if (retweet && retweet.isLongText) {
- const retweetData = await ctx.cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
+ const retweetData = await cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
if (retweetData !== undefined && retweetData.text) {
item.retweeted_status.text = retweetData.text;
}
diff --git a/lib/v2/weibo/group.js b/lib/v2/weibo/group.js
index bc33e3de5..bb55b3f6f 100644
--- a/lib/v2/weibo/group.js
+++ b/lib/v2/weibo/group.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('querystring');
import got from '@/utils/got';
import { config } from '@/config';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
}
}
- const responseData = await ctx.cache.tryGet(
+ const responseData = await cache.tryGet(
`weibo:group:index:${gid}`,
async () => {
const _r = await got({
@@ -48,7 +49,7 @@ module.exports = async (ctx) => {
responseData.statuses.map(async (item) => {
const retweet = item.retweeted_status;
if (retweet && retweet.isLongText) {
- const retweetData = await ctx.cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
+ const retweetData = await cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
if (retweetData !== undefined && retweetData.text) {
item.retweeted_status.text = retweetData.text;
}
diff --git a/lib/v2/weibo/keyword.js b/lib/v2/weibo/keyword.js
index ba0ef5765..87aece86e 100644
--- a/lib/v2/weibo/keyword.js
+++ b/lib/v2/weibo/keyword.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('querystring');
import got from '@/utils/got';
const weiboUtils = require('./utils');
@@ -8,7 +9,7 @@ import { config } from '@/config';
module.exports = async (ctx) => {
const keyword = ctx.req.param('keyword');
- const data = await ctx.cache.tryGet(
+ const data = await cache.tryGet(
`weibo:keyword:${keyword}`,
async () => {
const _r = await got({
diff --git a/lib/v2/weibo/search/hot.js b/lib/v2/weibo/search/hot.js
index 521244741..d7f239ac0 100644
--- a/lib/v2/weibo/search/hot.js
+++ b/lib/v2/weibo/search/hot.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { art } from '@/utils/render';
@@ -42,7 +43,7 @@ module.exports = async (ctx) => {
resultItems = await Promise.all(
tlist.map((i) =>
- ctx.cache.tryGet(i.plink, async () => {
+ cache.tryGet(i.plink, async () => {
const pInfo = await fetchContent(i.plink);
i.description = pInfo.content;
return i;
diff --git a/lib/v2/weibo/super-index.js b/lib/v2/weibo/super-index.js
index 6a8e2bff3..46edd1ea7 100644
--- a/lib/v2/weibo/super-index.js
+++ b/lib/v2/weibo/super-index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const weiboUtils = require('./utils');
const queryString = require('query-string');
@@ -7,7 +8,7 @@ module.exports = async (ctx) => {
const id = ctx.req.param('id');
const type = ctx.req.param('type') ?? 'feed';
- const containerData = await ctx.cache.tryGet(
+ const containerData = await cache.tryGet(
`weibo:super_index:container:${id}:${type}`,
async () => {
const _r = await got('https://m.weibo.cn/api/container/getIndex', {
diff --git a/lib/v2/weibo/timeline.js b/lib/v2/weibo/timeline.js
index 7392b015a..ec1133866 100644
--- a/lib/v2/weibo/timeline.js
+++ b/lib/v2/weibo/timeline.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('querystring');
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -9,7 +10,7 @@ module.exports = async (ctx) => {
const uid = ctx.req.param('uid');
const feature = ctx.req.param('feature') || 0;
const routeParams = ctx.req.param('routeParams') || undefined;
- const token = await ctx.cache.get('weibotimelineuid' + uid, false);
+ const token = await cache.get('weibotimelineuid' + uid, false);
let displayVideo = '1';
let displayArticle = '0';
let displayComments = '0';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
}
if (token) {
- const userInfo = await ctx.cache.tryGet(
+ const userInfo = await cache.tryGet(
`weibo:timeline:userInfo:${uid}`,
async () => {
const _r = await got({
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const description = userInfo.description;
const profileImageUrl = userInfo.profile_image_url;
- const response = await ctx.cache.tryGet(
+ const response = await cache.tryGet(
`weibo:timeline:${uid}`,
async () => {
const _r = await got(`https://api.weibo.com/2/statuses/home_timeline.json?access_token=${token}&count=100&feature=${feature}`);
@@ -66,7 +67,7 @@ module.exports = async (ctx) => {
const resultItem = await Promise.all(
response.statuses.map(async (item) => {
const key = `weibotimelineurl${item.user.id}${item.id}`;
- const data = await ctx.cache.tryGet(key, () => weiboUtils.getShowData(uid, item.id));
+ const data = await cache.tryGet(key, () => weiboUtils.getShowData(uid, item.id));
// 是否通过api拿到了data
const isDataOK = data?.text;
@@ -77,7 +78,7 @@ module.exports = async (ctx) => {
// 转发的长微博处理
const retweet = item.retweeted_status;
if (retweet?.isLongText) {
- const retweetData = await ctx.cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.id}`, () => weiboUtils.getShowData(retweet.user.id, retweet.id));
+ const retweetData = await cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.id}`, () => weiboUtils.getShowData(retweet.user.id, retweet.id));
if (retweetData?.text) {
item.retweeted_status.text = retweetData.text;
}
@@ -134,7 +135,7 @@ module.exports = async (ctx) => {
const token = rep.data.access_token;
const uid = rep.data.uid;
const expires_in = rep.data.expires_in;
- await ctx.cache.set('weibotimelineuid' + uid, token, expires_in);
+ await cache.set('weibotimelineuid' + uid, token, expires_in);
ctx.set({
'Content-Type': 'text/html; charset=UTF-8',
diff --git a/lib/v2/weibo/user.js b/lib/v2/weibo/user.js
index 9f5083fad..7056bd6d2 100644
--- a/lib/v2/weibo/user.js
+++ b/lib/v2/weibo/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('query-string');
import got from '@/utils/got';
const weiboUtils = require('./utils');
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
displayComments = fallback(undefined, queryToBoolean(routeParams.displayComments), false) ? '1' : '0';
}
}
- const containerData = await ctx.cache.tryGet(
+ const containerData = await cache.tryGet(
`weibo:user:index:${uid}`,
async () => {
const _r = await got({
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
const profileImageUrl = containerData.data.userInfo.profile_image_url;
const containerId = containerData.data.tabsInfo.tabs.find((item) => item.tab_type === 'weibo').containerid;
- const cards = await ctx.cache.tryGet(
+ const cards = await cache.tryGet(
`weibo:user:cards:${uid}:${containerId}`,
async () => {
const _r = await got({
@@ -73,7 +74,7 @@ module.exports = async (ctx) => {
// TODO: getShowData() on demand? The API seems to return most things we need since 2022/05/21.
// Need more investigation, pending for now since the current version works fine.
const key = 'weibo:user:' + item.mblog.bid;
- const data = await ctx.cache.tryGet(key, () => weiboUtils.getShowData(uid, item.mblog.bid));
+ const data = await cache.tryGet(key, () => weiboUtils.getShowData(uid, item.mblog.bid));
if (data && data.text) {
item.mblog.text = data.text;
@@ -90,7 +91,7 @@ module.exports = async (ctx) => {
const retweet = item.mblog.retweeted_status;
if (retweet && retweet.isLongText) {
// TODO: unify cache key and ...
- const retweetData = await ctx.cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
+ const retweetData = await cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
if (retweetData !== undefined && retweetData.text) {
item.mblog.retweeted_status.text = retweetData.text;
}
diff --git a/lib/v2/weibo/utils.js b/lib/v2/weibo/utils.js
index 022cabeec..4793463f1 100644
--- a/lib/v2/weibo/utils.js
+++ b/lib/v2/weibo/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const querystring = require('querystring');
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -315,7 +316,7 @@ const weiboUtils = {
}
const articleId = articleIdMatch[1];
const link = `https://card.weibo.com/article/m/aj/detail?id=${articleId}`;
- const response = await ctx.cache.tryGet(link, async () => {
+ const response = await cache.tryGet(link, async () => {
const _response = await got.get(link, {
headers: {
Referer: `https://card.weibo.com/article/m/show/id/${articleId}`,
@@ -397,7 +398,7 @@ const weiboUtils = {
const id = status.id;
const mid = status.mid;
const link = `https://m.weibo.cn/comments/hotflow?id=${id}&mid=${mid}&max_id_type=0`;
- const response = await ctx.cache.tryGet(link, async () => {
+ const response = await cache.tryGet(link, async () => {
const _response = await got.get(link, {
headers: {
Referer: `https://m.weibo.cn/detail/${id}`,
diff --git a/lib/v2/wenku8/volume.js b/lib/v2/wenku8/volume.js
index 797050893..4c2a83f04 100644
--- a/lib/v2/wenku8/volume.js
+++ b/lib/v2/wenku8/volume.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const vid = last_volume.parent().next().find('a')[0].attribs.href.replace('.htm', '');
const volume_url = `https://dl.wenku8.com/packtxt.php?aid=${aid}&vid=${vid}&charset=gbk`;
- const item_list = await ctx.cache.tryGet(volume_url, async () => {
+ const item_list = await cache.tryGet(volume_url, async () => {
const result = await get(volume_url);
const chapter_list = [...result.matchAll(/ {2}(\S.*)\r\n([\S\s]+?)\r\n\r\n/g)];
return chapter_list
diff --git a/lib/v2/wfu/news.js b/lib/v2/wfu/news.js
index 5d4f0d7ac..c006cea93 100644
--- a/lib/v2/wfu/news.js
+++ b/lib/v2/wfu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -80,7 +81,7 @@ module.exports = async (ctx) => {
// 对于列表的每一项, 单独获取 时间与详细内容
// eslint-disable-next-line no-return-await
- const other = await ctx.cache.tryGet($item_url, () => loadContent($item_url));
+ const other = await cache.tryGet($item_url, () => loadContent($item_url));
// 合并解析后的结果集作为该篇文章最终的输出结果
return { ...single, ...other };
})
diff --git a/lib/v2/whitehouse/briefing-room.js b/lib/v2/whitehouse/briefing-room.js
index 04e99a6bf..cf7c39a4e 100644
--- a/lib/v2/whitehouse/briefing-room.js
+++ b/lib/v2/whitehouse/briefing-room.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/whitehouse/ostp.js b/lib/v2/whitehouse/ostp.js
index 0bcc77b71..9ec0bf4bb 100644
--- a/lib/v2/whitehouse/ostp.js
+++ b/lib/v2/whitehouse/ostp.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/who/news-room.js b/lib/v2/who/news-room.js
index c9b30136e..c0c0b8e85 100644
--- a/lib/v2/who/news-room.js
+++ b/lib/v2/who/news-room.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/who/news.js b/lib/v2/who/news.js
index 740a1d374..3729f9287 100644
--- a/lib/v2/who/news.js
+++ b/lib/v2/who/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@@ -21,7 +22,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/who/speeches.js b/lib/v2/who/speeches.js
index 7a575fc54..660523712 100644
--- a/lib/v2/who/speeches.js
+++ b/lib/v2/who/speeches.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/whu/cs.js b/lib/v2/whu/cs.js
index ef5d4a4d4..220f9af15 100644
--- a/lib/v2/whu/cs.js
+++ b/lib/v2/whu/cs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/whu/gs/index.js b/lib/v2/whu/gs/index.js
index eed0332e6..665212723 100644
--- a/lib/v2/whu/gs/index.js
+++ b/lib/v2/whu/gs/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const detail = await got(item.link);
const content = load(detail.data);
diff --git a/lib/v2/whu/hyxt.js b/lib/v2/whu/hyxt.js
index b37ef4fb1..7bc2119c9 100644
--- a/lib/v2/whu/hyxt.js
+++ b/lib/v2/whu/hyxt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
};
});
- items = await processItems(items, ctx.cache.tryGet, rootUrl);
+ items = await processItems(items, cache.tryGet, rootUrl);
const meta = processMeta(response);
const siteName = getMeta(meta, 'SiteName');
diff --git a/lib/v2/whu/news.js b/lib/v2/whu/news.js
index c428d08e1..1403e7ed1 100644
--- a/lib/v2/whu/news.js
+++ b/lib/v2/whu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
};
});
- items = await processItems(items, ctx.cache.tryGet, rootUrl);
+ items = await processItems(items, cache.tryGet, rootUrl);
const meta = processMeta(response);
const siteName = getMeta(meta, 'SiteName');
diff --git a/lib/v2/wikinews/index.js b/lib/v2/wikinews/index.js
index 4e2914b4e..4e5eabf56 100644
--- a/lib/v2/wikinews/index.js
+++ b/lib/v2/wikinews/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const currentURL = 'https://zh.wikinews.org/wiki/Special:%E6%96%B0%E9%97%BB%E8%AE%A2%E9%98%85';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
urls.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const resp = await got(item.link);
const $ = load(resp.data);
item.description = $('#bodyContent').html();
diff --git a/lib/v2/winstall/update.js b/lib/v2/winstall/update.js
index 079c535e1..6d0fc1336 100644
--- a/lib/v2/winstall/update.js
+++ b/lib/v2/winstall/update.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { config } from '@/config';
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const baseUrl = 'https://winstall.app';
const { appId } = ctx.params;
- const buildId = await ctx.cache.tryGet(
+ const buildId = await cache.tryGet(
'winget:buildId',
async () => {
const { data } = await got(baseUrl);
diff --git a/lib/v2/wise/pair.js b/lib/v2/wise/pair.js
index 758f81249..ef4722d6c 100644
--- a/lib/v2/wise/pair.js
+++ b/lib/v2/wise/pair.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const dayjs = require('dayjs');
@@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const link = 'https://wise.com/tools/exchange-rate-alerts/';
const guid = `wise:rates:${ctx.req.param('source')}-${ctx.req.param('target')}-${yesterday}`;
- const single = await ctx.cache.tryGet(guid, async () => {
+ const single = await cache.tryGet(guid, async () => {
const { data } = await got('https://wise.com/rates/history', {
searchParams: {
source,
diff --git a/lib/v2/wnacg/index.js b/lib/v2/wnacg/index.js
index d0b9f1c7c..d65ad6c99 100644
--- a/lib/v2/wnacg/index.js
+++ b/lib/v2/wnacg/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -57,7 +58,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: descRes } = await got(item.link, {
headers: {
referer: encodeURI(url),
diff --git a/lib/v2/worldjournal/index.js b/lib/v2/worldjournal/index.js
index 711595088..9f831ebe6 100644
--- a/lib/v2/worldjournal/index.js
+++ b/lib/v2/worldjournal/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/woshipm/popular.js b/lib/v2/woshipm/popular.js
index 79c48a04d..bab784abe 100644
--- a/lib/v2/woshipm/popular.js
+++ b/lib/v2/woshipm/popular.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { baseUrl, parseArticle } = require('./utils');
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
};
});
- const result = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const result = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `热门文章 - ${rangeMap[range]} - 人人都是产品经理`,
diff --git a/lib/v2/woshipm/user-article.js b/lib/v2/woshipm/user-article.js
index a689ae2e4..f918655d4 100644
--- a/lib/v2/woshipm/user-article.js
+++ b/lib/v2/woshipm/user-article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
};
});
- const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: `${name}的文章-人人都是产品经理`,
diff --git a/lib/v2/woshipm/wen.js b/lib/v2/woshipm/wen.js
index 0cf1f6a79..85efcbecf 100644
--- a/lib/v2/woshipm/wen.js
+++ b/lib/v2/woshipm/wen.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const baseUrl = 'https://wen.woshipm.com';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
postList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const temp = await got(item.link);
const $ = load(temp.data);
item.description = $('.wt-desc').html();
diff --git a/lib/v2/wsj/utils.js b/lib/v2/wsj/utils.js
index fe4675d34..5a73fcd95 100644
--- a/lib/v2/wsj/utils.js
+++ b/lib/v2/wsj/utils.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const asyncPool = require('tiny-async-pool');
import { load } from 'cheerio';
import got from '@/utils/got';
@@ -9,8 +10,8 @@ import randUserAgent from '@/utils/rand-user-agent';
const UA = randUserAgent({ browser: 'chrome', os: 'android', device: 'mobile' });
// const chromeMobileUserAgent = 'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Mobile Safari/537.36';
-const parseArticle = (item, ctx) =>
- ctx.cache.tryGet(item.link, async () => {
+const parseArticle = (item) =>
+ cache.tryGet(item.link, async () => {
// Fetch the AMP version
const url = item.link.replace(/(?<=^https:\/\/\w+\.wsj\.com)/, '/amp');
const response = await got({
diff --git a/lib/v2/wsyu/news.js b/lib/v2/wsyu/news.js
index 8e12aeaca..85229c535 100644
--- a/lib/v2/wsyu/news.js
+++ b/lib/v2/wsyu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = require('url');
@@ -50,9 +51,9 @@ module.exports = async (ctx) => {
urlList.map(async (itemUrl, index) => {
itemUrl = url.resolve(baseUrl, itemUrl);
if (itemUrl.includes('.htm')) {
- const cache = await ctx.cache.get(itemUrl);
- if (cache) {
- return JSON.parse(cache);
+ const cacheIn = await cache.get(itemUrl);
+ if (cacheIn) {
+ return JSON.parse(cacheIn);
}
const response = await got.get(itemUrl);
const $ = load(response.data);
@@ -63,7 +64,7 @@ module.exports = async (ctx) => {
description: $('.content').html(),
pubDate: dateList[index],
};
- ctx.cache.set(itemUrl, JSON.stringify(single));
+ cache.set(itemUrl, JSON.stringify(single));
return single;
} else {
const single = {
diff --git a/lib/v2/wtu/job.js b/lib/v2/wtu/job.js
index 1c30432c4..55392c6ab 100644
--- a/lib/v2/wtu/job.js
+++ b/lib/v2/wtu/job.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const zlib = require('zlib');
@@ -62,7 +63,7 @@ module.exports = async (ctx) => {
// 获取全文信息
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got.get(item.link);
const content = decodeData(response);
item.description = content;
diff --git a/lib/v2/wyzxwk/article.js b/lib/v2/wyzxwk/article.js
index 856b7a4cc..fdd79f6b8 100644
--- a/lib/v2/wyzxwk/article.js
+++ b/lib/v2/wyzxwk/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.indexOf('wyzxwk.com') > 0) {
try {
const detailResponse = await got({
diff --git a/lib/v2/wzu/news.js b/lib/v2/wzu/news.js
index ece94cb2f..a7105025c 100644
--- a/lib/v2/wzu/news.js
+++ b/lib/v2/wzu/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { URL } = require('url');
@@ -74,7 +75,7 @@ module.exports = async (ctx) => {
const $itemUrl = new URL($originUrl, baseUrl).href;
return {
title: $a1.attr('title'),
- description: await ctx.cache.tryGet($itemUrl, () => loadContent($itemUrl)),
+ description: await cache.tryGet($itemUrl, () => loadContent($itemUrl)),
pubDate: parseDate($('li>samp').text(), 'YYYY-MM-DD'),
link: $itemUrl,
};
diff --git a/lib/v2/x-mol/news.js b/lib/v2/x-mol/news.js
index 62025db04..2409ec000 100644
--- a/lib/v2/x-mol/news.js
+++ b/lib/v2/x-mol/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
newsitem.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.link.includes('outLinkByIdAndCode')) {
return item;
}
diff --git a/lib/v2/x-mol/paper.js b/lib/v2/x-mol/paper.js
index 2ee17ddd3..af6695ead 100644
--- a/lib/v2/x-mol/paper.js
+++ b/lib/v2/x-mol/paper.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
};
const item = await asyncPoolAll(2, newsItem, (element) =>
- ctx.cache.tryGet(element.link, async () => {
+ cache.tryGet(element.link, async () => {
const response = await got(element.link);
const $ = load(response.data);
diff --git a/lib/v2/x6d/index.js b/lib/v2/x6d/index.js
index 5f866a4b0..37fbc77a6 100644
--- a/lib/v2/x6d/index.js
+++ b/lib/v2/x6d/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/xaufe/jiaowu.js b/lib/v2/xaufe/jiaowu.js
index 39d11f10c..704ae4fc7 100644
--- a/lib/v2/xaufe/jiaowu.js
+++ b/lib/v2/xaufe/jiaowu.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -50,7 +51,7 @@ module.exports = async (ctx) => {
language: 'zh_CN',
item: await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const $ = load(
(
await got({
diff --git a/lib/v2/xaut/index.js b/lib/v2/xaut/index.js
index 5b4e2a2fe..9d7e8e2df 100644
--- a/lib/v2/xaut/index.js
+++ b/lib/v2/xaut/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
// 遍历此前获取的数据
item: await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.match('zhixing.xaut.edu.cn') && !item.link.match('xinwen.xaut.edu.cn')) {
const res = await got({
method: 'get',
diff --git a/lib/v2/xaut/jwc.js b/lib/v2/xaut/jwc.js
index 54bf4706c..c05da7065 100644
--- a/lib/v2/xaut/jwc.js
+++ b/lib/v2/xaut/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
// 遍历此前获取的数据
item: await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (!item.link.match('zhixing.xaut.edu.cn') && !item.link.match('xinwen.xaut.edu.cn')) {
const res = await got({
method: 'get',
diff --git a/lib/v2/xaut/rsc.js b/lib/v2/xaut/rsc.js
index 148e8d21d..8a2218b2d 100644
--- a/lib/v2/xaut/rsc.js
+++ b/lib/v2/xaut/rsc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@@ -45,7 +46,7 @@ module.exports = async (ctx) => {
// 遍历此前获取的数据
item: await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
// 下面的if判断是否属于外链,使用切片的方式来判断,并不优雅,先用着吧
if (item.link.slice(0, 16) === 'http://renshichu') {
// 不属于外链
diff --git a/lib/v2/xiaoyuzhou/pickup.js b/lib/v2/xiaoyuzhou/pickup.js
index 551b72bad..e92be7c21 100644
--- a/lib/v2/xiaoyuzhou/pickup.js
+++ b/lib/v2/xiaoyuzhou/pickup.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
@@ -9,10 +10,10 @@ const isToday = (date) => {
return date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
};
-const ProcessFeed = async (ctx) => {
+const ProcessFeed = async () => {
const device_id = config.xiaoyuzhou.device_id || 'f5d56d9a-8530-49a4-a6d2-cfb4b7a31240';
const refresh_token =
- (await ctx.cache.get('XIAOYUZHOU_TOKEN')) ||
+ (await cache.get('XIAOYUZHOU_TOKEN')) ||
config.xiaoyuzhou.refresh_token ||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiVzhieXB2dTJtT24xZWNqcEppN2p6R2xhMDBhMHYxellLaHFcL0ZXVWVkdDcxNlh3bnJnOFE0cFpGbVJmVFJQQ29ESWsxMmVuY3RcLzNqQWNjeFU3aTZNbkM4MUtWcUlmWWJJbVBKdXJDTXVYc1dHa2x0SE5TK3llNnJvTldLSWN1M1ZFTGY5WFE0cGhnK2crQld6bFloM2g0VUtONlNKWWlUSGtkaHowd0RJYXIrdTlzOE5PaEJPYXdJXC80NEFZcW41RjJqUXNnU3o1TExDSGtuTENuUFppRXllaTNwcVFwRkgweWFWbk03bmQ2RFhrUmVmUExVMTVpMXcwRnpkXC9wWDEiLCJ2IjozLCJpdiI6IkJiVGFjXC9KTG9BU1NYY0tPMkk3M0JBPT0iLCJpYXQiOjE1OTQ1NzIyOTEuODE2fQ.aQm7A6A1R3P94s88vWBWTbIeek9nJ-q9ztfCB7o1uK0';
@@ -31,7 +32,7 @@ const ProcessFeed = async (ctx) => {
'x-jike-refresh-token': refresh_token,
},
});
- ctx.cache.set('XIAOYUZHOU_TOKEN', token_updated.data['x-jike-refresh-token']);
+ cache.set('XIAOYUZHOU_TOKEN', token_updated.data['x-jike-refresh-token']);
const response = await got({
method: 'post',
@@ -78,11 +79,11 @@ const ProcessFeed = async (ctx) => {
};
module.exports = async (ctx) => {
- let resultItems = await ctx.cache.tryGet(XIAOYUZHOU_ITEMS, () => ProcessFeed(ctx));
+ let resultItems = await cache.tryGet(XIAOYUZHOU_ITEMS, () => ProcessFeed(ctx));
if (!isToday(resultItems[0].pubDate)) {
// force refresh cache
resultItems = await ProcessFeed(ctx);
- ctx.cache.set(XIAOYUZHOU_ITEMS, resultItems);
+ cache.set(XIAOYUZHOU_ITEMS, resultItems);
}
ctx.set('data', {
title: '小宇宙 - 发现',
diff --git a/lib/v2/xiaozhuanlan/column.js b/lib/v2/xiaozhuanlan/column.js
index fa0dd4e9f..b124d0ef8 100644
--- a/lib/v2/xiaozhuanlan/column.js
+++ b/lib/v2/xiaozhuanlan/column.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const $ = load(detailResponse.data);
diff --git a/lib/v2/xidian/jwc.js b/lib/v2/xidian/jwc.js
index b37539be9..3e2679d06 100644
--- a/lib/v2/xidian/jwc.js
+++ b/lib/v2/xidian/jwc.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
referer: url,
diff --git a/lib/v2/ximalaya/album.js b/lib/v2/ximalaya/album.js
index a20b20c74..8de603628 100644
--- a/lib/v2/ximalaya/album.js
+++ b/lib/v2/ximalaya/album.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { getUrl, getRandom16 } = require('./utils');
@@ -128,7 +129,7 @@ module.exports = async (ctx) => {
await Promise.all(
playList.map(async (item) => {
const link = baseUrl + albumUrl + item.trackId;
- item.desc = await ctx.cache.tryGet('ximalaya:' + shouldShowNote.toString() + 'trackRichInfo' + link, async () => {
+ item.desc = await cache.tryGet('ximalaya:' + shouldShowNote.toString() + 'trackRichInfo' + link, async () => {
let _desc;
if (shouldShowNote) {
const trackRichInfoApi = `https://mobile.ximalaya.com/mobile-track/richIntro?trackId=${item.trackId}`;
@@ -149,7 +150,7 @@ module.exports = async (ctx) => {
await Promise.all(
playList.map(async (item) => {
const trackPayInfoApi = `https://mpay.ximalaya.com/mobile/track/pay/${item.trackId}/?device=pc`;
- const data = await ctx.cache.tryGet('ximalaya:trackPayInfo' + trackPayInfoApi, async () => {
+ const data = await cache.tryGet('ximalaya:trackPayInfo' + trackPayInfoApi, async () => {
const trackPayInfoResponse = await got(trackPayInfoApi, {
headers: {
'user-agent': 'ting_6.7.9(GM1900,Android29)',
diff --git a/lib/v2/xinpianchang/index.js b/lib/v2/xinpianchang/index.js
index b91d9caca..989dfddd9 100644
--- a/lib/v2/xinpianchang/index.js
+++ b/lib/v2/xinpianchang/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { rootUrl, getData, processItems } = require('./util');
module.exports = async (ctx) => {
@@ -6,11 +7,11 @@ module.exports = async (ctx) => {
const currentUrl = new URL(`discover/${params}`, rootUrl).href;
- const { data, response } = await getData(currentUrl, ctx.cache.tryGet);
+ const { data, response } = await getData(currentUrl, cache.tryGet);
let items = JSON.parse(response.match(/"list":(\[.*?]),"total"/)[1]);
- items = await processItems(items.slice(0, limit), ctx.cache.tryGet);
+ items = await processItems(items.slice(0, limit), cache.tryGet);
ctx.set('data', {
...data,
diff --git a/lib/v2/xinpianchang/rank.js b/lib/v2/xinpianchang/rank.js
index d1cc93925..7b467d674 100644
--- a/lib/v2/xinpianchang/rank.js
+++ b/lib/v2/xinpianchang/rank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, getData, processItems } = require('./util');
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const currentUrl = current.web_link;
const currentName = `${current.code}-${current.year}-${current.index}`;
- const { data, response: currentResponse } = await getData(currentUrl, ctx.cache.tryGet);
+ const { data, response: currentResponse } = await getData(currentUrl, cache.tryGet);
const buildId = currentResponse.match(/\/static\/(\w+)\/_buildManifest\.js/)[1];
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
let items = response.pageProps.rankList;
- items = await processItems(items.slice(0, limit), ctx.cache.tryGet);
+ items = await processItems(items.slice(0, limit), cache.tryGet);
ctx.set('data', {
...data,
diff --git a/lib/v2/xjtu/2yuan/news.js b/lib/v2/xjtu/2yuan/news.js
index 91dc391be..09f3395da 100644
--- a/lib/v2/xjtu/2yuan/news.js
+++ b/lib/v2/xjtu/2yuan/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/xjtu/dean.js b/lib/v2/xjtu/dean.js
index e3353b779..a38efa5aa 100644
--- a/lib/v2/xjtu/dean.js
+++ b/lib/v2/xjtu/dean.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -60,7 +61,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
try {
const response = await got(item.link);
const result = parseContent(response.data);
diff --git a/lib/v2/xjtu/dyyy/index.js b/lib/v2/xjtu/dyyy/index.js
index 60ffd305a..211308a1e 100644
--- a/lib/v2/xjtu/dyyy/index.js
+++ b/lib/v2/xjtu/dyyy/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -23,7 +24,7 @@ module.exports = async (ctx) => {
await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/xjtu/ee.js b/lib/v2/xjtu/ee.js
index ced3cde79..75fcf77ac 100644
--- a/lib/v2/xjtu/ee.js
+++ b/lib/v2/xjtu/ee.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
link: baseUrl,
item: await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link);
const content = load(res.data);
item.title = content('tr td[class^=titlestyle]').text();
diff --git a/lib/v2/xjtu/gs/tzgg.js b/lib/v2/xjtu/gs/tzgg.js
index 85a40e820..eb6e7a6ba 100644
--- a/lib/v2/xjtu/gs/tzgg.js
+++ b/lib/v2/xjtu/gs/tzgg.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
link: rootUrl,
item: await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link);
const content = load(res.data);
item.description = content('#vsb_content').html() + (content('form ul').length > 0 ? content('form ul').html() : '');
diff --git a/lib/v2/xjtu/international.js b/lib/v2/xjtu/international.js
index 25ef566ce..d13d531f3 100644
--- a/lib/v2/xjtu/international.js
+++ b/lib/v2/xjtu/international.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const item = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (new URL(item.link).pathname.startsWith === '/content.jsp') {
return item;
}
diff --git a/lib/v2/xjtu/job.js b/lib/v2/xjtu/job.js
index 42c2f1862..698612420 100644
--- a/lib/v2/xjtu/job.js
+++ b/lib/v2/xjtu/job.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got.post(`${baseUrl}/xsfw/sys/jyxtgktapp/modules/jywzManage/getWzone.do`, {
form: {
requestParamStr: `{"WID":${item.guid}}`,
diff --git a/lib/v2/xjtu/std.js b/lib/v2/xjtu/std.js
index 4e6ae2adb..b9fac6b27 100644
--- a/lib/v2/xjtu/std.js
+++ b/lib/v2/xjtu/std.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/xkb/index.js b/lib/v2/xkb/index.js
index 4ed17b11f..f483debd0 100644
--- a/lib/v2/xkb/index.js
+++ b/lib/v2/xkb/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.contentUrl, async () => {
+ cache.tryGet(item.contentUrl, async () => {
const detailResponse = await got({
method: 'get',
url: item.contentUrl,
diff --git a/lib/v2/xmnn/epaper.js b/lib/v2/xmnn/epaper.js
index b5dc2857c..b366161af 100644
--- a/lib/v2/xmnn/epaper.js
+++ b/lib/v2/xmnn/epaper.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -59,7 +60,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/xmnn/news.js b/lib/v2/xmnn/news.js
index 0e9fc9cd1..a3fe7ac73 100644
--- a/lib/v2/xmnn/news.js
+++ b/lib/v2/xmnn/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/xmut/jwc/bkjw.js b/lib/v2/xmut/jwc/bkjw.js
index e322dd90a..fcd1c1259 100644
--- a/lib/v2/xmut/jwc/bkjw.js
+++ b/lib/v2/xmut/jwc/bkjw.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
.get();
const items = await Promise.all(
itemsArray.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link, {
headers: {
referer: xmut,
diff --git a/lib/v2/xmut/jwc/yjs.js b/lib/v2/xmut/jwc/yjs.js
index a1222d919..a39ccc618 100644
--- a/lib/v2/xmut/jwc/yjs.js
+++ b/lib/v2/xmut/jwc/yjs.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
});
const itemPromises = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
referer: xmut,
diff --git a/lib/v2/xsijishe/forum.js b/lib/v2/xsijishe/forum.js
index 8e0879ec0..b178f7b3d 100644
--- a/lib/v2/xsijishe/forum.js
+++ b/lib/v2/xsijishe/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
});
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const resp = await got(item.link);
const $ = load(resp.data);
const firstViewBox = $('.t_f').first();
diff --git a/lib/v2/xsijishe/rank.js b/lib/v2/xsijishe/rank.js
index ed2aaf334..2a836dc0b 100644
--- a/lib/v2/xsijishe/rank.js
+++ b/lib/v2/xsijishe/rank.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const baseUrl = 'https://xsijishe.com';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
});
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const resp = await got(item.link);
const $ = load(resp.data);
const firstViewBox = $('.t_f').first();
diff --git a/lib/v2/xueqiu/stock-comments.js b/lib/v2/xueqiu/stock-comments.js
index 869261f0d..abe481fbd 100644
--- a/lib/v2/xueqiu/stock-comments.js
+++ b/lib/v2/xueqiu/stock-comments.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
});
// 获取stock_name
- const stock_name = await ctx.cache.tryGet(`stock_name_${id}`, async () => {
+ const stock_name = await cache.tryGet(`stock_name_${id}`, async () => {
const res = await got({
method: 'get',
url: `https://xueqiu.com/S/${id}`,
diff --git a/lib/v2/xueqiu/today.js b/lib/v2/xueqiu/today.js
index 0d533b105..fb3f76ecd 100644
--- a/lib/v2/xueqiu/today.js
+++ b/lib/v2/xueqiu/today.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/xueqiu/user.js b/lib/v2/xueqiu/user.js
index 00211b928..7eb29e669 100644
--- a/lib/v2/xueqiu/user.js
+++ b/lib/v2/xueqiu/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const queryString = require('query-string');
import { parseDate } from '@/utils/parse-date';
@@ -41,7 +42,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.map((item) =>
- ctx.cache.tryGet(item.target, async () => {
+ cache.tryGet(item.target, async () => {
const detailResponse = await got({
method: 'get',
url: rootUrl + item.target,
diff --git a/lib/v2/xys/new.js b/lib/v2/xys/new.js
index 2f76aa8dd..afb3790c8 100644
--- a/lib/v2/xys/new.js
+++ b/lib/v2/xys/new.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@@ -40,7 +41,7 @@ module.exports = async (ctx) => {
items
.filter((item) => !item.link.endsWith('.zip'))
.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const youTube = /(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w-]+)&?/g;
const matchYoutube = item.link.match(youTube);
diff --git a/lib/v2/yahoo/news/tw/index.js b/lib/v2/yahoo/news/tw/index.js
index c7f0f3e1e..6a7a7104e 100644
--- a/lib/v2/yahoo/news/tw/index.js
+++ b/lib/v2/yahoo/news/tw/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getArchive, getCategories, parseList, parseItem } = require('./utils');
module.exports = async (ctx) => {
@@ -7,13 +8,13 @@ module.exports = async (ctx) => {
}
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20;
- const categoryMap = await getCategories(region, ctx.cache.tryGet);
+ const categoryMap = await getCategories(region, cache.tryGet);
const tag = category ? categoryMap[category].yctMap : null;
const response = await getArchive(region, limit, tag);
const list = parseList(region, response);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `Yahoo 新聞 - ${category ? categoryMap[category].name : '所有類別'}`,
diff --git a/lib/v2/yahoo/news/tw/provider-helper.js b/lib/v2/yahoo/news/tw/provider-helper.js
index e6cd72b67..1760807dc 100644
--- a/lib/v2/yahoo/news/tw/provider-helper.js
+++ b/lib/v2/yahoo/news/tw/provider-helper.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getProviderList } = require('./utils');
module.exports = async (ctx) => {
@@ -6,7 +7,7 @@ module.exports = async (ctx) => {
throw new Error(`Unknown region: ${region}`);
}
- const providerList = await getProviderList(region, ctx.cache.tryGet);
+ const providerList = await getProviderList(region, cache.tryGet);
const items = providerList.map((provider) => ({
...provider,
diff --git a/lib/v2/yahoo/news/tw/provider.js b/lib/v2/yahoo/news/tw/provider.js
index 839e959f5..b8b983a31 100644
--- a/lib/v2/yahoo/news/tw/provider.js
+++ b/lib/v2/yahoo/news/tw/provider.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
const { getArchive, getProviderList, parseList, parseItem } = require('./utils');
module.exports = async (ctx) => {
@@ -7,13 +8,13 @@ module.exports = async (ctx) => {
}
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20;
- const providerList = await getProviderList(region, ctx.cache.tryGet);
+ const providerList = await getProviderList(region, cache.tryGet);
const provider = providerList.find((p) => p.key === providerId);
const response = await getArchive(region, limit, null, providerId);
const list = parseList(region, response);
- const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
+ const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));
ctx.set('data', {
title: `Yahoo 新聞 - ${provider?.title ?? ''}`,
diff --git a/lib/v2/yahoo/news/us/index.js b/lib/v2/yahoo/news/us/index.js
index 88c458842..7c6cfe9af 100644
--- a/lib/v2/yahoo/news/us/index.js
+++ b/lib/v2/yahoo/news/us/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
import { load } from 'cheerio';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
const filteredItems = feed.items.filter((item) => !item.link.includes('promotions') && new URL(item.link).hostname.match(/.*\.yahoo\.com$/));
const items = await Promise.all(
filteredItems.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/yangtzeu/dongke.js b/lib/v2/yangtzeu/dongke.js
index 6ba360171..cd5d289c8 100644
--- a/lib/v2/yangtzeu/dongke.js
+++ b/lib/v2/yangtzeu/dongke.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/ycwb/index.js b/lib/v2/ycwb/index.js
index a3ca6a343..8f781f6c9 100644
--- a/lib/v2/ycwb/index.js
+++ b/lib/v2/ycwb/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -27,7 +28,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/yicai/author.js b/lib/v2/yicai/author.js
index 2976c939a..0e3f6d247 100644
--- a/lib/v2/yicai/author.js
+++ b/lib/v2/yicai/author.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const $ = load(response.data);
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: `第一财经一财号 - ${$('title').text()}`,
diff --git a/lib/v2/yicai/dt.js b/lib/v2/yicai/dt.js
index 423241823..c33381dd8 100644
--- a/lib/v2/yicai/dt.js
+++ b/lib/v2/yicai/dt.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -54,7 +55,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);
diff --git a/lib/v2/yicai/feed.js b/lib/v2/yicai/feed.js
index 3bf852997..8607127d3 100644
--- a/lib/v2/yicai/feed.js
+++ b/lib/v2/yicai/feed.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const $ = load(response.data);
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: `第一财经主题 - ${$('title').text()}`,
diff --git a/lib/v2/yicai/headline.js b/lib/v2/yicai/headline.js
index 5045263a2..324309d24 100644
--- a/lib/v2/yicai/headline.js
+++ b/lib/v2/yicai/headline.js
@@ -1,9 +1,10 @@
+import cache from '@/utils/cache';
const { rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
const apiUrl = `${rootUrl}/api/ajax/getlistbycid?cid=48&type=1&page=1&pagesize=${ctx.req.query('limit') ?? 30}`;
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: '第一财经 - 头条',
diff --git a/lib/v2/yicai/latest.js b/lib/v2/yicai/latest.js
index b03b24291..175d19141 100644
--- a/lib/v2/yicai/latest.js
+++ b/lib/v2/yicai/latest.js
@@ -1,9 +1,10 @@
+import cache from '@/utils/cache';
const { rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
const apiUrl = `${rootUrl}/api/ajax/getlatest?page=1&pagesize=${ctx.req.query('limit') ?? 30}`;
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: '第一财经 - 最新',
diff --git a/lib/v2/yicai/news.js b/lib/v2/yicai/news.js
index c4cd927ef..7bf9ac863 100644
--- a/lib/v2/yicai/news.js
+++ b/lib/v2/yicai/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, ProcessItems } = require('./utils');
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const currentUrl = `${rootUrl}/news${id ? `/${channel.slug}` : ''}`;
const apiUrl = `${rootUrl}/api/ajax/${id ? `getlistbycid?cid=${channel.id}` : 'getjuhelist?action=news'}&page=1&pagesize=${ctx.req.query('limit') ?? 30}`;
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: `第一财经 - ${channel?.name ?? '新闻'}`,
diff --git a/lib/v2/yicai/video.js b/lib/v2/yicai/video.js
index 38e8761bf..6c699cd74 100644
--- a/lib/v2/yicai/video.js
+++ b/lib/v2/yicai/video.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { rootUrl, ProcessItems } = require('./utils');
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const currentUrl = `${rootUrl}/video${id ? `/${channel.slug}` : ''}`;
const apiUrl = `${rootUrl}/api/ajax/${id ? `getlistbycid?cid=${channel.id}` : 'getjuhelist?action=video'}&page=1&pagesize=${ctx.req.query('limit') ?? 30}`;
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: `第一财经 - ${channel?.name ?? '视听'}`,
diff --git a/lib/v2/yicai/vip.js b/lib/v2/yicai/vip.js
index c8c674341..1fa65936f 100644
--- a/lib/v2/yicai/vip.js
+++ b/lib/v2/yicai/vip.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -16,7 +17,7 @@ module.exports = async (ctx) => {
const $ = load(response.data);
- const items = await ProcessItems(apiUrl, ctx.cache.tryGet);
+ const items = await ProcessItems(apiUrl, cache.tryGet);
ctx.set('data', {
title: `第一财经VIP频道 - ${$('title').text()}`,
diff --git a/lib/v2/ymgal/article.js b/lib/v2/ymgal/article.js
index 4eba3c333..8e60c20a3 100644
--- a/lib/v2/ymgal/article.js
+++ b/lib/v2/ymgal/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
data.map((item) => {
const itemUrl = host + '/co/article/' + item.topicId;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const result = await got(itemUrl);
const $ = load(result.data);
const description = $('article').html().trim();
diff --git a/lib/v2/yomiuri/news.js b/lib/v2/yomiuri/news.js
index 5868344a0..77f2cb1b9 100644
--- a/lib/v2/yomiuri/news.js
+++ b/lib/v2/yomiuri/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -44,7 +45,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
if (item.locked) {
return item;
}
diff --git a/lib/v2/youtube/charts.js b/lib/v2/youtube/charts.js
index 584a73faf..230238885 100644
--- a/lib/v2/youtube/charts.js
+++ b/lib/v2/youtube/charts.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const { renderDescription } = require('./utils');
import { config } from '@/config';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const { category = 'TopVideos', country } = ctx.params;
const embed = !ctx.req.param('embed');
- const { content } = await ctx.cache.tryGet(
+ const { content } = await cache.tryGet(
`youtube:charts:${country ?? 'global'}`,
async () => {
const { data } = await got.post('https://charts.youtube.com/youtubei/v1/browse', {
diff --git a/lib/v2/youzhiyouxing/materials.js b/lib/v2/youzhiyouxing/materials.js
index c62fe40a2..15880f85e 100644
--- a/lib/v2/youzhiyouxing/materials.js
+++ b/lib/v2/youzhiyouxing/materials.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/yuque/book.js b/lib/v2/yuque/book.js
index eef38a5bc..aa820de69 100644
--- a/lib/v2/yuque/book.js
+++ b/lib/v2/yuque/book.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -39,7 +40,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const {
data: { data },
} = await got(`${baseUrl}/api/docs/${item.slug}`, {
diff --git a/lib/v2/yxdown/news.js b/lib/v2/yxdown/news.js
index 623500ccd..560bdd738 100644
--- a/lib/v2/yxdown/news.js
+++ b/lib/v2/yxdown/news.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
cookie,
diff --git a/lib/v2/yxdown/recommend.js b/lib/v2/yxdown/recommend.js
index 2e24a5d28..9c07a9eeb 100644
--- a/lib/v2/yxdown/recommend.js
+++ b/lib/v2/yxdown/recommend.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
headers: {
cookie,
diff --git a/lib/v2/yxrb/home.js b/lib/v2/yxrb/home.js
index 5df7bcb5d..854699fda 100644
--- a/lib/v2/yxrb/home.js
+++ b/lib/v2/yxrb/home.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
diff --git a/lib/v2/yyets/article.js b/lib/v2/yyets/article.js
index 76eff6cfe..20da2d07a 100644
--- a/lib/v2/yyets/article.js
+++ b/lib/v2/yyets/article.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);
diff --git a/lib/v2/yystv/category.js b/lib/v2/yystv/category.js
index 3427c872d..4720692ad 100644
--- a/lib/v2/yystv/category.js
+++ b/lib/v2/yystv/category.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -43,7 +44,7 @@ module.exports = async (ctx) => {
function getDescription(items) {
return Promise.all(
items.map(async (currentValue) => {
- currentValue.description = await ctx.cache.tryGet(currentValue.link, async () => {
+ currentValue.description = await cache.tryGet(currentValue.link, async () => {
const r = await got({
url: currentValue.link,
method: 'get',
diff --git a/lib/v2/zaker/index.js b/lib/v2/zaker/index.js
index 9b1c1ed6d..9307958f9 100644
--- a/lib/v2/zaker/index.js
+++ b/lib/v2/zaker/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
url: item.link,
headers: {
diff --git a/lib/v2/zaobao/util.js b/lib/v2/zaobao/util.js
index b085a9fe4..c14f2f305 100644
--- a/lib/v2/zaobao/util.js
+++ b/lib/v2/zaobao/util.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseRelativeDate } from '@/utils/parse-date';
@@ -74,7 +75,7 @@ const parseList = async (ctx, sectionUrl) => {
link = baseUrl + link;
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const article = await got_ins.get(link);
const $1 = load(article.data);
diff --git a/lib/v2/zcool/discover.js b/lib/v2/zcool/discover.js
index 22789006d..d016c06a9 100644
--- a/lib/v2/zcool/discover.js
+++ b/lib/v2/zcool/discover.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -113,7 +114,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/zcool/top.js b/lib/v2/zcool/top.js
index ab6b2dd78..ebf6de680 100644
--- a/lib/v2/zcool/top.js
+++ b/lib/v2/zcool/top.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/zcool/user.js b/lib/v2/zcool/user.js
index f20814196..024bcd076 100644
--- a/lib/v2/zcool/user.js
+++ b/lib/v2/zcool/user.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
workList.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
diff --git a/lib/v2/zhibo8/forum.js b/lib/v2/zhibo8/forum.js
index 66c296419..fe4eb8e9d 100644
--- a/lib/v2/zhibo8/forum.js
+++ b/lib/v2/zhibo8/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -18,7 +19,7 @@ module.exports = async (ctx) => {
item = $(item);
const a = item.find('td:nth-child(1) > a:nth-child(2)');
const link = 'https://bbs.zhibo8.cc' + a.attr('href');
- return ctx.cache.tryGet(link, async () => {
+ return cache.tryGet(link, async () => {
const title = a.text();
const author = item.find('td:nth-child(2) cite a').text();
const date = item.find('td:nth-child(2) em').text();
diff --git a/lib/v2/zhibo8/more.js b/lib/v2/zhibo8/more.js
index 2ed0f9090..c3f45cb20 100644
--- a/lib/v2/zhibo8/more.js
+++ b/lib/v2/zhibo8/more.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@@ -56,7 +57,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const res = await got(item.link);
const content = load(res.data);
diff --git a/lib/v2/zhihu/activities.js b/lib/v2/zhihu/activities.js
index c7957f8ae..a9a5e6180 100644
--- a/lib/v2/zhihu/activities.js
+++ b/lib/v2/zhihu/activities.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -12,7 +13,7 @@ module.exports = async (ctx) => {
// require users to set the cookie in environmental variables anymore.
// fisrt: get cookie(dc_0) from zhihu.com
- const cookie_mes = await ctx.cache.tryGet('zhihu:cookies:d_c0', async () => {
+ const cookie_mes = await cache.tryGet('zhihu:cookies:d_c0', async () => {
const response = await got(`https://www.zhihu.com/people/${id}`, {
headers: {
...utils.header,
diff --git a/lib/v2/zhihu/answers.js b/lib/v2/zhihu/answers.js
index 4eeff99e2..50965ca0b 100644
--- a/lib/v2/zhihu/answers.js
+++ b/lib/v2/zhihu/answers.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -19,7 +20,7 @@ module.exports = async (ctx) => {
let name = data[0].author.name;
if (name === '知乎用户') {
- const userProfile = await ctx.cache.tryGet(`zhihu:profile:${id}`, async () => {
+ const userProfile = await cache.tryGet(`zhihu:profile:${id}`, async () => {
const apiPath = `/api/v4/members/${id}`;
const { data } = await got({
diff --git a/lib/v2/zhihu/collection.js b/lib/v2/zhihu/collection.js
index 87b1d5e7a..e57d08de6 100644
--- a/lib/v2/zhihu/collection.js
+++ b/lib/v2/zhihu/collection.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const utils = require('./utils');
@@ -25,7 +26,7 @@ module.exports = async (ctx) => {
const offsetList = [...Array.from({ length: Math.round(totals / 20) }).keys()].map((item) => item * 20).slice(1);
const otherList = await Promise.all(
offsetList.map((offset) =>
- ctx.cache.tryGet(`https://www.zhihu.com/api/v4/collections/${id}/items?offset=${offset}&limit=20`, async () => {
+ cache.tryGet(`https://www.zhihu.com/api/v4/collections/${id}/items?offset=${offset}&limit=20`, async () => {
const response = await got({
method: 'get',
url: `https://www.zhihu.com/api/v4/collections/${id}/items?offset=${offset}&limit=20`,
diff --git a/lib/v2/zhihu/daily-section.js b/lib/v2/zhihu/daily-section.js
index a809e13df..26b711208 100644
--- a/lib/v2/zhihu/daily-section.js
+++ b/lib/v2/zhihu/daily-section.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -26,7 +27,7 @@ module.exports = async (ctx) => {
description: '',
link: 'https://daily.zhihu.com/story/' + story.id,
};
- return ctx.cache.tryGet(`https://daily.zhihu.com/story/${story.id}`, async () => {
+ return cache.tryGet(`https://daily.zhihu.com/story/${story.id}`, async () => {
const storyDetail = await got({
method: 'get',
url,
diff --git a/lib/v2/zhihu/daily.js b/lib/v2/zhihu/daily.js
index f724f86d8..5ede28817 100644
--- a/lib/v2/zhihu/daily.js
+++ b/lib/v2/zhihu/daily.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -53,7 +54,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
articleList.map(async (item) => {
const url = `${api}/${item.storyId}`;
- const description = await ctx.cache.tryGet(item.link, async () => {
+ const description = await cache.tryGet(item.link, async () => {
const storyDetail = await got({
method: 'get',
url,
diff --git a/lib/v2/zhihu/question.js b/lib/v2/zhihu/question.js
index c113315ec..6c6e5cc85 100644
--- a/lib/v2/zhihu/question.js
+++ b/lib/v2/zhihu/question.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import md5 from '@/utils/md5';
@@ -14,7 +15,7 @@ module.exports = async (ctx) => {
// require users to set the cookie in environmental variables anymore.
// fisrt: get cookie(dc_0) from zhihu.com
- const cookie_mes = await ctx.cache.tryGet('zhihu:cookies:d_c0', async () => {
+ const cookie_mes = await cache.tryGet('zhihu:cookies:d_c0', async () => {
const response = await got({
method: 'get',
url: `https://www.zhihu.com/question/${questionId}`,
diff --git a/lib/v2/zhihu/topic.js b/lib/v2/zhihu/topic.js
index c17d8043c..e4e5022e7 100644
--- a/lib/v2/zhihu/topic.js
+++ b/lib/v2/zhihu/topic.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import { parseDate } from '@/utils/parse-date';
@@ -8,7 +9,7 @@ module.exports = async (ctx) => {
const { topicId, isTop = false } = ctx.params;
const link = `https://www.zhihu.com/topic/${topicId}/${isTop ? 'top-answers' : 'newest'}`;
- const cookieDc0 = await ctx.cache.tryGet('zhihu:cookies:d_c0', async () => {
+ const cookieDc0 = await cache.tryGet('zhihu:cookies:d_c0', async () => {
const { headers } = await got(link, {
headers: {
...utils.header,
@@ -24,7 +25,7 @@ module.exports = async (ctx) => {
});
const cookie = `d_c0=${cookieDc0}`;
- const topicMeta = await ctx.cache.tryGet(`zhihu:topic:${topicId}`, async () => {
+ const topicMeta = await cache.tryGet(`zhihu:topic:${topicId}`, async () => {
const { data: response } = await got(`https://www.zhihu.com/api/v4/topics/${topicId}/intro`, {
searchParams: {
include: 'content.meta.content.photos',
diff --git a/lib/v2/zhihu/xhu/auth.js b/lib/v2/zhihu/xhu/auth.js
index 43a8ab89e..11713743e 100644
--- a/lib/v2/zhihu/xhu/auth.js
+++ b/lib/v2/zhihu/xhu/auth.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
const ProcessCookie = (cookie) => cookie.map((cookie) => cookie.split(';')[0]).join('; ');
@@ -9,9 +10,9 @@ const ProcessNewCookie = (oldCookie, newCookie) => {
};
module.exports = {
- getCookie: (ctx) => {
+ getCookie: () => {
const key = 'zhihu-xhu-cookie';
- return ctx.cache.tryGet(key, async () => {
+ return cache.tryGet(key, async () => {
// Get udid
const udidResponse = await got({
method: 'get',
diff --git a/lib/v2/zhitongcaijing/index.js b/lib/v2/zhitongcaijing/index.js
index 4d6a433a7..93fae33a4 100644
--- a/lib/v2/zhitongcaijing/index.js
+++ b/lib/v2/zhitongcaijing/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -89,7 +90,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/zhiy/post.js b/lib/v2/zhiy/post.js
index 05a973016..39cdf1a16 100644
--- a/lib/v2/zhiy/post.js
+++ b/lib/v2/zhiy/post.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const { baseUrl, fetchUserDate } = require('./utils');
@@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data: postMeta } = await got(`${baseUrl}/api/app/share/posts/${item.shareMD5}`);
const {
diff --git a/lib/v2/zhubai/top20.js b/lib/v2/zhubai/top20.js
index 4649d1d5f..6556063b0 100644
--- a/lib/v2/zhubai/top20.js
+++ b/lib/v2/zhubai/top20.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
@@ -30,7 +31,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const matches = item.link.match(/\/(?:fp|pq|pu)\/([\w-]+)\/(\d+)/);
const { data } = await got(`https://${matches[1]}.zhubai.love/api/posts/${matches[2]}`);
diff --git a/lib/v2/zimuxia/index.js b/lib/v2/zimuxia/index.js
index b4a6b5ab1..e189e2673 100644
--- a/lib/v2/zimuxia/index.js
+++ b/lib/v2/zimuxia/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@@ -32,7 +33,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/zjgtjy/index.js b/lib/v2/zjgtjy/index.js
index 9490d1f10..a7d980952 100644
--- a/lib/v2/zjgtjy/index.js
+++ b/lib/v2/zjgtjy/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
module.exports = async (ctx) => {
@@ -15,7 +16,7 @@ module.exports = async (ctx) => {
const pageUrl = `https://td.zjgtjy.cn:8553/devops/noticeInfo/queryNoticeLandContentDetails?noticeId=${item.GGID}&transactionMode=${item.JYFS}`;
const pageLink = `https://td.zjgtjy.cn/view/trade/announcement/detail?id=${item.GGID}&category=${item.ZYLB}&type=${item.JYFS}`;
- const desc = await ctx.cache.tryGet(pageUrl, async () => {
+ const desc = await cache.tryGet(pageUrl, async () => {
let desc = await got({
method: 'get',
url: pageUrl,
diff --git a/lib/v2/zjol/paper.js b/lib/v2/zjol/paper.js
index 48a000a85..0d3ed7259 100644
--- a/lib/v2/zjol/paper.js
+++ b/lib/v2/zjol/paper.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -58,7 +59,7 @@ module.exports = async (ctx) => {
.filter((a) => (id === 'jnyb' ? /\?div=1$/.test(a) : true))
.slice(0, limit)
.map((link) =>
- ctx.cache.tryGet(link, async () => {
+ cache.tryGet(link, async () => {
const detailResponse = await got({
method: 'get',
url: link,
diff --git a/lib/v2/zju/cst/index.js b/lib/v2/zju/cst/index.js
index 58a63b001..53fd97ac2 100644
--- a/lib/v2/zju/cst/index.js
+++ b/lib/v2/zju/cst/index.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -61,7 +62,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/zju/list.js b/lib/v2/zju/list.js
index b6fb3ddee..29bd4e293 100644
--- a/lib/v2/zju/list.js
+++ b/lib/v2/zju/list.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -35,7 +36,7 @@ module.exports = async (ctx) => {
const title = info.title;
const date = info.date;
const itemUrl = new URL(info.link, host).href;
- return ctx.cache.tryGet(itemUrl, async () => {
+ return cache.tryGet(itemUrl, async () => {
const response = await got({
method: 'get',
url: itemUrl,
diff --git a/lib/v2/zodgame/forum.js b/lib/v2/zodgame/forum.js
index 3547e1f3f..49bd7a548 100644
--- a/lib/v2/zodgame/forum.js
+++ b/lib/v2/zodgame/forum.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { config } from '@/config';
import { parseDate } from '@/utils/parse-date';
@@ -46,7 +47,7 @@ module.exports = async (ctx) => {
// fulltext
const items = await Promise.all(
ThreadList.map((item) =>
- ctx.cache.tryGet(item.tid, async () => {
+ cache.tryGet(item.tid, async () => {
const threadResponse = await got({
method: 'get',
url: `${rootUrl}/api/mobile/index.php?version=4&module=viewthread&tid=${item.tid}`,
diff --git a/lib/v2/zuel/notice.js b/lib/v2/zuel/notice.js
index 034a3f8c5..9cf3f3845 100644
--- a/lib/v2/zuel/notice.js
+++ b/lib/v2/zuel/notice.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
diff --git a/lib/v2/zuvio/boards.js b/lib/v2/zuvio/boards.js
index 6d5fbd469..7986c2b5a 100644
--- a/lib/v2/zuvio/boards.js
+++ b/lib/v2/zuvio/boards.js
@@ -1,7 +1,8 @@
+import cache from '@/utils/cache';
const { getBoards, rootUrl } = require('./utils');
module.exports = async (ctx) => {
- const items = await getBoards(ctx.cache.tryGet);
+ const items = await getBoards(cache.tryGet);
ctx.set('data', {
title: 'Zuvio 校園話題列表 - 大學生論壇',
diff --git a/lib/v2/zuvio/student5.js b/lib/v2/zuvio/student5.js
index 6c8de5c15..c5690d3a6 100644
--- a/lib/v2/zuvio/student5.js
+++ b/lib/v2/zuvio/student5.js
@@ -1,3 +1,4 @@
+import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@@ -5,7 +6,7 @@ const { token, apiUrl, rootUrl, renderDesc, getBoards } = require('./utils');
module.exports = async (ctx) => {
const { board = '' } = ctx.params;
- const title = board ? (await getBoards(ctx.cache.tryGet)).find((i) => i.boardId === board).title : '全部';
+ const title = board ? (await getBoards(cache.tryGet)).find((i) => i.boardId === board).title : '全部';
const { data } = await got(`${apiUrl}/article`, {
searchParams: {
@@ -31,7 +32,7 @@ module.exports = async (ctx) => {
await Promise.all(
items.map((item) =>
- ctx.cache.tryGet(item.link, async () => {
+ cache.tryGet(item.link, async () => {
const { data } = await got(item.api, {
searchParams: {
api_token: token,