From e8bc6a63015531cc77217790a13163cfd62064cc Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 27 Jul 2022 16:44:01 -0700 Subject: [PATCH] feat(route): ifi-audio download hub (#10337) * feat(route): ifi-audio download hub * fix(ifi-audio): use cheerio to make guid distinct --- docs/en/program-update.md | 112 ++++++++++++++++++--------------- docs/program-update.md | 14 +++++ lib/v2/ifi-audio/download.js | 34 ++++++++++ lib/v2/ifi-audio/maintainer.js | 3 + lib/v2/ifi-audio/router.js | 3 + 5 files changed, 117 insertions(+), 49 deletions(-) create mode 100644 lib/v2/ifi-audio/download.js create mode 100644 lib/v2/ifi-audio/maintainer.js create mode 100644 lib/v2/ifi-audio/router.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 63ba542067..b79aa66289 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -86,29 +86,29 @@ Software id Language -| Language | key | -| -------- | --- | -| English | en | -| 中文 (简体) | cn | -| 中文 (繁體) | tw | -| 日本語 | jp | -| Русский | ru | -| Español | es | -| Français | fr | -| Deutsch | de | -| Italiano | it | -| Slovenčina | sk | -| Українська | uk | -| Беларуская | be | -| Dansk | da | -| Polski | pl | -| Português Brasileiro | br | -| Čeština | cs | -| Nederlands | nl | -| Slovenščina| sl | -| Türkçe| tr | -| ภาษาไทย | th | -| 한국어 | kr | +| Language | key | +| -------------------- | --- | +| English | en | +| 中文 (简体) | cn | +| 中文 (繁體) | tw | +| 日本語 | jp | +| Русский | ru | +| Español | es | +| Français | fr | +| Deutsch | de | +| Italiano | it | +| Slovenčina | sk | +| Українська | uk | +| Беларуская | be | +| Dansk | da | +| Polski | pl | +| Português Brasileiro | br | +| Čeština | cs | +| Nederlands | nl | +| Slovenščina | sl | +| Türkçe | tr | +| ภาษาไทย | th | +| 한국어 | kr | @@ -193,8 +193,8 @@ Use `library` as the `owner` for official images, such as @@ -244,6 +244,20 @@ Language +## iFi audio + +### Download Hub + + + +::: warning + +1. Open and the Network panel +2. Select the device and the corresponding serial number in the website and click Search +3. Find the last request named in the Network panel, find out the val and id in the Payload panel, and fill in the url + +::: + ## ImageMagick ### Changelog @@ -423,8 +437,8 @@ Refer to [#minecraft](/en/game.html#minecraft) | Mac OS | Windows | -| - | - | -| mac | windows | +| ------ | ------- | +| mac | windows | @@ -468,28 +482,28 @@ Refer to [#minecraft](/en/game.html#minecraft) Language -| Id | Language | -| -- | ------------------- | -| en | English | -| ru | Русский | -| ja | 日本語 | -| es | Español | -| tr | Türkçe | -| ko | 한국어 | -| it | Italiano | -| pt | Português do Brasil | -| de | Deutsch | -| fr | Français | -| pl | Polski | -| id | Bahasa Indonesia | -| my | Bahasa Malaysia | -| tw | 繁體 | -| cn | 简体 | -| vi | Tiếng Việt | -| th | ภาษาไทย | -| sv | Svenska | -| ar | العربية | -| il | Hebrew | +| Id | Language | +| --- | ------------------- | +| en | English | +| ru | Русский | +| ja | 日本語 | +| es | Español | +| tr | Türkçe | +| ko | 한국어 | +| it | Italiano | +| pt | Português do Brasil | +| de | Deutsch | +| fr | Français | +| pl | Polski | +| id | Bahasa Indonesia | +| my | Bahasa Malaysia | +| tw | 繁體 | +| cn | 简体 | +| vi | Tiếng Việt | +| th | ภาษาไทย | +| sv | Svenska | +| ar | العربية | +| il | Hebrew | diff --git a/docs/program-update.md b/docs/program-update.md index 62d66c7eae..ff23d3ff05 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -276,6 +276,20 @@ pageClass: routes +## iFi audio + +### Download Hub + + + +::: warning 注意 + +1. 打开网站 并打开 Inspect -> Network 调试面板 +2. 在网站中选择设备以及对应的 serial number,点击搜索 +3. 在 Network 面板中找到最后一个 请求,查看 Payload 中的 val 和 id,填写在 url 中 + +::: + ## ImageMagick ### Changelog diff --git a/lib/v2/ifi-audio/download.js b/lib/v2/ifi-audio/download.js new file mode 100644 index 0000000000..85761ee3d1 --- /dev/null +++ b/lib/v2/ifi-audio/download.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const host = 'https://ifi-audio.com'; + +module.exports = async (ctx) => { + const { val, id } = ctx.params; + + const url = host + '/wp-admin/admin-ajax.php'; + const response = await got({ + method: 'post', + url, + headers: { + 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', + }, + body: 'action=ifi-ff-get-firmware&val=' + val + '&id=' + id, + }); + const markup = response.data.data.markup; + const $ = cheerio.load(markup); + const latestTitle = $('li[data-category=firmware]:first h4').text(); + const latestDownloadLink = $('li[data-category=firmware]:first a').attr('href'); + ctx.state.data = { + title: 'iFi audio Download Hub', + link: 'https://ifi-audio.com/download-hub/', + description: 'iFi audio Download Hub', + item: [ + { + title: latestTitle, + description: markup, + link: latestDownloadLink, + }, + ], + }; +}; diff --git a/lib/v2/ifi-audio/maintainer.js b/lib/v2/ifi-audio/maintainer.js new file mode 100644 index 0000000000..ad6161689a --- /dev/null +++ b/lib/v2/ifi-audio/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/download/:val/:id': ['NavePnow'], +}; diff --git a/lib/v2/ifi-audio/router.js b/lib/v2/ifi-audio/router.js new file mode 100644 index 0000000000..627c57818a --- /dev/null +++ b/lib/v2/ifi-audio/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/download/:val/:id', require('./download')); +};