feat(route): add Bandcamp Upcoming Live Streams (#8512)
This commit is contained in:
parent
8490e33230
commit
6ec9005946
|
|
@ -22,6 +22,10 @@ Full transcript support for better user experience.
|
|||
|
||||
<RouteEn author="nczitzk" example="/bandcamp/tag/united-kingdom" path="/bandcamp/tag/:tag?" :paramsDesc="['Tag, can be found in URL']"/>
|
||||
|
||||
### Upcoming Live Streams
|
||||
|
||||
<Route author="nczitzk" example="/bandcamp/live" path="/bandcamp/live"/>
|
||||
|
||||
## EZTV
|
||||
|
||||
::: tip
|
||||
|
|
|
|||
|
|
@ -205,6 +205,10 @@ pageClass: routes
|
|||
|
||||
<Route author="nczitzk" example="/bandcamp/tag/united-kingdom" path="/bandcamp/tag/:tag?" :paramsDesc="['标签,可在 URL 中找到']"/>
|
||||
|
||||
### Upcoming Live Streams
|
||||
|
||||
<Route author="nczitzk" example="/bandcamp/live" path="/bandcamp/live"/>
|
||||
|
||||
## bilibili
|
||||
|
||||
见 [#bilibili](/social-media.html#bilibili)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://bandcamp.com';
|
||||
const currentUrl = `${rootUrl}/live_schedule`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('.curated-wrapper').remove();
|
||||
|
||||
const items = $('.live-listing')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
link: item.find('.title-link').attr('href'),
|
||||
title: item.find('.show-title').text(),
|
||||
author: item.find('.show-artist').text(),
|
||||
pubDate: parseDate(item.find('.show-time-container').text().trim().split(' UTC')[0]),
|
||||
description: `<img src="${
|
||||
item
|
||||
.find('.show-thumb-image')
|
||||
.attr('style')
|
||||
.match(/background-image: url\((.*)\);/)[1]
|
||||
}">`,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/live': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'bandcamp.com': {
|
||||
_name: 'Bandcamp',
|
||||
'.': [
|
||||
{
|
||||
title: 'Upcoming Live Streams',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#bandcamp-upcoming-live-streams',
|
||||
source: ['/live_schedule'],
|
||||
target: '/bandcamp/live',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/live', require('./live'));
|
||||
};
|
||||
Loading…
Reference in New Issue