Skip to content

Commit

Permalink
Properly set judge name on oiClass problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Sep 28, 2024
1 parent baa2737 commit 4cdad54
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
10 changes: 3 additions & 7 deletions src/parsers/contest/HydroContestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ export class HydroContestParser extends SimpleContestParser {
protected linkSelector = '.col--problem.col--problem-name > a';
protected problemParser = new HydroProblemParser();

public getMatchPatterns(): string[] {
const patterns = [];

for (const domain of ['hydro.ac', 'oiclass.com']) {
patterns.push(`https://${domain}/contest/*`);
}
protected domain = 'hydro.ac';

return patterns;
public getMatchPatterns(): string[] {
return [`https://${this.domain}/contest/*`];
}
}
8 changes: 8 additions & 0 deletions src/parsers/contest/OIClassContestParser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { OIClassProblemParser } from '../problem/OIClassProblemParser';
import { HydroContestParser } from './HydroContestParser';

export class OIClassContestParser extends HydroContestParser {
protected problemParser = new OIClassProblemParser();

protected domain = 'oiclass.com';
}
5 changes: 5 additions & 0 deletions src/parsers/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { LanqiaoContestParser } from './contest/LanqiaoContestParser';
import { LibreOJContestParser } from './contest/LibreOJContestParser';
import { LuoguContestParser } from './contest/LuoguContestParser';
import { NOJContestParser } from './contest/NOJContestParser';
import { OIClassContestParser } from './contest/OIClassContestParser';
import { OpenJudgeContestParser } from './contest/OpenJudgeContestParser';
import { PEGJudgeContestParser } from './contest/PEGJudgeContestParser';
import { POJContestParser } from './contest/POJContestParser';
Expand Down Expand Up @@ -104,6 +105,7 @@ import { NepsAcademyProblemParser } from './problem/NepsAcademyProblemParser';
import { NewtonSchoolProblemParser } from './problem/NewtonSchoolProblemParser';
import { NOJProblemParser } from './problem/NOJProblemParser';
import { NowCoderProblemParser } from './problem/NowCoderProblemParser';
import { OIClassProblemParser } from './problem/OIClassProblemParser';
import { OmegaUpProblemParser } from './problem/OmegaUpProblemParser';
import { OpenJudgeProblemParser } from './problem/OpenJudgeProblemParser';
import { OTOGProblemParser } from './problem/OTOGProblemParser';
Expand Down Expand Up @@ -285,6 +287,9 @@ export const parsers: Parser[] = [

new NowCoderProblemParser(),

new OIClassProblemParser(),
new OIClassContestParser(),

new OmegaUpProblemParser(),

new OpenJudgeProblemParser(),
Expand Down
15 changes: 5 additions & 10 deletions src/parsers/problem/HydroProblemParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@ import { htmlToElement } from '../../utils/dom';
import { Parser } from '../Parser';

export class HydroProblemParser extends Parser {
public getMatchPatterns(): string[] {
const patterns = [];

for (const domain of ['hydro.ac', 'oiclass.com']) {
for (const path of ['p/*', 'd/*/p/*', 'contest/*/p/*']) {
patterns.push(`https://${domain}/${path}`);
}
}
protected domain = 'hydro.ac';
protected judge = 'Hydro';

return patterns;
public getMatchPatterns(): string[] {
return [`https://${this.domain}/p/*`, `https://${this.domain}/d/*/p/*`, `https://${this.domain}/contest/*/p/*`];
}

public async parse(url: string, html: string): Promise<Sendable> {
const elem = htmlToElement(html);
const task = new TaskBuilder('Hydro').setUrl(url);
const task = new TaskBuilder(this.judge).setUrl(url);

task.setName(elem.querySelector('.section__title').lastChild.textContent.trim());

Expand Down
6 changes: 6 additions & 0 deletions src/parsers/problem/OIClassProblemParser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { HydroProblemParser } from './HydroProblemParser';

export class OIClassProblemParser extends HydroProblemParser {
protected domain = 'oiclass.com';
protected judge = 'oiClass';
}

0 comments on commit 4cdad54

Please sign in to comment.