Skip to content

Commit 2a6b605

Browse files
Add support for kaggle
1 parent 0de2087 commit 2a6b605

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
22
package-lock.json
33
.DS_Store
4-
dist/
4+
dist/
5+
secrets.json

src/parsers/kaggle.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const axios = require("axios");
2+
const { kaggleUsername, kaggleApiKey } = require("../../secrets.json");
3+
const { parserErrorHandler, getCurrentTimeInSeconds } = require('./../utils');
4+
5+
const KAGGLE_API_URL = "https://www.kaggle.com/api/v1/competitions/list";
6+
const KAGGLE = 'kaggle';
7+
8+
const isContestActive = (currentTimeInSeconds) => contest => contest.endTime > currentTimeInSeconds
9+
10+
const convertToStandardContest = contest => ({
11+
name: contest.title,
12+
url: contest.url,
13+
platform: KAGGLE,
14+
startTime: Date.parse(contest.enabledDate) / 1000,
15+
endTime: Date.parse(contest.deadline) / 1000,
16+
});
17+
18+
const kaggle = () => axios.get(KAGGLE_API_URL, {
19+
timeout: 15000,
20+
auth: {
21+
username: kaggleUsername,
22+
password: kaggleApiKey,
23+
},
24+
})
25+
.then(response => response.data
26+
.map(convertToStandardContest)
27+
.filter(isContestActive(getCurrentTimeInSeconds()))
28+
)
29+
.catch(parserErrorHandler(KAGGLE));
30+
31+
module.exports = kaggle;

src/runner.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const codechef = require('./parsers/codechef');
1111
const atcoder = require('./parsers/atcoder');
1212
const csacademy = require('./parsers/csacademy');
1313
const coj = require('./parsers/coj');
14+
const kaggle = require('./parsers/kaggle');
1415

1516
const runner = () => axios.all([
1617
codeforces(),
@@ -22,6 +23,7 @@ const runner = () => axios.all([
2223
atcoder(),
2324
csacademy(),
2425
coj(),
26+
kaggle(),
2527
])
2628
.then((contestsByPlatform) => {
2729
const contests = flat(contestsByPlatform.filter(it => Array.isArray(it)));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy