feat: add openwrt releases

This commit is contained in:
DIYgod 2022-06-19 02:44:05 +01:00
parent 6a0d44348e
commit 303b91ffec
No known key found for this signature in database
GPG Key ID: D159328F47A80DCA
6 changed files with 56 additions and 0 deletions

View File

@ -289,6 +289,12 @@ Refer to [#minecraft](/en/game.html#minecraft)
<RouteEn author="nczitzk" example="/obsidian/announcements" path="/obsidian/announcements"/>
## OpenWrt
### Releases
<RouteEn author="DIYgod" example="/openwrt/releases/xiaomi/xiaomi_redmi_router_ac2100" path="/releases/:brand/:model" :paramsDesc="['Device Model, can be found in url of `Table of Hardware` -> `Device Page`', 'Same as above']"/>
## PlayStation
### PlayStation 4 System Update

View File

@ -342,6 +342,12 @@ pageClass: routes
<Route author="nczitzk" example="/onenotegem/release" path="/onenotegem/release"/>
## OpenWrt
### Releases
<Route author="DIYgod" example="/openwrt/releases/xiaomi/xiaomi_redmi_router_ac2100" path="/releases/:brand/:model" :paramsDesc="['产品型号,可在 `Table of Hardware` -> `Device Page` 的 URL 中找到', '同上']"/>
## PlayStation
### PlayStation 4 系统更新纪录

View File

@ -0,0 +1,3 @@
module.exports = {
'/releases/:model?': ['DIYgod'],
};

13
lib/v2/openwrt/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'openwrt.org': {
_name: 'Openwrt',
'.': [
{
title: 'Model Releases',
docs: 'https://docs.rsshub.app/program-update.html#openwrt',
source: '/toh/:band/:model',
target: '/openwrt/releases/:model',
},
],
},
};

View File

@ -0,0 +1,25 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const brand = ctx.params.brand;
const model = ctx.params.model;
const url = `https://openwrt.org/toh/${brand}/${model}`;
const response = await got(url);
const $ = cheerio.load(response.data);
const table = $('#installation').next();
ctx.state.data = {
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()}'`,
},
],
};
};

3
lib/v2/openwrt/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/releases/:brand/:model', require('./releases'));
};