diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 004f7dbfe..0156edf30 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -454,6 +454,12 @@ Refer to [#minecraft](/en/game.html#minecraft) +## Western Digital + +### Download + + + ## WizTree ### What's New diff --git a/docs/program-update.md b/docs/program-update.md index 28078fe60..06a612e6c 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -541,6 +541,12 @@ pageClass: routes +## Western Digital + +### Download + + + ## WizTree ### What's New diff --git a/lib/v2/wdc/download.js b/lib/v2/wdc/download.js new file mode 100644 index 000000000..109120451 --- /dev/null +++ b/lib/v2/wdc/download.js @@ -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, + }; +}; diff --git a/lib/v2/wdc/maintainer.js b/lib/v2/wdc/maintainer.js new file mode 100644 index 000000000..8e7f20fb1 --- /dev/null +++ b/lib/v2/wdc/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/download/:id': ['nczitzk'], +}; diff --git a/lib/v2/wdc/radar.js b/lib/v2/wdc/radar.js new file mode 100644 index 000000000..8c3585de8 --- /dev/null +++ b/lib/v2/wdc/radar.js @@ -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')}`, + }, + ], + }, +}; diff --git a/lib/v2/wdc/router.js b/lib/v2/wdc/router.js new file mode 100644 index 000000000..e17b492b9 --- /dev/null +++ b/lib/v2/wdc/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/download/:id?', require('./download')); +};