feat(route): add Western Digital Download (#10307)
* feat(route): add Western Digital Download * docs: fix typo
This commit is contained in:
parent
54f78956d7
commit
362a2b0f49
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/download/:id': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -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')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/download/:id?', require('./download'));
|
||||
};
|
||||
Loading…
Reference in New Issue