diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 1c1c49d2ed..721a2a12e8 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -4,6 +4,12 @@ pageClass: routes # Application Updates +## Android + +### SDK Platform Tools release notes + + + ## Anki ### Changes diff --git a/docs/program-update.md b/docs/program-update.md index f23d9dfc02..3578ce8f38 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -14,6 +14,12 @@ pageClass: routes +## Android + +### SDK Platform Tools release notes + + + ## Anki ### Changes diff --git a/lib/v2/android/maintainer.js b/lib/v2/android/maintainer.js new file mode 100644 index 0000000000..a1d820e344 --- /dev/null +++ b/lib/v2/android/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/platform-tools-releases': ['nczitzk'], +}; diff --git a/lib/v2/android/platform-tools-releases.js b/lib/v2/android/platform-tools-releases.js new file mode 100644 index 0000000000..bb8ef6fabd --- /dev/null +++ b/lib/v2/android/platform-tools-releases.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://developer.android.com'; + const currentUrl = `${rootUrl}/studio/releases/platform-tools`; + + const response = await got({ + method: 'get', + url: currentUrl, + headers: { + cookie: 'signin=autosignin', + }, + }); + + const $ = cheerio.load(response.data); + + $('.hide-from-toc').remove(); + $('.devsite-dialog, .devsite-badge-awarder, .devsite-hats-survey').remove(); + + const items = $('h4') + .toArray() + .map((item) => { + item = $(item); + + const title = item.attr('data-text'); + + let description = ''; + item.nextUntil('h4').each(function () { + description += $(this).html(); + }); + + return { + title, + description, + link: `${currentUrl}#${item.attr('id')}`, + pubDate: parseDate(title.match(/\((.*)\)/)[1], 'MMMM YYYY'), + }; + }); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/android/radar.js b/lib/v2/android/radar.js new file mode 100644 index 0000000000..c2fa315904 --- /dev/null +++ b/lib/v2/android/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'android.com': { + _name: 'Android Developers', + developer: [ + { + title: 'SDK Platform Tools release notes', + docs: 'https://docs.rsshub.app/program-update.html#android-sdk-platform-tools-release-notes', + source: ['/studio/releases/platform-tools', '/'], + target: '/android/platform-tools-releases', + }, + ], + }, +}; diff --git a/lib/v2/android/router.js b/lib/v2/android/router.js new file mode 100644 index 0000000000..310220cb65 --- /dev/null +++ b/lib/v2/android/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/platform-tools-releases', require('./platform-tools-releases')); +};