From 557e7eb778fe85a82d922334131ebc66077cf338 Mon Sep 17 00:00:00 2001 From: webbrain-one <295484252+webbrain-one@users.noreply.github.com> Date: Tue, 11 Aug 2026 05:16:30 +0300 Subject: [PATCH] Use mvhs-schedule package for period lookup Integrate the mvhs-schedule npm package to fetch period data directly from mvhs.io's Firebase backend. This ensures the schedule is always up-to-date and actively maintained by Mr. Nguyen. The library caches data for 30 minutes and falls back to the stale cache when offline. --- index.js | 12 ++++++++++++ package.json | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6003a02..f6574c1 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ const yaml = require("js-yaml"); const Validator = require("./Validator"); const fs = require("fs"); const path = require("path"); +const { getSchedule } = require("mvhs-schedule"); const filesNeedFixing = []; @@ -57,6 +58,17 @@ for (let key in directory) { continue; } + if (key === "mvhs") { + const scheduleData = getSchedule(); + obj[key] = { + name: directory[key].name, + school: JSON.stringify(yaml.safeLoad(readFile(`./data/${folder}/school.yml`))), + schedule: JSON.stringify(scheduleData.schedule), + periods: JSON.stringify(scheduleData.periods), + }; + continue; + } + obj[key] = { name: directory[key].name, ...loadSchool(folder), diff --git a/package.json b/package.json index 8659bcf..aff625c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "homepage": "https://github.com/arjunpat/timing-data#readme", "dependencies": { - "js-yaml": "^3.14.2" + "js-yaml": "^3.14.2", + "mvhs-schedule": "^1.0.0" } }