every day at 10am the script runs

This commit is contained in:
Kfir Dayan 2023-04-02 11:10:44 +03:00
parent 4360499dd0
commit 831dfaaea0
4 changed files with 45 additions and 31 deletions

View file

@ -5,23 +5,9 @@ PRODID:https://mhaifafc.com/
METHOD:PUBLISH
X-PUBLISHED-TTL:PT1H
BEGIN:VEVENT
UID:OOg8oTxogguu8rzrqhISi
UID:XM2mxB4gOmBM4OBkqWWW1
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230330T060421Z
DTSTART:20230401T170000Z
DTEND:20230401T190000Z
DESCRIPTION:Maccabi Haifa vs. H Be'er Sheva
URL:https://mhaifafc.com/
LOCATION:Sammy Ofer Stadium
STATUS:CONFIRMED
CATEGORIES:
ORGANIZER;CN=Maccabi Haifa F.C.
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
UID:dF2NNZZYkoYqyT9lUvRUL
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230330T060421Z
DTSTAMP:20230402T080845Z
DTSTART:20230404T173000Z
DTEND:20230404T193000Z
DESCRIPTION:Maccabi Tel aviv vs. Maccabi Haifa
@ -33,9 +19,9 @@ ORGANIZER;CN=Maccabi Haifa F.C.
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
UID:w1jpYkmLHn22sPStvLVvX
UID:7P2E8_IBsTYsJlGkVZu7u
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230330T060421Z
DTSTAMP:20230402T080845Z
DTSTART:20230408T170000Z
DTEND:20230408T190000Z
DESCRIPTION:Maccabi Haifa vs. Maccabi Netanya
@ -47,9 +33,9 @@ ORGANIZER;CN=Maccabi Haifa F.C.
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
UID:Ltl5msGiuujEh6aXPj7R6
UID:cMHqpY5PoYZOG_IizeMXS
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230330T060421Z
DTSTAMP:20230402T080845Z
DTSTART:20230415T153000Z
DTEND:20230415T173000Z
DESCRIPTION:Hapoel Jerusalem vs. Maccabi Haifa
@ -61,9 +47,9 @@ ORGANIZER;CN=Maccabi Haifa F.C.
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
UID:mhXQ-EHi3UTLDyP_f0X7C
UID:Z80kiSCKPEMLud1BUFxia
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230330T060421Z
DTSTAMP:20230402T080845Z
DTSTART:20230423T173000Z
DTEND:20230423T193000Z
DESCRIPTION:F.C Ashdod vs. Maccabi Haifa
@ -75,9 +61,9 @@ ORGANIZER;CN=Maccabi Haifa F.C.
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
UID:rlUHEdqvIN_bym5lWst2Q
UID:mndtB--cUk1MicazqF1lv
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230330T060421Z
DTSTAMP:20230402T080845Z
DTSTART:20230501T173000Z
DTEND:20230501T193000Z
DESCRIPTION:H Be'er Sheva vs. Maccabi Haifa

17
package-lock.json generated
View file

@ -6,6 +6,7 @@
"": {
"dependencies": {
"axios": "^1.3.4",
"cron": "^2.3.0",
"dotenv": "^16.0.3",
"googleapis": "^113.0.0",
"ics": "^3.1.0",
@ -132,6 +133,14 @@
"node": ">= 0.8"
}
},
"node_modules/cron": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/cron/-/cron-2.3.0.tgz",
"integrity": "sha512-ZN5HP8zDY41sJolMsbc+GksRATcbvkPKF5wR/qc8FrV4NBVi9ORQa1HmYa5GydaysUB80X9XpRlRkooa5uEtTA==",
"dependencies": {
"luxon": "^3.2.1"
}
},
"node_modules/css-select": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz",
@ -530,6 +539,14 @@
"node": ">=10"
}
},
"node_modules/luxon": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==",
"engines": {
"node": ">=12"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",

View file

@ -1,6 +1,7 @@
{
"dependencies": {
"axios": "^1.3.4",
"cron": "^2.3.0",
"dotenv": "^16.0.3",
"googleapis": "^113.0.0",
"ics": "^3.1.0",

View file

@ -3,6 +3,8 @@ import GameSource from './GameSource';
import fs from 'fs';
import Ics from './Ics';
const CronJob = require('cron').CronJob;
class App {
googleCalendar: GoogleCalendar;
@ -31,11 +33,19 @@ class App {
const app = new App();
const start = async () => {
const job = new CronJob(
"0 10 * * *",
async () => {
console.log("START")
const outputFileLocation = 'maccabi-haifa-fc.ics';
const games = await app.gameSource.getGamesFromHaifa();
const icsEvents = app.ics.generateIcsOutputFromGames(games);
fs.writeFileSync(outputFileLocation, icsEvents);
}
},
null,
true,
'Asia/Jerusalem'
);
start();