/
whats-new.ts
74 lines (65 loc) 路 1.83 KB
/
whats-new.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
64
65
66
67
68
69
70
71
72
73
74
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/whats-new',
categories: ['program-update'],
example: '/diskanalyzer/whats-new',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['diskanalyzer.com/whats-new', 'diskanalyzer.com/'],
},
],
name: "What's New",
maintainers: ['nczitzk'],
handler,
url: 'diskanalyzer.com/whats-new',
};
async function handler() {
const rootUrl = 'https://diskanalyzer.com';
const currentUrl = `${rootUrl}/whats-new`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = load(response.data);
const items = $('.blog-content h4')
.toArray()
.map((item) => {
item = $(item);
const title = item.text();
let description = '';
item.nextUntil('h4').each(function () {
description += $(this).html();
});
if (description === '') {
item.parent()
.nextUntil('h4')
.each(function () {
description += $(this).html();
});
}
return {
title,
link: currentUrl,
description,
pubDate: parseDate(title.match(/\((.*)\)/)[1], ['D MMMM YYYY', 'D MMM YYYY']),
guid: title,
};
});
return {
title: $('title').text(),
link: currentUrl,
item: items,
};
}