feat(route): add Western Digital Download (#10307)

* feat(route): add Western Digital Download

* docs: fix typo
This commit is contained in:
Ethan Shen 2022-07-24 21:30:50 +08:00 committed by GitHub
parent 54f78956d7
commit 362a2b0f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 0 deletions

View File

@ -454,6 +454,12 @@ Refer to [#minecraft](/en/game.html#minecraft)
<RouteEn author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
## Western Digital
### Download
<RouteEn author="nczitzk" example="/wdc/download/279" path="/wdc/download/:id?" :paramsDesc="['Software id, can be found in URL, 279 as Western Digital Dashboard by default']"/>
## WizTree
### What's New

View File

@ -541,6 +541,12 @@ pageClass: routes
<Route author="nczitzk" example="/typora/changelog-dev/macOS" path="/typora/changelog-dev/:os" :paramsDesc="['操作系统类型, 可选 `macOS``Windows``Linux`,默认为 `macOS`']"/>
## Western Digital
### Download
<Route author="nczitzk" example="/wdc/download/279" path="/wdc/download/:id?" :paramsDesc="['软件 id可在对应软件页 URL 中找到,默认为 279即 Western Digital Dashboard']"/>
## WizTree
### What's New

37
lib/v2/wdc/download.js Normal file
View File

@ -0,0 +1,37 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const id = ctx.params.id ?? '279';
const rootUrl = 'https://support.wdc.com';
const currentUrl = `${rootUrl}/downloads.aspx?p=${id}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const version = $('#WD_lblVersionSelected').text();
const items = [
{
title: version,
link: `${currentUrl}#${version}`,
enclosure_url: $('#WD_hlDownloadFWSelected').attr('href'),
pubDate: parseDate($('#WD_lblReleaseDateSelected').text(), 'D/M/YYYY'),
description: $('.toggleInner')
.html()
.replace(/style="color:White;"/, ''),
},
];
ctx.state.data = {
title: `${$('#WD_lblSelectedName').text()} | WD Support`,
link: currentUrl,
item: items,
};
};

3
lib/v2/wdc/maintainer.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
'/download/:id': ['nczitzk'],
};

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

@ -0,0 +1,13 @@
module.exports = {
'wdc.com': {
_name: '',
support: [
{
title: 'Western Digital',
docs: 'https://docs.rsshub.app/program-update.html#western-digital-download',
source: ['/downloads.aspx', '/'],
target: (params, url) => `/wdc/download/${new URL(url).searchParams.get('p')}`,
},
],
},
};

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

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/download/:id?', require('./download'));
};