Files
RSSHub/lib/v2/bandcamp/weekly.js
Ethan Shen 27ad517f0d feat(route): add Bandcamp Weekly (#7480)
* feat(route): add Bandcamp Weekly

* refactor: migrate to v2

* docs: fix route tag

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2022-02-21 00:15:54 +08:00

30 lines
849 B
JavaScript

const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const rootUrl = 'https://bandcamp.com';
const apiUrl = `${rootUrl}/api/bcweekly/3/list`;
const response = await got({
method: 'get',
url: apiUrl,
});
const items = response.data.results.slice(0, 50).map((item) => ({
title: item.title,
link: `${rootUrl}/?show=${item.id}`,
pubDate: parseDate(item.published_date),
description: art(path.join(__dirname, 'templates/weekly.art'), {
v2_image_id: item.v2_image_id,
desc: item.desc,
}),
}));
ctx.state.data = {
title: 'Bandcamp Weekly',
link: rootUrl,
item: items,
};
};