feat(route): add Bitmovin blogs (#8935)

* Add(route): add Bitmovin blogs

* refactor: migrate to v2

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
elxy 2022-03-06 01:21:58 +08:00 committed by GitHub
parent 0ac081aad0
commit c30a4d56fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 0 deletions

View File

@ -66,6 +66,12 @@ Category
<RouteEn author="elxy" example="/bbcnewslabs/news" path="/bbcnewslabs/news"/>
## Bitmovin
### Blog
<RouteEn author="elxy" example="/bitmovin/blog" path="/bitmovin/blog"/>
## Codeforces
### Latest contests

View File

@ -80,6 +80,12 @@ Rated 对象
<Route author="elxy" example="/bbcnewslabs/news" path="/bbcnewslabs/news"/>
## Bitmovin
### Blog
<Route author="elxy" example="/bitmovin/blog" path="/bitmovin/blog"/>
## Codeforces
#### 最新比赛

33
lib/v2/bitmovin/blog.js Normal file
View File

@ -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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/blog': ['elxy'],
};

13
lib/v2/bitmovin/radar.js Normal file
View File

@ -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',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/blog', require('./blog'));
};