mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: use contentExpire
This commit is contained in:
@@ -63,7 +63,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -60,7 +60,7 @@ module.exports = async (ctx) => {
|
||||
description: content,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
link: url,
|
||||
guid: url,
|
||||
};
|
||||
ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
|
||||
guid: itemUrl,
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
description: $('article .transcript-content').html(),
|
||||
pubDate: new Date($('article header .entry-meta time').text()),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
|
||||
guid: itemUrl,
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = async (ctx) => {
|
||||
description: content.html(),
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -57,7 +57,7 @@ module.exports = async (ctx) => {
|
||||
pubDate: new Date(datelist[index].replace(/(\d+) 年 (\d+) 月 (\d+) 日/, '$1-$2-$3')).toISOString(),
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -96,7 +96,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = async (ctx) => {
|
||||
pubDate: new Date().toISOString(),
|
||||
link,
|
||||
};
|
||||
ctx.cache.set(link, JSON.stringify(single), 2 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = {
|
||||
}),
|
||||
});
|
||||
name = nameResponse.data.data.name;
|
||||
ctx.cache.set(key, name, 24 * 60 * 60);
|
||||
ctx.cache.set(key, name);
|
||||
}
|
||||
return name;
|
||||
},
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
},
|
||||
});
|
||||
liveID = liveIDResponse.data.data.room_id;
|
||||
ctx.cache.set(key, liveID, 24 * 60 * 60);
|
||||
ctx.cache.set(key, liveID);
|
||||
}
|
||||
return liveID;
|
||||
},
|
||||
@@ -53,7 +53,7 @@ module.exports = {
|
||||
},
|
||||
});
|
||||
name = nameResponse.data.data.info.uname;
|
||||
ctx.cache.set(key, name, 24 * 60 * 60);
|
||||
ctx.cache.set(key, name);
|
||||
}
|
||||
return name;
|
||||
},
|
||||
@@ -71,7 +71,7 @@ module.exports = {
|
||||
const $ = cheerio.load(responseHtml);
|
||||
name = $('title').text();
|
||||
name = name.substr(0, name.indexOf('_哔哩哔哩'));
|
||||
ctx.cache.set(key, name, 24 * 60 * 60);
|
||||
ctx.cache.set(key, name);
|
||||
}
|
||||
return name;
|
||||
},
|
||||
@@ -95,7 +95,7 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
}
|
||||
ctx.cache.set(key, name, 24 * 60 * 60);
|
||||
ctx.cache.set(key, name);
|
||||
}
|
||||
if (!name) {
|
||||
name = 'Unknown';
|
||||
@@ -117,7 +117,7 @@ module.exports = {
|
||||
cid = cidResponse.data.data.pages[pid - 1].cid;
|
||||
}
|
||||
if (!cid) {
|
||||
ctx.cache.set(key, cid, 24 * 60 * 60);
|
||||
ctx.cache.set(key, cid);
|
||||
}
|
||||
}
|
||||
return cid;
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = async (ctx) => {
|
||||
guid: itemUrl,
|
||||
description: $d('#main .content').html(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
|
||||
link,
|
||||
guid: link,
|
||||
};
|
||||
ctx.cache.set(link, JSON.stringify(item), 5 * 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(item));
|
||||
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
|
||||
@@ -86,7 +86,7 @@ module.exports = async (category, ctx) => {
|
||||
}
|
||||
|
||||
item.description = description;
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
@@ -2,7 +2,6 @@ const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const BASE_URL = 'https://minecraft.curseforge.com/';
|
||||
const CACHE_TIME = 24 * 60 * 60;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { project } = ctx.params;
|
||||
@@ -37,7 +36,7 @@ module.exports = async (ctx) => {
|
||||
document.pubDate = new Date(Number($item('.standard-datetime').attr('data-epoch')) * 1000).toUTCString();
|
||||
document.guid = $item('.md5').text();
|
||||
|
||||
await ctx.cache.set(document.link, JSON.stringify(document), CACHE_TIME);
|
||||
await ctx.cache.set(document.link, JSON.stringify(document));
|
||||
|
||||
return document;
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
});
|
||||
item.description = $('.article-content').html();
|
||||
ctx.cache.set(key, item.description, 12 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
});
|
||||
item.description = $('.article-content').html() || '内容已删除或未通过审核';
|
||||
ctx.cache.set(key, item.description, 12 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = async (ctx) => {
|
||||
guid: link,
|
||||
link,
|
||||
};
|
||||
await ctx.cache.set(link, cache, 24 * 60 * 60);
|
||||
await ctx.cache.set(link, cache);
|
||||
return item;
|
||||
});
|
||||
|
||||
|
||||
@@ -57,14 +57,10 @@ module.exports = async (ctx) => {
|
||||
|
||||
item.description = description;
|
||||
item.pubDate = pubDate;
|
||||
ctx.cache.set(
|
||||
key,
|
||||
{
|
||||
pubDate,
|
||||
description,
|
||||
},
|
||||
24 * 60 * 60
|
||||
);
|
||||
ctx.cache.set(key, {
|
||||
pubDate,
|
||||
description,
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = async (ctx) => {
|
||||
8
|
||||
);
|
||||
|
||||
ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: '懂球帝早报',
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = async (ctx) => {
|
||||
8
|
||||
);
|
||||
|
||||
ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: `懂球帝专题-${id}`,
|
||||
|
||||
@@ -64,7 +64,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -47,8 +47,8 @@ module.exports = async (ctx) => {
|
||||
.substr(0, 18)
|
||||
).toUTCString();
|
||||
|
||||
ctx.cache.set(description_key, single.description, 60 * 60);
|
||||
ctx.cache.set(pubDate_key, single.pubDate, 60 * 60);
|
||||
ctx.cache.set(description_key, single.description);
|
||||
ctx.cache.set(pubDate_key, single.pubDate);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
|
||||
description: result.description,
|
||||
pubDate: result.pubDate,
|
||||
};
|
||||
ctx.cache.set(item.url, JSON.stringify(single), 2 * 60 * 60);
|
||||
ctx.cache.set(item.url, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = async (ctx) => {
|
||||
description,
|
||||
pubDate: pubDate.toUTCString(),
|
||||
};
|
||||
ctx.cache.set(item.url, JSON.stringify(single), 2 * 60 * 60);
|
||||
ctx.cache.set(item.url, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ async function load(link, ctx) {
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const description = $('div#Zoom').html();
|
||||
await ctx.cache.set(link, description, 24 * 60 * 60);
|
||||
await ctx.cache.set(link, description);
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = async (ctx) => {
|
||||
.replace(')', '')
|
||||
).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -86,7 +86,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: pubDate,
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -71,7 +71,7 @@ module.exports = async (ctx) => {
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
$('section .content script').remove();
|
||||
$('section .content #discourse-comments').remove();
|
||||
const html = $('section .content').html();
|
||||
ctx.cache.set(link, html, 3 * 60 * 60);
|
||||
ctx.cache.set(link, html);
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
|
||||
const contentData = await axios.get(link);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('.TRS_Editor').html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
const title = $a.text();
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = async (ctx) => {
|
||||
const contentData = await axios.get(href);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('#UCAP-CONTENT').html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
|
||||
const contentData = await axios.get(href.startsWith('/zhengce') ? `http://www.gov.cn${href}` : href);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('#UCAP-CONTENT').html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
|
||||
const $ = cheerio.load(data);
|
||||
item.pubDate = $('time').attr('datetime');
|
||||
item.description = $('.post-body').html();
|
||||
ctx.cache.set(key, item.description, 6 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
|
||||
item: items,
|
||||
};
|
||||
// one hour cache
|
||||
ctx.cache.set(url, JSON.stringify(result), 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify(result));
|
||||
|
||||
ctx.state.data = result;
|
||||
};
|
||||
|
||||
@@ -76,7 +76,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
+14
-18
@@ -10,26 +10,22 @@ const ProcessFeed = async (list, cache) => {
|
||||
list.map(async (e) => {
|
||||
const link = url.resolve(host, e);
|
||||
|
||||
const single = await cache.tryGet(
|
||||
link,
|
||||
async () => {
|
||||
const response = await axios.get(link);
|
||||
const single = await cache.tryGet(link, async () => {
|
||||
const response = await axios.get(link);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
$('.neirong-shouquan, .neirong-shouquan-public').remove();
|
||||
const $ = cheerio.load(response.data);
|
||||
$('.neirong-shouquan, .neirong-shouquan-public').remove();
|
||||
|
||||
return {
|
||||
title: $('.t-h1')
|
||||
.text()
|
||||
.trim(),
|
||||
description: $('.article-img-box').html() + $('.article-content-wrap').html(),
|
||||
pubDate: date($('.article-time').text(), 8),
|
||||
author: $('.article-author .author-name').text(),
|
||||
link,
|
||||
};
|
||||
},
|
||||
2 * 24 * 60 * 60
|
||||
);
|
||||
return {
|
||||
title: $('.t-h1')
|
||||
.text()
|
||||
.trim(),
|
||||
description: $('.article-img-box').html() + $('.article-content-wrap').html(),
|
||||
pubDate: date($('.article-time').text(), 8),
|
||||
author: $('.article-author .author-name').text(),
|
||||
link,
|
||||
};
|
||||
});
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = async (ctx) => {
|
||||
item.title = $('.c-dasheng_header__title').text();
|
||||
}
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(item), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(item));
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(pubDate).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
+25
-29
@@ -6,37 +6,33 @@ const ProcessFeed = async (list, cache) => {
|
||||
const items = await Promise.all(
|
||||
list.map(async (e) => {
|
||||
const uuid = e.uuid;
|
||||
const single = await cache.tryGet(
|
||||
uuid,
|
||||
async () => {
|
||||
const link = `https://www.infoq.cn/article/${uuid}`;
|
||||
const resp = await axios({
|
||||
method: 'post',
|
||||
url: detailUrl,
|
||||
headers: {
|
||||
Referer: link,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: {
|
||||
uuid: uuid,
|
||||
},
|
||||
});
|
||||
const single = await cache.tryGet(uuid, async () => {
|
||||
const link = `https://www.infoq.cn/article/${uuid}`;
|
||||
const resp = await axios({
|
||||
method: 'post',
|
||||
url: detailUrl,
|
||||
headers: {
|
||||
Referer: link,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: {
|
||||
uuid: uuid,
|
||||
},
|
||||
});
|
||||
|
||||
const data = resp.data.data;
|
||||
const author = data.author ? data.author.map((p) => p.nickname).join(',') : data.no_author;
|
||||
const pubDate = new Date();
|
||||
pubDate.setTime(data.publish_time);
|
||||
const data = resp.data.data;
|
||||
const author = data.author ? data.author.map((p) => p.nickname).join(',') : data.no_author;
|
||||
const pubDate = new Date();
|
||||
pubDate.setTime(data.publish_time);
|
||||
|
||||
return {
|
||||
title: data.article_title,
|
||||
description: data.content,
|
||||
pubDate,
|
||||
author: author,
|
||||
link,
|
||||
};
|
||||
},
|
||||
2 * 24 * 60 * 60
|
||||
);
|
||||
return {
|
||||
title: data.article_title,
|
||||
description: data.content,
|
||||
pubDate,
|
||||
author: author,
|
||||
link,
|
||||
};
|
||||
});
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
description = $('#content').html();
|
||||
}
|
||||
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
image: item.display_url,
|
||||
};
|
||||
|
||||
ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify([single]));
|
||||
return Promise.resolve([single]);
|
||||
} else if (item.__typename === 'GraphSidecar') {
|
||||
const response = await axios({
|
||||
@@ -46,7 +46,7 @@ module.exports = async (ctx) => {
|
||||
video: item.node.video_url,
|
||||
}));
|
||||
|
||||
ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
} else if (item.__typename === 'GraphVideo') {
|
||||
const response = await axios({
|
||||
@@ -59,7 +59,7 @@ module.exports = async (ctx) => {
|
||||
video: data.entry_data.PostPage[0].graphql.shortcode_media.video_url,
|
||||
};
|
||||
|
||||
ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify([single]));
|
||||
return Promise.resolve([single]);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
|
||||
image: item.display_url,
|
||||
};
|
||||
|
||||
ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify([single]));
|
||||
return Promise.resolve([single]);
|
||||
} else if (item.__typename === 'GraphSidecar') {
|
||||
const response = await axios({
|
||||
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
video: item.node.video_url,
|
||||
}));
|
||||
|
||||
ctx.cache.set(url, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
} else if (item.__typename === 'GraphVideo') {
|
||||
const response = await axios({
|
||||
@@ -60,7 +60,7 @@ module.exports = async (ctx) => {
|
||||
video: data.entry_data.PostPage[0].graphql.shortcode_media.video_url,
|
||||
};
|
||||
|
||||
ctx.cache.set(url, JSON.stringify([single]), 24 * 60 * 60);
|
||||
ctx.cache.set(url, JSON.stringify([single]));
|
||||
return Promise.resolve([single]);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -24,7 +24,7 @@ async function processReport(item, ctx) {
|
||||
description += `<img src="http://report.iresearch.cn/rimgs/${reportId}/${i}.jpg" rel="noreferrer"><br>`;
|
||||
}
|
||||
|
||||
await ctx.cache.set(apiUrl, description, 24 * 60 * 60);
|
||||
await ctx.cache.set(apiUrl, description);
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ const getDetail = async (link, ctx) => {
|
||||
screenData = null;
|
||||
}
|
||||
const detail = { actresses, filmTime, filmLast, filmEstabName, filmMakerbName, seriesName, directorName, code, screenData };
|
||||
ctx.cache.set(link, JSON.stringify(detail), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(detail));
|
||||
return detail;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const content = $('.article-view .article-main').html();
|
||||
out[indexList[i]].description = content;
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
if (description) {
|
||||
item.description = description;
|
||||
await ctx.cache.set(newsUrl, description, 24 * 60 * 60);
|
||||
await ctx.cache.set(newsUrl, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ module.exports = async (ctx) => {
|
||||
.text()
|
||||
).toUTCString();
|
||||
|
||||
ctx.cache.set(description_key, single.description, 60 * 60);
|
||||
ctx.cache.set(pubDate_key, single.pubDate, 60 * 60);
|
||||
ctx.cache.set(description_key, single.description);
|
||||
ctx.cache.set(pubDate_key, single.pubDate);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -58,7 +58,7 @@ module.exports = async (ctx) => {
|
||||
pubDate: new Date(info.date).toUTCString(),
|
||||
};
|
||||
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
const res = responses[i];
|
||||
const $ = cheerio.load(res.data);
|
||||
out[indexList[i]].description = $('.u-content').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
const res = responses[i];
|
||||
const $ = cheerio.load(res.data);
|
||||
out[indexList[i]].description = $('.u-content').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = async (ctx) => {
|
||||
description: article,
|
||||
};
|
||||
|
||||
ctx.cache.set(link, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
const res = responses[i];
|
||||
const $ = cheerio.load(res.data);
|
||||
out[indexList[i]].description = $('.u-content').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
const res = responses[i];
|
||||
const $ = cheerio.load(res.data);
|
||||
out[indexList[i]].description = $('.u-content').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
const cacheLength = 5;
|
||||
const cacheDays = 30;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type = 'release', device, region = 'cn' } = ctx.params;
|
||||
@@ -48,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
...oldPosts,
|
||||
];
|
||||
|
||||
await ctx.cache.set(cacheName, item.slice(0, cacheLength), cacheDays * 24 * 60 * 60);
|
||||
await ctx.cache.set(cacheName, item.slice(0, cacheLength));
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -94,7 +94,7 @@ async function buildRss($, paramType, ctx) {
|
||||
description = $page('.main')
|
||||
.find('.intro')
|
||||
.html();
|
||||
cache.set(key, description, 24 * 60 * 60);
|
||||
cache.set(key, description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
||||
const contentData = await axios.get(href);
|
||||
const $content = cheerio.load(contentData.data);
|
||||
description = $content('.newsbody').html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -60,7 +60,7 @@ module.exports = async (ctx) => {
|
||||
.text()
|
||||
.replace('时间:', '')
|
||||
).toUTCString();
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: '中国美术馆 -- 通知公告',
|
||||
|
||||
@@ -78,7 +78,7 @@ module.exports = async (ctx) => {
|
||||
.text()
|
||||
.replace('时间:', '')
|
||||
).toUTCString();
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: '中国美术馆 -- 展览预告',
|
||||
|
||||
@@ -65,7 +65,7 @@ module.exports = async (ctx) => {
|
||||
.text()
|
||||
.replace('时间:', '')
|
||||
).toUTCString();
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]));
|
||||
}
|
||||
}
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -65,7 +65,7 @@ module.exports = async (ctx) => {
|
||||
.text()
|
||||
.replace('时间:', '')
|
||||
).toUTCString();
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[i].link, JSON.stringify(out[i]));
|
||||
}
|
||||
}
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
|
||||
const data = storyDetail.data;
|
||||
const $ = cheerio.load(data);
|
||||
item.description = $('.td-post-content').html();
|
||||
ctx.cache.set(key, item.description, 12 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
|
||||
@@ -12,7 +12,7 @@ exports.getSimple = async (url) => {
|
||||
};
|
||||
|
||||
const MAX_DETAIL = 5;
|
||||
exports.getDetails = async (cache, simples) => Promise.all(simples.slice(0, MAX_DETAIL).map((simple) => cache.tryGet(simple.link, () => getDetail(simple), 24 * 60 * 60)));
|
||||
exports.getDetails = async (cache, simples) => Promise.all(simples.slice(0, MAX_DETAIL).map((simple) => cache.tryGet(simple.link, () => getDetail(simple))));
|
||||
|
||||
const parseSimpleDetail = ($ele) => {
|
||||
const link = resolve('https://nhentai.net', $ele.attr('href'));
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
link: link,
|
||||
};
|
||||
if (res.slice(0, 10).includes('正在手打中') === false) {
|
||||
ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(resultItem));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: date(date_value, 8),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -84,7 +84,7 @@ module.exports = async (ctx) => {
|
||||
item.author = content('a.__user')
|
||||
.find('span')
|
||||
.text();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
|
||||
const content = cheerio.load(detail.data);
|
||||
content('.ad-wrap').remove();
|
||||
item.description = content('#articleContent').html();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = async (ctx) => {
|
||||
const content = cheerio.load(detail.data);
|
||||
content('.ad-wrap').remove();
|
||||
item.description = content('#articleContent').html();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = async (ctx) => {
|
||||
};
|
||||
}
|
||||
|
||||
await ctx.cache.set(tracking, JSON.stringify(single), 1 * 60 * 60);
|
||||
await ctx.cache.set(tracking, JSON.stringify(single));
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
|
||||
@@ -10,7 +10,7 @@ module.exports = {
|
||||
url: `https://patchwork.kernel.org/api/patches/${id}/`,
|
||||
});
|
||||
name = patchDetail.data.name;
|
||||
ctx.cache.set(key, name, 24 * 60 * 60);
|
||||
ctx.cache.set(key, name);
|
||||
}
|
||||
return name;
|
||||
},
|
||||
|
||||
@@ -98,7 +98,7 @@ module.exports = async (ctx) => {
|
||||
.eq(0)
|
||||
.find('.message')
|
||||
.html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
|
||||
@@ -64,7 +64,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -61,7 +61,7 @@ module.exports = async (ctx) => {
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
$('.article-detail-ft').remove();
|
||||
|
||||
out[indexList[i]].description = $('.main .com-article-detail').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
|
||||
$('.article-detail-ft').remove();
|
||||
|
||||
out[indexList[i]].description = $('.main .com-article-detail').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
$('.article-detail-ft').remove();
|
||||
|
||||
out[indexList[i]].description = $('.main .com-article-detail').html();
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]), 24 * 60 * 60);
|
||||
ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
|
||||
}
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
|
||||
@@ -88,7 +88,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date * 1000).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -79,7 +79,7 @@ module.exports = async (ctx) => {
|
||||
link,
|
||||
};
|
||||
|
||||
await ctx.cache.set(link, JSON.stringify(item), 24 * 60 * 60);
|
||||
await ctx.cache.set(link, JSON.stringify(item));
|
||||
} else {
|
||||
const description = news.summaryAuto || news.summary || news.title;
|
||||
item = {
|
||||
|
||||
@@ -91,7 +91,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: date(date_value, 8),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -87,7 +87,7 @@ module.exports = async (ctx) => {
|
||||
} catch (err) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
ctx.cache.set(link, JSON.stringify(single), 3 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -11,16 +11,12 @@ module.exports = async (ctx) => {
|
||||
const date = data.intime * 1000;
|
||||
const link = data.url;
|
||||
|
||||
const description = await ctx.cache.tryGet(
|
||||
`sina-rollnews: ${link}`,
|
||||
async () => {
|
||||
const response = await axios.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = await ctx.cache.tryGet(`sina-rollnews: ${link}`, async () => {
|
||||
const response = await axios.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
return $('.article').html();
|
||||
},
|
||||
3 * 60 * 60
|
||||
);
|
||||
return $('.article').html();
|
||||
});
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
|
||||
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: date(pubdate),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -52,7 +52,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date * 1000).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
|
||||
const response = await axios({ method: 'get', url: link });
|
||||
const $ = cheerio.load(response.data);
|
||||
description = $('#article-content > div').html();
|
||||
ctx.cache.set(key, description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, description);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -160,7 +160,7 @@ module.exports = async (ctx) => {
|
||||
} catch (err) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
ctx.cache.set(link, JSON.stringify(single), 3 * 60 * 60);
|
||||
ctx.cache.set(link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -148,7 +148,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
// 记录读取的最后页码
|
||||
ctx.cache.set(`/t66y/post/${tid}`, JSON.stringify({ page }), 3 * 60 * 60);
|
||||
ctx.cache.set(`/t66y/post/${tid}`, JSON.stringify({ page }));
|
||||
|
||||
// 如果没有读到内容,则读取下一页,最多读取3页
|
||||
if (items.length === 0 && retry < 3) {
|
||||
|
||||
@@ -38,7 +38,7 @@ module.exports = async (ctx) => {
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
item.description = $('#articleContent').html();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
|
||||
author: author,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
item.description = $('.art-cont').html();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -53,7 +53,7 @@ module.exports = async (ctx) => {
|
||||
author: author,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
item.description = $(`#${id}`).html();
|
||||
ctx.cache.set(key, item.description, 24 * 60 * 60);
|
||||
ctx.cache.set(key, item.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(item);
|
||||
|
||||
@@ -51,8 +51,8 @@ module.exports = async (ctx) => {
|
||||
.replace(/更新于:/g, '')
|
||||
).toUTCString();
|
||||
|
||||
ctx.cache.set(description_key, single.description, 60 * 60);
|
||||
ctx.cache.set(pubDate_key, single.pubDate, 60 * 60);
|
||||
ctx.cache.set(description_key, single.description);
|
||||
ctx.cache.set(pubDate_key, single.pubDate);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
|
||||
@@ -50,8 +50,8 @@ module.exports = async (ctx) => {
|
||||
.replace(/更新于:/g, '')
|
||||
).toUTCString();
|
||||
|
||||
ctx.cache.set(description_key, single.description, 60 * 60);
|
||||
ctx.cache.set(pubDate_key, single.pubDate, 60 * 60);
|
||||
ctx.cache.set(description_key, single.description);
|
||||
ctx.cache.set(pubDate_key, single.pubDate);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
|
||||
@@ -57,7 +57,7 @@ module.exports = async (ctx) => {
|
||||
.trim(),
|
||||
pubDate: new Date(item.date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -2,7 +2,6 @@ const axios = require('../../../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const baseUrl = 'http://jwc.cqu.edu.cn';
|
||||
const cacheTime = 24 * 60 * 60;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
@@ -48,7 +47,7 @@ module.exports = async (ctx) => {
|
||||
$('div .field-items')
|
||||
.find('p')
|
||||
.text();
|
||||
await ctx.cache.set(item.link, JSON.stringify(item), cacheTime);
|
||||
await ctx.cache.set(item.link, JSON.stringify(item));
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ module.exports = async (ctx) => {
|
||||
.replace('/', '-')
|
||||
).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60); //
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single)); //
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user