Skip to content

Commit

Permalink
Merge pull request #501 from touhidurrr/fix-eolymp
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle authored Oct 14, 2024
2 parents d96135d + cffd65a commit 46c1ffa
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/parsers/problem/EolympBasecampProblemParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@ import { Parser } from '../Parser';

export class EolympBasecampProblemParser extends Parser {
public getMatchPatterns(): string[] {
return ['https://basecamp.eolymp.com/*/problem/*'];
return ['https://basecamp.eolymp.com/*/problems/*', 'https://basecamp.eolymp.com/*/compete/*/problem/*'];
}

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

task.setName(elem.querySelector('.tab-content h1 span').textContent);
const contentElem = elem.querySelector(url.includes('compete') ? '.tab-content' : '.content');

task.setName(contentElem.querySelector('h1 > span.ecm-span').textContent);

const contestName = elem.querySelector('.drawer span.MuiTypography-headlineSmall')?.textContent;
if (contestName && contestName !== task.name) {
if (contestName && contestName !== task.name && contestName !== 'Basecamp') {
task.setCategory(`Basecamp - ${contestName}`);
} else {
task.setCategory('Basecamp');
}

const [timeLimit, memoryLimit] = [...document.querySelectorAll('.tab-content span.MuiTypography-bodyMedium')].map(
span => span.childNodes[1]?.textContent,
);

task.setTimeLimit(parseFloat(/\d+/.exec(timeLimit)[0]) * 1000);
task.setMemoryLimit(parseInt(/\d+/.exec(memoryLimit)[0], 10));
const [timeLimit, memoryLimit] = [...contentElem.querySelectorAll('span.MuiTypography-bodyMedium')];
task.setTimeLimit(parseFloat(/\d+/.exec(timeLimit.textContent)[0]) * 1000);
task.setMemoryLimit(parseInt(/\d+/.exec(memoryLimit.textContent)[0], 10));

const inputOutputBlocks = [...document.querySelectorAll('.tab-content pre')];
const inputOutputBlocks = [...contentElem.querySelectorAll('pre')];
for (let i = 1; i < inputOutputBlocks.length; i += 2) {
task.addTest(inputOutputBlocks[i - 1].textContent, inputOutputBlocks[i].textContent);
}
Expand Down

0 comments on commit 46c1ffa

Please sign in to comment.