From c30a4d56fca51ea2ddba683ad3fd88492ca9cfea Mon Sep 17 00:00:00 2001 From: elxy Date: Sun, 6 Mar 2022 01:21:58 +0800 Subject: [PATCH] feat(route): add Bitmovin blogs (#8935) * Add(route): add Bitmovin blogs * refactor: migrate to v2 Co-authored-by: TonyRL --- docs/en/programming.md | 6 ++++++ docs/programming.md | 6 ++++++ lib/v2/bitmovin/blog.js | 33 +++++++++++++++++++++++++++++++++ lib/v2/bitmovin/maintainer.js | 3 +++ lib/v2/bitmovin/radar.js | 13 +++++++++++++ lib/v2/bitmovin/router.js | 3 +++ 6 files changed, 64 insertions(+) create mode 100644 lib/v2/bitmovin/blog.js create mode 100644 lib/v2/bitmovin/maintainer.js create mode 100644 lib/v2/bitmovin/radar.js create mode 100644 lib/v2/bitmovin/router.js diff --git a/docs/en/programming.md b/docs/en/programming.md index 783703cd0..224ebe8f1 100644 --- a/docs/en/programming.md +++ b/docs/en/programming.md @@ -66,6 +66,12 @@ Category +## Bitmovin + +### Blog + + + ## Codeforces ### Latest contests diff --git a/docs/programming.md b/docs/programming.md index 5f162496b..eab7cfd92 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -80,6 +80,12 @@ Rated 对象 +## Bitmovin + +### Blog + + + ## Codeforces #### 最新比赛 diff --git a/lib/v2/bitmovin/blog.js b/lib/v2/bitmovin/blog.js new file mode 100644 index 000000000..e1353a39f --- /dev/null +++ b/lib/v2/bitmovin/blog.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://bitmovin.com/blog/'; + const response = await got({ + method: 'get', + url: rootUrl, + }); + + const $ = cheerio.load(response.data); + + const items = $('div.blog-posts article') + .slice() + .map((_, item) => { + item = $(item); + return { + title: item.find('h2 a').text(), + author: item.find('li.post-author span a').text(), + description: item.find('div.entry p').text(), + pubDate: parseDate(item.find('li.post-date').text()), + link: item.find('h2 a').attr('href'), + }; + }) + .get(); + + ctx.state.data = { + title: 'Blog - Bitmovin', + link: rootUrl, + item: items, + }; +}; diff --git a/lib/v2/bitmovin/maintainer.js b/lib/v2/bitmovin/maintainer.js new file mode 100644 index 000000000..74aebe40d --- /dev/null +++ b/lib/v2/bitmovin/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/blog': ['elxy'], +}; diff --git a/lib/v2/bitmovin/radar.js b/lib/v2/bitmovin/radar.js new file mode 100644 index 000000000..3ed26fb0d --- /dev/null +++ b/lib/v2/bitmovin/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bitmovin.com': { + _name: 'Bitmovin', + '.': [ + { + title: 'Blog', + docs: 'https://docs.rsshub.app/programming.html#bitmovin', + source: ['/blog', '/'], + target: '/bitmovin/blog', + }, + ], + }, +}; diff --git a/lib/v2/bitmovin/router.js b/lib/v2/bitmovin/router.js new file mode 100644 index 000000000..eadc22005 --- /dev/null +++ b/lib/v2/bitmovin/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/blog', require('./blog')); +};