Compare commits

...

2 commits

Author SHA1 Message Date
Kfir Dayan
90bb926341 removed google api + changing game info 2023-04-16 14:53:59 +03:00
Kfir Dayan
0fea123354 removed google api + changing game info 2023-04-16 14:53:39 +03:00
2 changed files with 13 additions and 26 deletions

View file

@ -12,31 +12,33 @@ export default class Ics {
output.push(this.generateIcsOutputFromGame(game));
});
console.log(output)
const { error, value } = ics.createEvents(output);
if (error) {
console.log(error);
return '';
}
console.log(value);
return value;
}
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
const { summary, location, description, start, end } = game;
const icsEvent: ics.EventAttributes = {
title: summary,
title: description,
description,
location,
start: [start.dateTime[0], start.dateTime[1], start.dateTime[2], start.dateTime[3], start.dateTime[4]],
end: [end.dateTime[0], end.dateTime[1], end.dateTime[2], end.dateTime[3], end.dateTime[4]],
url: 'https://mhaifafc.com/',
status: 'CONFIRMED',
busyStatus: 'BUSY',
productId: 'https://mhaifafc.com/',
busyStatus: "BUSY",
productId: '-//kfir.dayanhub.com',
recurrenceRule: '',
attendees: [],
alarms: [],
categories: [],
organizer: { name: 'Maccabi Haifa F.C.', email: '' }
organizer: { name: 'Maccabi Haifa F.C.', email: '' },
};
return icsEvent;
}

View file

@ -1,4 +1,3 @@
// import GoogleCalendar from './GoogleCalendar';
import GameSource from './GameSource';
import fs from 'fs';
import Ics from './Ics';
@ -8,29 +7,15 @@ import env from 'dotenv';
env.config();
class App {
// googleCalendar: GoogleCalendar;
gameSource: GameSource;
ics: Ics;
googleToken: string;
constructor() {
// this.googleCalendar = new GoogleCalendar();
this.gameSource = new GameSource();
this.ics = new Ics();
}
// async init() {
// console.log("INIT APP")
// await this.googleCalendar.init();
// }
// async getNewGamesAndUpdateCalendar() {
// console.log("GET NEW GAMES AND UPDATE CALENDAR")
// const games = await this.gameSource.getGamesFromHaifa();
// this.googleCalendar.updateNewEvent(games);
// }
async startCronJob() {
console.log("START CRON JOB")
const CronJob = require('cron').CronJob;
@ -42,16 +27,16 @@ class App {
console.log("Getting games from Haifa")
const games = await app.gameSource.getGamesFromHaifa();
console.log("Generating ICS file")
const icsEvents = app.ics.generateIcsOutputFromGames(games);
const icsEvents = app.ics.generateIcsOutputFromGames([games[0]]);
console.log("Writing ICS file to " + outputFileLocation)
fs.writeFileSync(outputFileLocation, icsEvents);
console.log("Done Ics file")
console.log("converting ics file to ical file")
const outputIcalFileLocation = 'public/maccabi-haifa-fc.ical';
const icalEvents = app.ics.convertIcsToIcal(icsEvents);
console.log("Writing Ical file to " + outputIcalFileLocation)
fs.writeFileSync(outputIcalFileLocation, icalEvents);
// console.log("converting ics file to ical file")
// const outputIcalFileLocation = 'public/maccabi-haifa-fc.ical';
// const icalEvents = app.ics.convertIcsToIcal(icsEvents);
// console.log("Writing Ical file to " + outputIcalFileLocation)
// fs.writeFileSync(outputIcalFileLocation, icalEvents);
},
null,