/
system-update.ts
63 lines (57 loc) · 1.93 KB
/
system-update.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
export const route: Route = {
path: '/system-update',
categories: ['game'],
example: '/nintendo/system-update',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['nintendo.co.jp/support/switch/system_update/index.html', 'nintendo.co.jp/'],
},
],
name: 'Switch System Update(Japan)',
maintainers: ['hoilc'],
handler,
url: 'nintendo.co.jp/support/switch/system_update/index.html',
};
async function handler() {
const url = 'https://www.nintendo.co.jp/support/switch/system_update/index.html';
const response = await got(url);
const $ = load(response.data);
const list = $('.c-heading-lv3').toArray().slice(1, -2);
return {
title: 'Nintendo Switch 本体更新情報',
link: url,
item: list.map((update) => {
update = $(update);
const heading = update.text();
const matched_date = /(\d+)年(\d+)月(\d+)日/.exec(heading);
const update_info = update.nextUntil('.c-heading-lv3');
const update_infos = update_info
.map(function () {
return $(this).html();
})
.get()
.join('\n');
const matched_version = /(\d\.)+\d/.exec(heading);
return {
title: heading,
author: 'Nintendo',
description: update_infos,
link: url,
guid: `${url}#${matched_version[0]}`,
pubDate: new Date(Number.parseInt(matched_date[1]), Number.parseInt(matched_date[2]) - 1, Number.parseInt(matched_date[3])),
};
}),
};
}