feat(route): add Tribal Football (#10238)
* feat(route): add Tribal Football Signed-off-by: Rongrong <i@rong.moe> * fix: insecure HTTP
This commit is contained in:
parent
ee475dd3a1
commit
f0c5610ba1
|
|
@ -739,6 +739,12 @@ Provides all of the Thrillist articles with the specified tag.
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## Tribal Football
|
||||
|
||||
### Latest News
|
||||
|
||||
<RouteEn author="Rongronggg9" example="/tribalfootball" path="/tribalfootball" />
|
||||
|
||||
## VOA News
|
||||
|
||||
### Day in Photos
|
||||
|
|
|
|||
|
|
@ -1317,6 +1317,12 @@ Provides all of the Thrillist articles with the specified tag.
|
|||
|
||||
</Route>
|
||||
|
||||
## Tribal Football
|
||||
|
||||
### Latest News
|
||||
|
||||
<Route author="Rongronggg9" example="/tribalfootball" path="/tribalfootball" />
|
||||
|
||||
## Uwants
|
||||
|
||||
### 版塊
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rssUrl = 'https://www.tribalfootball.com/rss/mediafed/general/rss.xml';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rss = await got(rssUrl);
|
||||
const $ = cheerio.load(rss.data, { xmlMode: true });
|
||||
const items = $('rss > channel > item')
|
||||
.map((_, item) => {
|
||||
const $item = $(item);
|
||||
let link = $item.find('link').text();
|
||||
link = new URL(link);
|
||||
link.search = '';
|
||||
link = link.href;
|
||||
return {
|
||||
title: $item.find('title').text(),
|
||||
description: $item.find('description').text(),
|
||||
link,
|
||||
guid: $item.find('guid').text(),
|
||||
pubDate: parseDate($item.find('pubDate').text()),
|
||||
author: $item.find('dc\\:creator').text(),
|
||||
_header_image: $item.find('enclosure').attr('url'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const title = $('head > title').text().replace(' - Tribal Football', '');
|
||||
|
||||
let desc = $('.articleBody');
|
||||
desc.find('.ad').remove();
|
||||
// <p><br><i>AD</i><span></span></p>
|
||||
const ad = desc.find('p > br:first-child').next('i');
|
||||
const adNextSpan = ad.next('span');
|
||||
if (adNextSpan.length && !adNextSpan.text() && !adNextSpan.next().length) {
|
||||
ad.parent().remove();
|
||||
}
|
||||
desc = desc.html();
|
||||
desc = art(path.join(__dirname, 'templates/plus_header.art'), {
|
||||
desc,
|
||||
header_image: item._header_image,
|
||||
});
|
||||
|
||||
item.title = title || item.title;
|
||||
item.description = desc || item.description;
|
||||
delete item._header_image;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Tribal Football - Latest',
|
||||
description: 'Tribal Football - Football News, Soccer News, Transfers & Rumours',
|
||||
link: 'https://www.tribalfootball.com/articles',
|
||||
image: 'https://www.tribalfootball.com/images/tribal-logo-rss.png',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/': ['Rongronggg9'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'tribalfootball.com': {
|
||||
_name: 'Tribal Football',
|
||||
'.': [
|
||||
{
|
||||
title: 'Latest News',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#tribal-football',
|
||||
source: ['/'],
|
||||
target: '/tribalfootball',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/', require('./latest'));
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{{ if header_image }}
|
||||
<p>
|
||||
<img src="{{ header_image }}">
|
||||
</p>
|
||||
{{ /if }}
|
||||
{{@ desc }}
|
||||
Loading…
Reference in New Issue