/
releases.ts
39 lines (36 loc) 路 1.15 KB
/
releases.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
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
export const route: Route = {
path: '/releases/:brand/:model',
radar: [
{
source: ['openwrt.org/toh/:band/:model'],
target: '/releases/:model',
},
],
name: 'Unknown',
maintainers: [],
handler,
};
async function handler(ctx) {
const brand = ctx.req.param('brand');
const model = ctx.req.param('model');
const url = `https://openwrt.org/toh/${brand}/${model}`;
const response = await got(url);
const $ = load(response.data);
const table = $('#installation').next();
return {
title: $('h1').text() + ' - OpenWrt Releases',
link: url,
description: $('.dw-content div.level1').text(),
language: 'en-US',
item: [
{
title: table.find('.supported_current_rel').text(),
link: url,
description: `Firmware OpenWrt Install: ${table.find('.firmware_openwrt_install_url').html()}<br><br>Firmware OpenWrt Upgrade: ${$('.firmware_openwrt_upgrade_url').html()}'`,
},
],
};
}