lscontests 1.11.3 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of lscontests might be problematic. Click here for more details.
- package/README.md +10 -25
- package/dist/server.d.ts +1 -0
- package/dist/server.js +107 -0
- package/dist/server.js.map +1 -0
- package/package.json +9 -4
package/README.md
CHANGED
@@ -54,7 +54,7 @@ Options:
|
|
54
54
|
It performs as follows:
|
55
55
|
|
56
56
|
<!-- block_cli begin -->
|
57
|
-
(*The following content was automatically generated using [semantic-release](https://github.com/semantic-release/semantic-release) on
|
57
|
+
(*The following content was automatically generated using [semantic-release](https://github.com/semantic-release/semantic-release) on Tue, 24 May 2022 12:17:18 GMT*)
|
58
58
|
|
59
59
|
<details>
|
60
60
|
<summary> <code>> lsct -L en</code> </summary>
|
@@ -76,14 +76,7 @@ Start time: 5/17/2022, 09:00:00
|
|
76
76
|
End time: 5/24/2022, 14:00:00
|
77
77
|
https://ac.nowcoder.com/acm/contest/34974
|
78
78
|
|
79
|
-
There are 3 contests on Codeforces in the next 3 days
|
80
|
-
|
81
|
-
OJ: Codeforces
|
82
|
-
Contest name: Educational Codeforces Round 129 (Rated for Div. 2)
|
83
|
-
Rule: ICPC
|
84
|
-
Start time: 5/23/2022, 14:35:00
|
85
|
-
End time: 5/23/2022, 16:35:00
|
86
|
-
https://codeforces.com/contests/1681
|
79
|
+
There are 3 contests on Codeforces,NowCoder in the next 3 days
|
87
80
|
|
88
81
|
OJ: Codeforces
|
89
82
|
Contest name: Codeforces Round #794 (Div. 1)
|
@@ -98,6 +91,13 @@ Rule: Codeforces
|
|
98
91
|
Start time: 5/25/2022, 17:35:00
|
99
92
|
End time: 5/25/2022, 19:50:00
|
100
93
|
https://codeforces.com/contests/1686
|
94
|
+
|
95
|
+
OJ: NowCoder
|
96
|
+
Contest name: 牛客练习赛 99
|
97
|
+
Rule: ICPC
|
98
|
+
Start time: 5/27/2022, 11:00:00
|
99
|
+
End time: 5/27/2022, 13:30:00
|
100
|
+
https://ac.nowcoder.com/acm/contest/34330
|
101
101
|
```
|
102
102
|
|
103
103
|
</details>
|
@@ -108,14 +108,7 @@ https://codeforces.com/contests/1686
|
|
108
108
|
```text
|
109
109
|
No running contests
|
110
110
|
|
111
|
-
There are
|
112
|
-
|
113
|
-
OJ: Codeforces
|
114
|
-
Contest name: Educational Codeforces Round 129 (Rated for Div. 2)
|
115
|
-
Rule: ICPC
|
116
|
-
Start time: 5/23/2022, 14:35:00
|
117
|
-
End time: 5/23/2022, 16:35:00
|
118
|
-
https://codeforces.com/contests/1681
|
111
|
+
There are 3 contests on Codeforces,AtCoder in the next 7 days
|
119
112
|
|
120
113
|
OJ: Codeforces
|
121
114
|
Contest name: Codeforces Round #794 (Div. 1)
|
@@ -171,14 +164,6 @@ https://atcoder.jp/contests/ahc011
|
|
171
164
|
"startTime": "2022-05-25T17:35:00.000Z",
|
172
165
|
"endTime": "2022-05-25T19:50:00.000Z",
|
173
166
|
"url": "https://codeforces.com/contests/1686"
|
174
|
-
},
|
175
|
-
{
|
176
|
-
"ojName": "Codeforces",
|
177
|
-
"name": "Educational Codeforces Round 129 (Rated for Div. 2)",
|
178
|
-
"rule": "ICPC",
|
179
|
-
"startTime": "2022-05-23T14:35:00.000Z",
|
180
|
-
"endTime": "2022-05-23T16:35:00.000Z",
|
181
|
-
"url": "https://codeforces.com/contests/1681"
|
182
167
|
}
|
183
168
|
]
|
184
169
|
}
|
package/dist/server.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/dist/server.js
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const express_1 = __importDefault(require("express"));
|
16
|
+
const index_1 = require("./index");
|
17
|
+
const oj_1 = require("./lib/oj");
|
18
|
+
const locale_1 = require("./locale");
|
19
|
+
const ics_1 = require("ics");
|
20
|
+
const pangu_1 = __importDefault(require("pangu"));
|
21
|
+
const crypto_1 = require("crypto");
|
22
|
+
const commander_1 = require("commander");
|
23
|
+
const package_json_1 = require("../package.json");
|
24
|
+
const lodash_1 = __importDefault(require("lodash"));
|
25
|
+
const app = (0, express_1.default)();
|
26
|
+
function assertType(obj) {
|
27
|
+
}
|
28
|
+
app.get("/", (req, res) => {
|
29
|
+
res.redirect("https://github.com/StableAgOH/lscontests");
|
30
|
+
});
|
31
|
+
app.get("/ics", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
32
|
+
const { language, l, ojs, o } = req.query;
|
33
|
+
const lArg = language || l || "zh-CN";
|
34
|
+
let oArg = ojs || o;
|
35
|
+
if (lArg instanceof Array) {
|
36
|
+
res.status(400).send("Multiple languages not supported");
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
if (typeof oArg === "string") {
|
40
|
+
if (oArg.includes(","))
|
41
|
+
oArg = oArg.split(",");
|
42
|
+
else
|
43
|
+
oArg = [oArg];
|
44
|
+
}
|
45
|
+
else if (!oArg)
|
46
|
+
oArg = Object.keys(oj_1.alloj);
|
47
|
+
assertType(oArg);
|
48
|
+
assertType(lArg);
|
49
|
+
const data = yield getIcs(lArg, oArg);
|
50
|
+
res.setHeader("Content-Type", "text/calendar");
|
51
|
+
res.send(data);
|
52
|
+
}));
|
53
|
+
const contestsCache = {
|
54
|
+
contests: [],
|
55
|
+
lastUpdate: 0
|
56
|
+
};
|
57
|
+
function getIcs(lang, ojs) {
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
59
|
+
if (contestsCache.lastUpdate < Date.now() - 1000 * 60 * 5) {
|
60
|
+
const c = yield (0, index_1.getContests)({
|
61
|
+
days: 365 * 10,
|
62
|
+
});
|
63
|
+
contestsCache.contests = lodash_1.default.uniqBy(contestsCache.contests.concat(c.running.concat(c.upcoming)), c => JSON.stringify(c));
|
64
|
+
contestsCache.lastUpdate = Date.now();
|
65
|
+
}
|
66
|
+
const contests = contestsCache.contests.filter(c => ojs.some(oj => c.ojName === oj_1.alloj[oj].name));
|
67
|
+
const langDict = yield (0, locale_1.getLangDict)(lang);
|
68
|
+
const events = contests.map((c) => {
|
69
|
+
const ls = [];
|
70
|
+
ls.push(`${langDict.ojName}: ${c.ojName}`);
|
71
|
+
ls.push(`${langDict.name}: ${c.name}`);
|
72
|
+
ls.push(`${langDict.rule}: ${c.rule}`);
|
73
|
+
ls.push(c.url);
|
74
|
+
const description = pangu_1.default.spacing(ls.join("\n"));
|
75
|
+
const ret = {
|
76
|
+
start: (0, ics_1.convertTimestampToArray)(c.startTime.getTime(), "local"),
|
77
|
+
end: (0, ics_1.convertTimestampToArray)(c.endTime.getTime(), "local"),
|
78
|
+
calName: "算法竞赛",
|
79
|
+
productId: "-//StableAgOH//LSCT//CN",
|
80
|
+
title: c.name,
|
81
|
+
url: c.url,
|
82
|
+
location: c.ojName,
|
83
|
+
categories: [c.rule],
|
84
|
+
uid: `${(0, crypto_1.randomUUID)()}@LSCT`,
|
85
|
+
description,
|
86
|
+
};
|
87
|
+
return ret;
|
88
|
+
});
|
89
|
+
const { value, error } = (0, ics_1.createEvents)(events);
|
90
|
+
if (error)
|
91
|
+
throw error;
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
93
|
+
return value;
|
94
|
+
});
|
95
|
+
}
|
96
|
+
const command = new commander_1.Command()
|
97
|
+
.name(Object.keys(package_json_1.bin)[1])
|
98
|
+
.version(package_json_1.version)
|
99
|
+
.option("-h, --host, <host>", "Host to listen on", "0.0.0.0")
|
100
|
+
.option("-p, --port, <port>", "Port to listen on", "8080");
|
101
|
+
command.parse();
|
102
|
+
const { host, port } = command.opts();
|
103
|
+
app.listen(port, host, () => {
|
104
|
+
const logURL = `http://${host === "0.0.0.0" ? "127.0.0.1" : host}:${port}/`;
|
105
|
+
console.log(`Listening on ${logURL}`);
|
106
|
+
});
|
107
|
+
//# sourceMappingURL=server.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,mCAA6C;AAC7C,iCAA+B;AAC/B,qCAAqC;AACrC,6BAA2E;AAC3E,kDAA0B;AAC1B,mCAAkC;AAClC,yCAAkC;AAClC,kDAA6C;AAC7C,oDAAuB;AAEvB,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAEtB,SAAS,UAAU,CAAI,GAAY;AAGnC,CAAC;AAED,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAEtB,GAAG,CAAC,QAAQ,CAAC,0CAA0C,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;IAE/B,MAAM,EAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC,GAAG,GAAG,CAAC,KAAK,CAAC;IACxC,MAAM,IAAI,GAAG,QAAQ,IAAI,CAAC,IAAI,OAAO,CAAC;IACtC,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC;IAEpB,IAAG,IAAI,YAAY,KAAK,EACxB;QACI,GAAG,CAAC,MAAM,CAAC,GAAG,CA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AAE,CAAC,CAAC,MAAM;gBAClB,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBACpB,GAAG,EAAE,GAAG,IAAA,mBAAU,GAAE,OAAO;gBAC3B,WAAW;aACd,CAAC;YACF,OAAO,GAAG,CAAC;QACf,CAAC,CAAC,CAAC;QACH,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,IAAA,kBAAY,EAAC,MAAM,CAAC,CAAC;QAC5C,IAAG,KAAK;YAAE,MAAM,KAAK,CAAC;QACtB,oEAAoE;QACpE,OAAO,KAAM,CAAC;IAClB,CAAC;CAAA;AAED,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE;KACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACzB,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,SAAS,CAAC;KAC5D,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAC/D,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,MAAM,EAAC,IAAI,EAAE,IAAI,EAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAEpC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;IAExB,MAAM,MAAM,GAAG,UAAU,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC;IAC5E,OAAO,CAAC,GAAG,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lscontests",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.12.0",
|
4
4
|
"description": "A tool to get information about the contests on each OJ",
|
5
5
|
"keywords": [
|
6
6
|
"cli",
|
@@ -18,7 +18,8 @@
|
|
18
18
|
"license": "GPL-3.0",
|
19
19
|
"main": "./dist/index.js",
|
20
20
|
"bin": {
|
21
|
-
"lsct": "./dist/cli.js"
|
21
|
+
"lsct": "./dist/cli.js",
|
22
|
+
"lsct-s": "./dist/server.js"
|
22
23
|
},
|
23
24
|
"files": [
|
24
25
|
"dist"
|
@@ -28,15 +29,17 @@
|
|
28
29
|
"clean": "rimraf ./dist",
|
29
30
|
"docs": "typedoc",
|
30
31
|
"lint": "eslint && markdownlint README.md",
|
31
|
-
"prestart": "yarn build",
|
32
32
|
"release": "mkdirp docs && yarn semantic-release",
|
33
|
-
"start": "
|
33
|
+
"start": "tsx src/cli.ts",
|
34
|
+
"start-s": "tsx src/server.ts"
|
34
35
|
},
|
35
36
|
"dependencies": {
|
36
37
|
"axios": "^0.27.2",
|
37
38
|
"axios-retry": "^3.2.5",
|
38
39
|
"cheerio": "^1.0.0-rc.10",
|
39
40
|
"commander": "^9.2.0",
|
41
|
+
"express": "^4.18.1",
|
42
|
+
"ics": "^2.35.0",
|
40
43
|
"lodash": "^4.17.21",
|
41
44
|
"pangu": "^4.0.7"
|
42
45
|
},
|
@@ -45,6 +48,7 @@
|
|
45
48
|
"@semantic-release/changelog": "^6.0.1",
|
46
49
|
"@semantic-release/exec": "^6.0.3",
|
47
50
|
"@semantic-release/git": "^10.0.1",
|
51
|
+
"@types/express": "^4.17.13",
|
48
52
|
"@types/lodash": "^4.14.182",
|
49
53
|
"@types/node": "^17.0.34",
|
50
54
|
"@types/pangu": "^3.3.0",
|
@@ -56,6 +60,7 @@
|
|
56
60
|
"mkdirp": "^1.0.4",
|
57
61
|
"rimraf": "^3.0.2",
|
58
62
|
"semantic-release": "^19.0.2",
|
63
|
+
"tsx": "*",
|
59
64
|
"typedoc": "^0.22.15",
|
60
65
|
"typedoc-plugin-extras": "^2.2.3",
|
61
66
|
"typescript": "^4.6.4"
|