chore: Idk
This commit is contained in:
@@ -13,7 +13,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import parseV1V2 from "./parse/v1_v2.js";
|
import parseV1V2 from "./parse/v1_v2.js";
|
||||||
|
import parseV3 from "./parse/v3.js";
|
||||||
|
|
||||||
export default async function parseThisShit(downloadedFilePath) {
|
export default async function parseThisShit(downloadedFilePath) {
|
||||||
await parseV1V2(downloadedFilePath)
|
await parseV1V2(downloadedFilePath);
|
||||||
|
await parseV3("db/v2.json"); // NEEDS TO BE RAN AFTER V2 (uses its format)
|
||||||
}
|
}
|
||||||
|
|||||||
43
scrape/parse/v3.js
Normal file
43
scrape/parse/v3.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Jakub Žitník
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import parseTeachers from "../utils/parseTeachers.js"
|
||||||
|
import fs from "fs/promises";
|
||||||
|
|
||||||
|
const PREVIOUS = "db/v3/_previous.json";
|
||||||
|
|
||||||
|
export default async function parseV3(fileV2Path) {
|
||||||
|
const previousStr = fs.readFile(PREVIOUS, {
|
||||||
|
encoding: "utf8",
|
||||||
|
});
|
||||||
|
const nowStr = fs.readFile(fileV2Path, {
|
||||||
|
encoding: "utf8",
|
||||||
|
})
|
||||||
|
|
||||||
|
const previous = JSON.parse(previousStr);
|
||||||
|
const previousDays = previous.props.map(prop => prop.date);
|
||||||
|
const now = JSON.parse(nowStr);
|
||||||
|
|
||||||
|
for (const prop of now.props) {
|
||||||
|
if (!previousDays.includes(prop.date)) {
|
||||||
|
doWholeDay(prop);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Check for changes for each class, if any change is do the class (will do someday)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHANGE PREVIOUS TO NOW
|
||||||
|
fs.copyFile(fileV2Path, PREVIOUS);
|
||||||
|
}
|
||||||
@@ -1,3 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Jakub Žitník
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { CookieJar } from "tough-cookie";
|
import { CookieJar } from "tough-cookie";
|
||||||
import { wrapper } from "axios-cookiejar-support";
|
import { wrapper } from "axios-cookiejar-support";
|
||||||
|
|||||||
28
scripts/setup.js
Normal file
28
scripts/setup.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Jakub Žitník
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
|
const DIRS = [
|
||||||
|
"db/persistent",
|
||||||
|
"db/v3",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const dir of DIRS) {
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(dir);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LEAVE ME ALONE I KNOW THIS CODE IS SHIT
|
||||||
Reference in New Issue
Block a user