feat(route): Add La Jornada news (#11091)
* git commit -m "feat(route): Add La Jornada news" * fix(route): Lint for route * fix(route): get precise date * Update docs/en/traditional-media.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/lajornada/router.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix: radar * fix: maintainer
This commit is contained in:
@@ -281,6 +281,30 @@ Support all channels, refer to [CNBC RSS feeds](https://www.cnbc.com/rss-feeds/)
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## La Jornada
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="Thealf154" example="/jornada/2022-10-12/capital" path="/jornada/:date?/:category?" :paramsDesc="['Date string, must be in format of `YYYY-MM-DD`. You can get today\'s news using `today`', 'Category, refer to the table below']" radar="1">
|
||||
|
||||
Provides a way to get an specific rss feed by date and category over the official one.
|
||||
|
||||
| Category | `:category`|
|
||||
|------------------------|------------|
|
||||
| Capital | capital |
|
||||
| Cartones | cartones |
|
||||
| Ciencia y Tecnología | ciencia |
|
||||
| Cultura | cultura |
|
||||
| Deportes | deportes |
|
||||
| Economía | economia |
|
||||
| Estados | estados |
|
||||
| Mundo | mundo |
|
||||
| Opinión | opinion |
|
||||
| Política | politica |
|
||||
| Sociedad | sociedad |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Ming Pao
|
||||
|
||||
### Ming Pao Daily
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootUrl = 'https://www.jornada.com.mx';
|
||||
|
||||
const categories = {
|
||||
capital: 'Capital',
|
||||
cartones: 'Cartones',
|
||||
ciencia: 'Ciencia-Y-Tecnologia',
|
||||
cultura: 'Cultura',
|
||||
deportes: 'Deportes',
|
||||
economia: 'Economia',
|
||||
estados: 'Estados',
|
||||
mundo: 'Mundo',
|
||||
opinion: 'Opinion',
|
||||
politica: 'Politica',
|
||||
sociedad: 'Sociedad',
|
||||
};
|
||||
|
||||
const getDateForToday = () => {
|
||||
const date = new Date(Date.now());
|
||||
const today = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2);
|
||||
return today;
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const date = ctx.params.date === 'today' || ctx.params.date === undefined ? getDateForToday() : ctx.params.date;
|
||||
const category = ctx.params.category;
|
||||
const url = `${rootUrl}/jsonstorage/articles_${date}_.json`;
|
||||
|
||||
const response = await got(url);
|
||||
const data = response.data;
|
||||
|
||||
let items = {};
|
||||
|
||||
if (!category) {
|
||||
items = data.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.content,
|
||||
pubDate: parseDate(item.date),
|
||||
link: `${rootUrl}/${item.url}`,
|
||||
}));
|
||||
} else {
|
||||
const newsFilteredByCategory = data.filter((item) => item.category === categories[category]);
|
||||
|
||||
items = newsFilteredByCategory.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.content,
|
||||
pubDate: parseDate(item.date),
|
||||
link: `${rootUrl}/${item.url}`,
|
||||
}));
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'La Jornada',
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:date?/:category?': ['Thealf154'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'jornada.com.mx': {
|
||||
_name: 'La Jornada',
|
||||
'.': [
|
||||
{
|
||||
title: 'News',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#jornada',
|
||||
source: ['/category/:category', '/'],
|
||||
target: (params) => (params.category ? `/jornada/today/${params.category.replacce('.html', '')}` : `/jornada/today`),
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:date?/:category?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user