How to use the node-ical.fromURL function in node-ical

To help you get started, we’ve selected a few node-ical examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grover / homebridge-calendar / src / CalendarPoller.js View on Github external
_loadCalendar() {
    // TODO: Make use of HTTP cache control stuff
    this.log(`Updating calendar ${this.name}`);
    ical.fromURL(this._url, {}, (err, cal) => {
      if (err) {
        this.log(`Failed to load iCal calender: ${this.url} with error ${err}`);
        this.emit('error', err);
      }

      if (cal) {
        this.emit('data', cal);
      }

      this._scheduleNextIteration();
    });
  }
github Giveth / giveth-bot / chatbot.js View on Github external
if (message[1] === ' ') {
      message = message.replace(' ', '')
    }
    message = message.split(' ')
    const cmd = message[0]
    let localHashtag = ''
    if (message.length > 1) {
      localHashtag = message[1].toLowerCase()
    }
    const user = event.getSender()
    const roomId = room.roomId
    if (cmd === '!calendar' || cmd === '!cal') {
      if (localHashtag.length == 0 && hashtagMappings.hasOwnProperty(roomId)) {
        localHashtag = hashtagMappings[roomId]
      }
      ical.fromURL(calendarURL, {}, function(err, data) {
        if (!err) {
          const today = new Date()
          const upperLimit = new Date()
          upperLimit.setDate(today.getDate() + calendarUpperLimitInMonths * 30)
          const globalFormattingOptions = {
            weekday: 'long',
            year: 'numeric',
            month: 'long',
            day: 'numeric',
          }
          globals = []
          locals = []
          for (var key in data) {
            if (data.hasOwnProperty(key) && data[key].start && data[key].end) {
              if (data[key].rrule && data[key].start.tz) {
                var nextOccurrences = data[key].rrule.between(
github naimo84 / node-red-contrib-ical-events / src / caldav.ts View on Github external
for (let calendarObject of calendarEntry.calendar.objects) {
                                        if (calendarObject.data && calendarObject.data.href) {
                                            let ics = url.origin + calendarObject.data.href;
                                            let header = {};
                                            let username = node.config.username;
                                            let password = node.config.password;
                                            if (username && password) {
                                                var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
                                                header = {
                                                    headers: {
                                                        'Authorization': auth
                                                    }
                                                }
                                            }

                                           return ical.fromURL(ics, header).then(data => {
                                                for (var k in data) {
                                                    var ev = data[k];
                                                    ev.calendarName = calendar.displayName;
                                                    retEntries[ev.uid] = ev;
                                                }                                              
                                                return retEntries;
                                            });
                                        }
                                    }
                                }
                            }
                        })
                    );
github naimo84 / node-red-contrib-ical-events / dist / caldav.js View on Github external
for (var _a = 0, _b = calendarEntry.calendar.objects; _a < _b.length; _a++) {
                                var calendarObject = _b[_a];
                                if (calendarObject.data && calendarObject.data.href) {
                                    var ics = url.origin + calendarObject.data.href;
                                    var header = {};
                                    var username = node.config.username;
                                    var password = node.config.password;
                                    if (username && password) {
                                        var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
                                        header = {
                                            headers: {
                                                'Authorization': auth
                                            }
                                        };
                                    }
                                    return ical.fromURL(ics, header).then(function (data) {
                                        for (var k in data) {
                                            var ev = data[k];
                                            ev.calendarName = calendar.displayName;
                                            retEntries[ev.uid] = ev;
                                        }
                                        return retEntries;
                                    });
                                }
                            }
                        }
                    }
                }));
            }
github naimo84 / node-red-contrib-ical-events / dist / helper.js View on Github external
});
    }
    else {
        if (urlOrFile.match(/^https?:\/\//)) {
            var header = {};
            var username = node.config.username;
            var password = node.config.password;
            if (username && password) {
                var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
                header = {
                    headers: {
                        'Authorization': auth
                    }
                };
            }
            ical.fromURL(node.config.url, header, function (err, data) {
                if (err) {
                    callback && callback(err, null);
                    return;
                }
                callback && callback(null, data);
            });
        }
        else {
            ical.parseFile(node.config.url, function (err, data) {
                if (err) {
                    callback && callback(err, null);
                    return;
                }
                callback && callback(null, data);
            });
        }
github naimo84 / node-red-contrib-ical-events / src / helper.ts View on Github external
} else {
        if (urlOrFile.match(/^https?:\/\//)) {
            let header = {};
            let username = node.config.username;
            let password = node.config.password;

            if (username && password) {
                var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
                header = {
                    headers: {
                        'Authorization': auth
                    }
                }
            }

            ical.fromURL(node.config.url, header, (err, data) => {
                if (err) {
                    callback && callback(err, null);
                    return;
                }
                callback && callback(null, data);
            });
        } else {
            ical.parseFile(node.config.url, (err, data) => {
                if (err) {
                    callback && callback(err, null);
                    return;
                }
                callback && callback(null, data);
            });
        }
    }

node-ical

NodeJS class for parsing iCalendar/ICS files

Apache-2.0
Latest version published 7 days ago

Package Health Score

84 / 100
Full package analysis