mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
feat: 添加对【PS4 系统更新纪录 】支持 (#3131)
This commit is contained in:
@@ -104,6 +104,10 @@ pageClass: routes
|
||||
|
||||
<Route author="DIYgod" example="/ps/trophy/DIYgod_" path="/ps/trophy/:id" :paramsDesc="['用户 ID']"/>
|
||||
|
||||
### PlayStation 4 系统更新纪录
|
||||
|
||||
<Route author="Jeason0228" example="/ps/ps4updates/" path="/ps/ps4updates/" />
|
||||
|
||||
## psnine
|
||||
|
||||
### 首页-白金攻略/游戏开箱
|
||||
|
||||
@@ -1287,6 +1287,7 @@ router.get('/mlhang', require('./routes/mlhang/latest'));
|
||||
// PlayStation Store
|
||||
router.get('/ps/list/:gridName', require('./routes/ps/list'));
|
||||
router.get('/ps/trophy/:id', require('./routes/ps/trophy'));
|
||||
router.get('/ps/ps4updates', require('./routes/ps/ps4updates'));
|
||||
|
||||
// Nintendo
|
||||
router.get('/nintendo/eshop/jp', require('./routes/nintendo/eshop_jp'));
|
||||
|
||||
70
lib/routes/ps/ps4updates.js
Normal file
70
lib/routes/ps/ps4updates.js
Normal file
@@ -0,0 +1,70 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
const host = 'https://asia.playstation.com/';
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://asia.playstation.com/chs-hk/ps4/system-update/ps4-system-update-change-log/`;
|
||||
const response = await got.get(link, {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
// let title = $('.psc-main-format-style').first().text();
|
||||
function sortDate(e) {
|
||||
// console.log(e);
|
||||
const pubday = e.substr(8, 2);
|
||||
const pubmonth = e.substr(5, 2);
|
||||
const pubyear = e.substr(0, 4);
|
||||
const pubdateString = pubmonth + `-` + pubday + `-` + pubyear;
|
||||
// console.log(pubdateString);
|
||||
return pubdateString;
|
||||
}
|
||||
const list = $('.layoutRowParsys ul li')
|
||||
.map(function() {
|
||||
const info = {
|
||||
title: $(this)
|
||||
.find('span.psc-d-block')
|
||||
.text(),
|
||||
link: $(this)
|
||||
.find('a')
|
||||
.attr('href'),
|
||||
date: sortDate(
|
||||
$(this)
|
||||
.find('span.psc-info-date')
|
||||
.text()
|
||||
),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
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 Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await got.get(itemUrl, {
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = $('.layoutRowParsys').html();
|
||||
const single = {
|
||||
title: title,
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
pubDate: new Date(date).toDateString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: $('.psc-main-format-style')
|
||||
.first()
|
||||
.text(),
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user