mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
Add(route): add Codeforces contests (#8815)
Co-authored-by: HuangWei <huangwei.a180285@gmail.com> Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -10,6 +10,12 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="nczitzk" example="/acm/amturingaward" path="/acm/amturingaward"/>
|
<Route author="nczitzk" example="/acm/amturingaward" path="/acm/amturingaward"/>
|
||||||
|
|
||||||
|
## Codeforces
|
||||||
|
|
||||||
|
### Latest contests
|
||||||
|
|
||||||
|
<RouteEn author="Fatpandac" example="/codeforces/contests" path="/codeforces/contests"/>
|
||||||
|
|
||||||
## AtCoder
|
## AtCoder
|
||||||
|
|
||||||
### Present Contests
|
### Present Contests
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ pageClass: routes
|
|||||||
|
|
||||||
> AlgoCasts 需要付费订阅,RSS 仅做更新提醒,不含付费内容.
|
> AlgoCasts 需要付费订阅,RSS 仅做更新提醒,不含付费内容.
|
||||||
|
|
||||||
|
## Codeforces
|
||||||
|
|
||||||
|
#### 最新比赛
|
||||||
|
|
||||||
|
<Route author="Fatpandac" example="/codeforces/contests" path="/codeforces/contests"/>
|
||||||
|
|
||||||
## AtCoder
|
## AtCoder
|
||||||
|
|
||||||
### Present Contests
|
### Present Contests
|
||||||
|
|||||||
37
lib/v2/codeforces/contests.js
Normal file
37
lib/v2/codeforces/contests.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const path = require('path');
|
||||||
|
const { art } = require('@/utils/render');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
const contestAPI = 'https://codeforces.com/api/contest.list';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const contestsData = await got.get(contestAPI).json();
|
||||||
|
const contests = contestsData.result;
|
||||||
|
|
||||||
|
const items = contests
|
||||||
|
.filter((contests) => contests.phase === 'BEFORE')
|
||||||
|
.map((contest) => {
|
||||||
|
const title = String(contest.name);
|
||||||
|
const description = art(path.join(__dirname, 'templates/contest.art'), {
|
||||||
|
title,
|
||||||
|
startTime: timezone(parseDate(contest.startTimeSeconds * 1000), +0),
|
||||||
|
durationTime: contest.durationSeconds / 60,
|
||||||
|
relativeTime: Math.floor(contest.relativeTimeSeconds / 60),
|
||||||
|
type: contest.type,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
link: 'https://codeforces.com/contests/' + contest.id,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'Codeforces - Contests',
|
||||||
|
link: 'https://codeforces.com/contests',
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/codeforces/maintainer.js
Normal file
3
lib/v2/codeforces/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/contests': ['Fatpandac'],
|
||||||
|
};
|
||||||
13
lib/v2/codeforces/radar.js
Normal file
13
lib/v2/codeforces/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'codeforces.com': {
|
||||||
|
_name: 'Codeforces',
|
||||||
|
www: [
|
||||||
|
{
|
||||||
|
title: '最新比赛',
|
||||||
|
docs: 'https://docs.rsshub.app/programming.html#codeforces-zui-xin-bi-sai',
|
||||||
|
source: ['/contests'],
|
||||||
|
target: '/codeforces/contests',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/codeforces/router.js
Normal file
3
lib/v2/codeforces/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/contests', require('./contests'));
|
||||||
|
};
|
||||||
11
lib/v2/codeforces/templates/contest.art
Normal file
11
lib/v2/codeforces/templates/contest.art
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<text>比赛:{{ title }}</text>
|
||||||
|
<br>
|
||||||
|
<text>开始时间:{{ startTime }}</text>
|
||||||
|
<br>
|
||||||
|
<text>持续时间:{{ durationTime }} 分钟</text>
|
||||||
|
<br>
|
||||||
|
<text>相对时间:{{ relativeTime }} 分钟</text>
|
||||||
|
<br>
|
||||||
|
<text>比赛类型:{{ type }}</text>
|
||||||
|
<br>
|
||||||
|
|
||||||
Reference in New Issue
Block a user