lscontests 1.2.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +34 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/contest.d.ts +9 -0
- package/dist/lib/contest.js +3 -0
- package/dist/lib/contest.js.map +1 -0
- package/dist/lib/oj/codeforces.d.ts +2 -0
- package/dist/lib/oj/codeforces.js +37 -0
- package/dist/lib/oj/codeforces.js.map +1 -0
- package/dist/lib/oj/luogu.d.ts +2 -0
- package/dist/lib/oj/luogu.js +44 -0
- package/dist/lib/oj/luogu.js.map +1 -0
- package/dist/lib/oj/nowcoder.d.ts +5 -0
- package/dist/lib/oj/nowcoder.js +79 -0
- package/dist/lib/oj/nowcoder.js.map +1 -0
- package/dist/lib/oj.d.ts +9 -0
- package/dist/lib/oj.js +16 -0
- package/dist/lib/oj.js.map +1 -0
- package/package.json +9 -15
- package/bin/cli.js +0 -84
package/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# lscontests
|
2
2
|
|
3
|
+

|
3
4
|

|
4
5
|

|
5
6
|
[](https://github.com/semantic-release/semantic-release)
|
7
|
+
|
6
8
|

|
9
|
+

|
7
10
|
|
8
11
|
A CLI tool to get information about the contests on each OJ
|
9
12
|
|
@@ -13,9 +16,11 @@ A CLI tool to get information about the contests on each OJ
|
|
13
16
|
lsct [options]
|
14
17
|
|
15
18
|
Options:
|
16
|
-
-V, --version
|
17
|
-
-
|
18
|
-
-
|
19
|
+
-V, --version output the version number
|
20
|
+
-d, --days, <day> Number of days to get contests information (default: "3")
|
21
|
+
-l, --list List all supported OJ
|
22
|
+
-o, --oj <ojs...> OJs to get contests information (choices: "cf", "lg", "nc")
|
23
|
+
-h, --help display help for command
|
19
24
|
```
|
20
25
|
|
21
26
|
## License
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
"use strict";
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10
|
+
});
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
const package_json_1 = require("../package.json");
|
14
|
+
const commander_1 = require("commander");
|
15
|
+
const oj_1 = require("./lib/oj");
|
16
|
+
const _1 = require(".");
|
17
|
+
commander_1.program
|
18
|
+
.name("lsct")
|
19
|
+
.version(package_json_1.version)
|
20
|
+
.option("-d, --days, <day>", "Number of days to get contests information", "3")
|
21
|
+
.option("-l, --list", "List all supported OJ")
|
22
|
+
.addOption(new commander_1.Option("-o, --oj <ojs...>", "OJs to get contests information").choices(Object.keys(oj_1.alloj)))
|
23
|
+
.parse();
|
24
|
+
const opts = commander_1.program.opts();
|
25
|
+
function main() {
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
27
|
+
if (opts.list)
|
28
|
+
console.log(Object.values(oj_1.alloj).map((oj) => oj.name));
|
29
|
+
else
|
30
|
+
console.log(yield (0, _1.list)(opts.oj, opts.days));
|
31
|
+
});
|
32
|
+
}
|
33
|
+
main();
|
34
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kDAA0C;AAC1C,yCAA4C;AAC5C,iCAAiC;AACjC,wBAAyB;AAEzB,mBAAO;KACF,IAAI,CAAC,MAAM,CAAC;KACZ,OAAO,CAAC,sBAAO,CAAC;KAChB,MAAM,CAAC,mBAAmB,EAAE,4CAA4C,EAAE,GAAG,CAAC;KAC9E,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC;KAC7C,SAAS,CAAC,IAAI,kBAAM,CAAC,mBAAmB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAK,CAAC,CAAC,CAAC;KACzG,KAAK,EAAE,CAAC;AAEb,MAAM,IAAI,GAAG,mBAAO,CAAC,IAAI,EAAE,CAAC;AAE5B,SAAe,IAAI;;QACf,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,UAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;;YACjE,OAAO,CAAC,GAAG,CAAC,MAAM,IAAA,OAAI,EAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAc,CAAC,CAAC,CAAC;IAC/D,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,25 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.list = exports.addOJ = void 0;
|
13
|
+
const oj_1 = require("./lib/oj");
|
14
|
+
Object.defineProperty(exports, "addOJ", { enumerable: true, get: function () { return oj_1.addOJ; } });
|
15
|
+
function list(abbrList, days) {
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
17
|
+
if (!abbrList)
|
18
|
+
abbrList = Object.keys(oj_1.alloj);
|
19
|
+
return (yield Promise.all(abbrList.map((abbr) => __awaiter(this, void 0, void 0, function* () {
|
20
|
+
return (yield oj_1.alloj[abbr].get()).filter((ct) => ct.startTime <= new Date(Date.now() + days * 86400000));
|
21
|
+
})))).reduce((ls1, ls2) => ls1.concat(ls2));
|
22
|
+
});
|
23
|
+
}
|
24
|
+
exports.list = list;
|
25
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAwC;AAa/B,sFAbA,UAAK,OAaA;AAXd,SAAe,IAAI,CAAC,QAAkB,EAAE,IAAY;;QAChD,IAAI,CAAC,QAAQ;YAAE,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,UAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CACrB,QAAQ,CAAC,GAAG,CACR,CAAO,IAAI,EAAE,EAAE;YAAC,OAAA,CAAC,MAAM,UAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAC5C,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAI,IAAe,GAAG,QAAQ,CAAC,CAC7E,CAAA;UAAA,CACJ,CACJ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;CAAA;AAEe,oBAAI"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"contest.js","sourceRoot":"","sources":["../../src/lib/contest.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,37 @@
|
|
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
|
+
exports.cf = void 0;
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
17
|
+
const ruleRecord = {
|
18
|
+
CF: "Codeforces",
|
19
|
+
ICPC: "ICPC"
|
20
|
+
};
|
21
|
+
exports.cf = {
|
22
|
+
name: "Codeforces",
|
23
|
+
get: () => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
+
const resList = (yield axios_1.default.get("https://codeforces.com/api/contest.list")).data.result;
|
25
|
+
return resList.map((res) => {
|
26
|
+
return {
|
27
|
+
ojName: exports.cf.name,
|
28
|
+
name: res.name,
|
29
|
+
rule: ruleRecord[res.type],
|
30
|
+
startTime: new Date(res.startTimeSeconds * 1000),
|
31
|
+
endTime: new Date((res.startTimeSeconds + res.durationSeconds) * 1000),
|
32
|
+
url: `https://codeforces.com/contests/${res.id}`
|
33
|
+
};
|
34
|
+
}).filter((contest) => contest.startTime >= new Date());
|
35
|
+
})
|
36
|
+
};
|
37
|
+
//# sourceMappingURL=codeforces.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"codeforces.js","sourceRoot":"","sources":["../../../src/lib/oj/codeforces.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAe1B,MAAM,UAAU,GAAyB;IACrC,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,MAAM;CACf,CAAC;AAEW,QAAA,EAAE,GAAO;IAClB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,GAAS,EAAE;QACZ,MAAM,OAAO,GAAa,CAAC,MAAM,eAAK,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACnG,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAW,EAAE;YAChC,OAAO;gBACH,MAAM,EAAE,UAAE,CAAC,IAAI;gBACf,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;gBAC1B,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAChD,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;gBACtE,GAAG,EAAE,mCAAmC,GAAG,CAAC,EAAE,EAAE;aACnD,CAAC;QACN,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAA;CACJ,CAAC"}
|
@@ -0,0 +1,44 @@
|
|
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
|
+
exports.lg = void 0;
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
17
|
+
const ruleRecord = {
|
18
|
+
1: "OI",
|
19
|
+
2: "ICPC",
|
20
|
+
3: "LeDuo",
|
21
|
+
4: "IOI",
|
22
|
+
5: "Codeforces"
|
23
|
+
};
|
24
|
+
const headers = {
|
25
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
|
26
|
+
"x-luogu-type": "content-only"
|
27
|
+
};
|
28
|
+
exports.lg = {
|
29
|
+
name: "Luogu",
|
30
|
+
get: () => __awaiter(void 0, void 0, void 0, function* () {
|
31
|
+
const resList = (yield axios_1.default.get("https://www.luogu.com.cn/contest/list", { headers })).data.currentData.contests.result;
|
32
|
+
return resList.map((res) => {
|
33
|
+
return {
|
34
|
+
ojName: exports.lg.name,
|
35
|
+
name: res.name,
|
36
|
+
rule: ruleRecord[res.ruleType],
|
37
|
+
startTime: new Date(res.startTime * 1000),
|
38
|
+
endTime: new Date(res.endTime * 1000),
|
39
|
+
url: `https://www.luogu.com.cn/contest/${res.id}`
|
40
|
+
};
|
41
|
+
}).filter((contest) => contest.startTime >= new Date());
|
42
|
+
})
|
43
|
+
};
|
44
|
+
//# sourceMappingURL=luogu.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"luogu.js","sourceRoot":"","sources":["../../../src/lib/oj/luogu.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAiB1B,MAAM,UAAU,GAAyB;IACrC,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,YAAY;CAClB,CAAC;AAEF,MAAM,OAAO,GAAG;IACZ,YAAY,EAAE,qHAAqH;IACnI,cAAc,EAAE,cAAc;CACjC,CAAC;AAEW,QAAA,EAAE,GAAO;IAClB,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,GAAS,EAAE;QACZ,MAAM,OAAO,GAAa,CAAC,MAAM,eAAK,CAAC,GAAG,CAAC,uCAAuC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;QACnI,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAW,EAAE;YAChC,OAAO;gBACH,MAAM,EAAE,UAAE,CAAC,IAAI;gBACf,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAC9B,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;gBACzC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;gBACrC,GAAG,EAAE,oCAAoC,GAAG,CAAC,EAAE,EAAE;aACpD,CAAC;QACN,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAA;CACJ,CAAC"}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
+
exports.nc = void 0;
|
39
|
+
const axios_1 = __importDefault(require("axios"));
|
40
|
+
const cheerio = __importStar(require("cheerio"));
|
41
|
+
var topCategoryFilter;
|
42
|
+
(function (topCategoryFilter) {
|
43
|
+
topCategoryFilter[topCategoryFilter["NOWCODERSERIES"] = 13] = "NOWCODERSERIES";
|
44
|
+
topCategoryFilter[topCategoryFilter["SCHOOLCONTEST"] = 14] = "SCHOOLCONTEST";
|
45
|
+
})(topCategoryFilter || (topCategoryFilter = {}));
|
46
|
+
const url = "https://ac.nowcoder.com/acm/contest/vip-index";
|
47
|
+
function getResultList(tcf) {
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
49
|
+
const html = (yield axios_1.default.get(`${url}?topCategoryFilter=${tcf}`)).data;
|
50
|
+
const $ = cheerio.load(html);
|
51
|
+
const ls = [];
|
52
|
+
$("div[class='platform-item js-item ']").each(function () {
|
53
|
+
ls.push(JSON.parse(cheerio.load(this.attribs["data-json"]).text()));
|
54
|
+
});
|
55
|
+
return ls;
|
56
|
+
});
|
57
|
+
}
|
58
|
+
const ruleRecord = {
|
59
|
+
0: "ICPC",
|
60
|
+
1: "IOI",
|
61
|
+
2: "OI"
|
62
|
+
};
|
63
|
+
exports.nc = {
|
64
|
+
name: "NowCoder",
|
65
|
+
get: () => __awaiter(void 0, void 0, void 0, function* () {
|
66
|
+
const res = [...yield getResultList(topCategoryFilter.NOWCODERSERIES), ...yield getResultList(topCategoryFilter.SCHOOLCONTEST)];
|
67
|
+
return res.filter((res) => res.signUpEndCountDownTime > 0).map((res) => {
|
68
|
+
return {
|
69
|
+
ojName: exports.nc.name,
|
70
|
+
name: res.contestName,
|
71
|
+
rule: ruleRecord[res.type],
|
72
|
+
startTime: new Date(res.contestStartTime),
|
73
|
+
endTime: new Date(res.contestEndTime),
|
74
|
+
url: `https://ac.nowcoder.com/acm/contest/${res.contestId}`
|
75
|
+
};
|
76
|
+
});
|
77
|
+
})
|
78
|
+
};
|
79
|
+
//# sourceMappingURL=nowcoder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"nowcoder.js","sourceRoot":"","sources":["../../../src/lib/oj/nowcoder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,iDAAmC;AA+CnC,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IAClB,8EAAmB,CAAA;IACnB,4EAAa,CAAA;AACjB,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAM,GAAG,GAAG,+CAA+C,CAAC;AAE5D,SAAe,aAAa,CAAC,GAAsB;;QAC/C,MAAM,IAAI,GAAG,CAAC,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,GAAG,sBAAsB,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACvE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,EAAE,GAAa,EAAE,CAAC;QACxB,CAAC,CAAC,qCAAqC,CAAC,CAAC,IAAI,CAAC;YAC1C,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACd,CAAC;CAAA;AAED,MAAM,UAAU,GAAyB;IACrC,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,IAAI;CACV,CAAC;AAEW,QAAA,EAAE,GAAG;IACd,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,GAAS,EAAE;QACZ,MAAM,GAAG,GAAa,CAAC,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1I,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,sBAAsB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAW,EAAE;YAC5E,OAAO;gBACH,MAAM,EAAE,UAAE,CAAC,IAAI;gBACf,IAAI,EAAE,GAAG,CAAC,WAAW;gBACrB,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;gBAC1B,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC;gBACzC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;gBACrC,GAAG,EAAE,uCAAuC,GAAG,CAAC,SAAS,EAAE;aAC9D,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC,CAAA;CACJ,CAAC"}
|
package/dist/lib/oj.d.ts
ADDED
package/dist/lib/oj.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.addOJ = exports.alloj = void 0;
|
4
|
+
const codeforces_1 = require("./oj/codeforces");
|
5
|
+
const luogu_1 = require("./oj/luogu");
|
6
|
+
const nowcoder_1 = require("./oj/nowcoder");
|
7
|
+
exports.alloj = {
|
8
|
+
cf: codeforces_1.cf,
|
9
|
+
lg: luogu_1.lg,
|
10
|
+
nc: nowcoder_1.nc
|
11
|
+
};
|
12
|
+
function addOJ(abbr, oj) {
|
13
|
+
exports.alloj[abbr] = oj;
|
14
|
+
}
|
15
|
+
exports.addOJ = addOJ;
|
16
|
+
//# sourceMappingURL=oj.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"oj.js","sourceRoot":"","sources":["../../src/lib/oj.ts"],"names":[],"mappings":";;;AACA,gDAAqC;AACrC,sCAAgC;AAChC,4CAAmC;AAOtB,QAAA,KAAK,GAA2B;IACzC,EAAE,EAAF,eAAE;IACF,EAAE,EAAF,UAAE;IACF,EAAE,EAAF,aAAE;CACL,CAAC;AAEF,SAAgB,KAAK,CAAC,IAAY,EAAE,EAAM;IACtC,aAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAFD,sBAEC"}
|
package/package.json
CHANGED
@@ -1,38 +1,32 @@
|
|
1
1
|
{
|
2
2
|
"name": "lscontests",
|
3
|
-
"version": "1.
|
4
|
-
"description": "A
|
3
|
+
"version": "1.5.0",
|
4
|
+
"description": "A tool to get information about the contests on each OJ",
|
5
5
|
"keywords": [
|
6
|
-
"cli",
|
7
6
|
"competitive-programming"
|
8
7
|
],
|
9
8
|
"repository": "https://github.com/StableAgOH/lscontests",
|
10
9
|
"author": "StableAgOH <stagoh17@gmail.com>",
|
11
10
|
"license": "GPL-3.0",
|
12
11
|
"private": false,
|
13
|
-
"main": "./
|
12
|
+
"main": "./dist/index.js",
|
14
13
|
"bin": {
|
15
|
-
"lsct": "./
|
14
|
+
"lsct": "./dist/cli.js"
|
16
15
|
},
|
17
16
|
"files": [
|
18
|
-
"
|
17
|
+
"dist"
|
19
18
|
],
|
20
19
|
"scripts": {
|
21
|
-
"build": "
|
22
|
-
"
|
20
|
+
"build": "rimraf ./dist/* && tsc -p src",
|
21
|
+
"clean": "rimraf ./dist",
|
23
22
|
"prepack": "yarn build"
|
24
23
|
},
|
25
24
|
"dependencies": {
|
26
25
|
"axios": "^0.27.2",
|
26
|
+
"cheerio": "^1.0.0-rc.10",
|
27
27
|
"commander": "^9.2.0"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
|
-
"@babel/core": "^7.17.10",
|
31
|
-
"@babel/preset-env": "^7.17.10",
|
32
|
-
"@babel/preset-typescript": "^7.16.7",
|
33
|
-
"@rollup/plugin-babel": "^5.3.1",
|
34
|
-
"@rollup/plugin-json": "^4.1.0",
|
35
|
-
"@rollup/plugin-node-resolve": "^13.3.0",
|
36
30
|
"@semantic-release/changelog": "^6.0.1",
|
37
31
|
"@semantic-release/git": "^10.0.1",
|
38
32
|
"@types/node": "^17.0.31",
|
@@ -40,7 +34,7 @@
|
|
40
34
|
"@typescript-eslint/parser": "^5.22.0",
|
41
35
|
"cz-conventional-changelog": "3.3.0",
|
42
36
|
"eslint": "^8.14.0",
|
43
|
-
"
|
37
|
+
"rimraf": "^3.0.2",
|
44
38
|
"semantic-release": "^19.0.2",
|
45
39
|
"typescript": "^4.6.4"
|
46
40
|
},
|
package/bin/cli.js
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
var commander = require('commander');
|
5
|
-
var axios = require('axios');
|
6
|
-
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8
|
-
|
9
|
-
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
10
|
-
|
11
|
-
var version = "1.2.0";
|
12
|
-
|
13
|
-
const ruleRecord$1 = {
|
14
|
-
"CF": "Codeforces",
|
15
|
-
"ICPC": "ICPC"
|
16
|
-
};
|
17
|
-
async function get$1() {
|
18
|
-
const result = (await axios__default["default"].get("https://codeforces.com/api/contest.list")).data.result;
|
19
|
-
return result.map(contest => {
|
20
|
-
return {
|
21
|
-
oj: "Codeforces",
|
22
|
-
name: contest.name,
|
23
|
-
rule: ruleRecord$1[contest.type],
|
24
|
-
startTime: new Date(contest.startTimeSeconds * 1000),
|
25
|
-
durationHours: contest.durationSeconds / 60 / 60,
|
26
|
-
url: `https://codeforces.com/contests/${contest.id}`
|
27
|
-
};
|
28
|
-
}).filter(contest => contest.startTime >= new Date());
|
29
|
-
}
|
30
|
-
|
31
|
-
const ruleRecord = {
|
32
|
-
1: "OI",
|
33
|
-
2: "ICPC",
|
34
|
-
3: "LeDuo",
|
35
|
-
4: "IOI",
|
36
|
-
5: "Codeforces"
|
37
|
-
};
|
38
|
-
const headers = {
|
39
|
-
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
|
40
|
-
"x-luogu-type": "content-only"
|
41
|
-
};
|
42
|
-
async function get() {
|
43
|
-
const result = (await axios__default["default"].get("https://www.luogu.com.cn/contest/list", {
|
44
|
-
headers
|
45
|
-
})).data.currentData.contests.result;
|
46
|
-
return result.map(contest => {
|
47
|
-
return {
|
48
|
-
oj: "Luogu",
|
49
|
-
name: contest.name,
|
50
|
-
rule: ruleRecord[contest.ruleType],
|
51
|
-
startTime: new Date(contest.startTime * 1000),
|
52
|
-
durationHours: (contest.endTime - contest.startTime) / 60 / 60,
|
53
|
-
url: `https://www.luogu.com.cn/contest/${contest.id}`
|
54
|
-
};
|
55
|
-
}).filter(contest => contest.startTime >= new Date());
|
56
|
-
}
|
57
|
-
|
58
|
-
const alloj = {
|
59
|
-
"cf": {
|
60
|
-
name: "Codeforces",
|
61
|
-
getter: get$1
|
62
|
-
},
|
63
|
-
"lg": {
|
64
|
-
name: "Luogu",
|
65
|
-
getter: get
|
66
|
-
}
|
67
|
-
};
|
68
|
-
function getGetterList(ojs) {
|
69
|
-
if (!ojs) ojs = Object.keys(alloj);
|
70
|
-
return ojs.map(oj => alloj[oj].getter);
|
71
|
-
}
|
72
|
-
|
73
|
-
async function list(ojs, days) {
|
74
|
-
return (await Promise.all(getGetterList(ojs).map(async get => (await get()).filter(ct => ct.startTime <= new Date(Date.now() + days * 86400000))))).reduce((ls1, ls2) => ls1.concat(ls2));
|
75
|
-
}
|
76
|
-
|
77
|
-
commander.program.name("lsct").version(version).option("-d, --days, <day>", "Number of days to get contests information", "3").option("-l, --list", "List all supported OJ").addOption(new commander.Option("-o, --oj <ojs...>", "OJs to get contests information").choices(Object.keys(alloj))).parse();
|
78
|
-
const opts = commander.program.opts();
|
79
|
-
|
80
|
-
async function main() {
|
81
|
-
if (opts.list) console.log(Object.values(alloj).map(ojd => ojd.name));else console.log(await list(opts.oj, opts.days));
|
82
|
-
}
|
83
|
-
|
84
|
-
main();
|