Compare commits
No commits in common. "90bb926341d897ebe08fa5e0c129b9d0c610a68d" and "d512ca8197f7ab29683ef0081c3ad7c6919dbe0d" have entirely different histories.
90bb926341
...
d512ca8197
2 changed files with 26 additions and 13 deletions
12
src/Ics.ts
12
src/Ics.ts
|
@ -12,33 +12,31 @@ export default class Ics {
|
||||||
output.push(this.generateIcsOutputFromGame(game));
|
output.push(this.generateIcsOutputFromGame(game));
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(output)
|
|
||||||
const { error, value } = ics.createEvents(output);
|
const { error, value } = ics.createEvents(output);
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(value);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
|
generateIcsOutputFromGame = (game: GoogleCalendarEvent) => {
|
||||||
const { summary, location, description, start, end } = game;
|
const { summary, location, description, start, end } = game;
|
||||||
const icsEvent: ics.EventAttributes = {
|
const icsEvent: ics.EventAttributes = {
|
||||||
title: description,
|
title: summary,
|
||||||
description,
|
description,
|
||||||
location,
|
location,
|
||||||
start: [start.dateTime[0], start.dateTime[1], start.dateTime[2], start.dateTime[3], start.dateTime[4]],
|
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]],
|
end: [end.dateTime[0], end.dateTime[1], end.dateTime[2], end.dateTime[3], end.dateTime[4]],
|
||||||
|
url: 'https://mhaifafc.com/',
|
||||||
status: 'CONFIRMED',
|
status: 'CONFIRMED',
|
||||||
busyStatus: "BUSY",
|
busyStatus: 'BUSY',
|
||||||
productId: '-//kfir.dayanhub.com',
|
productId: 'https://mhaifafc.com/',
|
||||||
recurrenceRule: '',
|
recurrenceRule: '',
|
||||||
attendees: [],
|
attendees: [],
|
||||||
alarms: [],
|
alarms: [],
|
||||||
categories: [],
|
categories: [],
|
||||||
organizer: { name: 'Maccabi Haifa F.C.', email: '' },
|
organizer: { name: 'Maccabi Haifa F.C.', email: '' }
|
||||||
};
|
};
|
||||||
return icsEvent;
|
return icsEvent;
|
||||||
}
|
}
|
||||||
|
|
27
src/index.ts
27
src/index.ts
|
@ -1,3 +1,4 @@
|
||||||
|
// import GoogleCalendar from './GoogleCalendar';
|
||||||
import GameSource from './GameSource';
|
import GameSource from './GameSource';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import Ics from './Ics';
|
import Ics from './Ics';
|
||||||
|
@ -7,15 +8,29 @@ import env from 'dotenv';
|
||||||
env.config();
|
env.config();
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
// googleCalendar: GoogleCalendar;
|
||||||
gameSource: GameSource;
|
gameSource: GameSource;
|
||||||
ics: Ics;
|
ics: Ics;
|
||||||
googleToken: string;
|
googleToken: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
// this.googleCalendar = new GoogleCalendar();
|
||||||
this.gameSource = new GameSource();
|
this.gameSource = new GameSource();
|
||||||
this.ics = new Ics();
|
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() {
|
async startCronJob() {
|
||||||
console.log("START CRON JOB")
|
console.log("START CRON JOB")
|
||||||
const CronJob = require('cron').CronJob;
|
const CronJob = require('cron').CronJob;
|
||||||
|
@ -27,16 +42,16 @@ class App {
|
||||||
console.log("Getting games from Haifa")
|
console.log("Getting games from Haifa")
|
||||||
const games = await app.gameSource.getGamesFromHaifa();
|
const games = await app.gameSource.getGamesFromHaifa();
|
||||||
console.log("Generating ICS file")
|
console.log("Generating ICS file")
|
||||||
const icsEvents = app.ics.generateIcsOutputFromGames([games[0]]);
|
const icsEvents = app.ics.generateIcsOutputFromGames(games);
|
||||||
console.log("Writing ICS file to " + outputFileLocation)
|
console.log("Writing ICS file to " + outputFileLocation)
|
||||||
fs.writeFileSync(outputFileLocation, icsEvents);
|
fs.writeFileSync(outputFileLocation, icsEvents);
|
||||||
console.log("Done Ics file")
|
console.log("Done Ics file")
|
||||||
|
|
||||||
// console.log("converting ics file to ical file")
|
console.log("converting ics file to ical file")
|
||||||
// const outputIcalFileLocation = 'public/maccabi-haifa-fc.ical';
|
const outputIcalFileLocation = 'public/maccabi-haifa-fc.ical';
|
||||||
// const icalEvents = app.ics.convertIcsToIcal(icsEvents);
|
const icalEvents = app.ics.convertIcsToIcal(icsEvents);
|
||||||
// console.log("Writing Ical file to " + outputIcalFileLocation)
|
console.log("Writing Ical file to " + outputIcalFileLocation)
|
||||||
// fs.writeFileSync(outputIcalFileLocation, icalEvents);
|
fs.writeFileSync(outputIcalFileLocation, icalEvents);
|
||||||
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
|
|
Loading…
Reference in a new issue