/
changelog.ts
65 lines (55 loc) · 1.76 KB
/
changelog.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
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/changelog/:id',
categories: ['program-update'],
example: '/oo-software/changelog/shutup10',
parameters: { id: 'Software id, see below, shutup10 by default, can be found in URL' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Changelog',
maintainers: ['nczitzk'],
handler,
description: `| Software | Id |
| --------------- | ----------- |
| O\&O ShutUp10++ | shutup10 |
| O\&O AppBuster | ooappbuster |
| O\&O Lanytix | oolanytix |
| O\&O DeskInfo | oodeskinfo |`,
};
async function handler(ctx) {
const id = ctx.req.param('id') ?? 'shutup10';
const rootUrl = 'https://www.oo-software.com';
const currentUrl = `${rootUrl}/en/${id}/changelog`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = load(response.data);
const items = $('.content h4')
.toArray()
.map((item) => {
item = $(item);
const title = item.text();
return {
title,
link: `${currentUrl}#${title.split(' – ')[0]}`,
description: item.next().html(),
pubDate: parseDate(title.match(/released (on )?(.*)$/)[2], 'MMMM DD, YYYY'),
};
});
items[0].enclosure_url = $('.banner-inlay').find('a').attr('href');
return {
title: $('title').text(),
link: currentUrl,
item: items,
};
}