2016-04-15 12:18:59 +02:00
/ * C a l e n d a r F e t c h e r T e s t e r
2016-12-30 17:47:33 -03:00
* use this script with ` node debug.js ` to test the fetcher without the need
2016-04-15 12:18:59 +02:00
* of starting the MagicMirror core . Adjust the values below to your desire .
*
2020-04-28 23:05:28 +02:00
* By Michael Teeuw https : //michaelteeuw.nl
2016-04-15 12:18:59 +02:00
* MIT Licensed .
* /
2020-06-20 08:45:46 +02:00
const CalendarFetcher = require ( "./calendarfetcher.js" ) ;
const url = "https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics" ; // Standard test URL
//const url = "https://www.googleapis.com/calendar/v3/calendars/primary/events/"; // URL for Bearer auth (must be configured in Google OAuth2 first)
const fetchInterval = 60 * 60 * 1000 ;
const maximumEntries = 10 ;
const maximumNumberOfDays = 365 ;
const user = "magicmirror" ;
const pass = "MyStrongPass" ;
const auth = {
2017-03-07 00:12:43 +01:00
user : user ,
pass : pass
} ;
2016-04-15 12:18:59 +02:00
2016-12-01 19:48:53 -03:00
console . log ( "Create fetcher ..." ) ;
2016-04-15 12:18:59 +02:00
2020-06-20 08:45:46 +02:00
const fetcher = new CalendarFetcher ( url , fetchInterval , [ ] , maximumEntries , maximumNumberOfDays , auth ) ;
2016-04-15 12:18:59 +02:00
2020-05-11 22:22:32 +02:00
fetcher . onReceive ( function ( fetcher ) {
2016-12-01 19:48:53 -03:00
console . log ( fetcher . events ( ) ) ;
console . log ( "------------------------------------------------------------" ) ;
2016-04-15 12:18:59 +02:00
} ) ;
2020-05-11 22:22:32 +02:00
fetcher . onError ( function ( fetcher , error ) {
2016-04-15 12:18:59 +02:00
console . log ( "Fetcher error:" ) ;
console . log ( error ) ;
} ) ;
fetcher . startFetch ( ) ;
2019-12-31 11:19:30 +01:00
console . log ( "Create fetcher done! " ) ;