Giter Club home page Giter Club logo

gas-ics-sync's Introduction

Hi there, I'm Derek

Some things about me:

  • I'm avid outdoorsman: rock climbing πŸ§— , hiking (PCT 2015) πŸ”οΈ , camping πŸ•οΈ - you name it!
  • My biggest hobby is programming πŸ’» and building programs that simplify or automate workflows. If you have a common, tedious workflow that you'd like to automate - send me an email!
  • I dabble a bit in 3D printing - mostly functional printing (adapters, containers, and other small solutions for around the house)
  • I enjoy cooking 🍳 and foods such as ginger beer, root beer, and ice cream!
  • I've been to Turkey three times (so far) and enjoyed it so much that I'm trying to learn Turkish (TΓΌrkΓ§e) & share the culture with others

Some of my biggest & most popular projects:

  • πŸ“… Bulk Edit Calendar Events - a desktop program for editing Google Calendar events in bulk
  • MountainProject - an HTML scraper and reddit bot to link MountainProject.com and various climbing subreddits, replying automatically to posts with climbing information
  • GAS-ICS-Sync - a script for syncing ics/ical calendars to Google Calendar faster than the 12 hour cadence provided natively by Google Calendar

derekantrican's GitHub stats

Top Langs

gas-ics-sync's People

Contributors

allanlewis avatar bestknighter avatar blackwind avatar derekantrican avatar fizzfaldt avatar foxtrotsierra6829 avatar jma127 avatar joelbalmer avatar jonas0b1011001 avatar lbell avatar leog avatar lonestarjeepin avatar mastercko avatar michaelcadilhac avatar non-bin avatar octogonz avatar rufuswilson avatar ruggi99 avatar rupumped avatar simonkotwicz avatar tanoabeleyra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gas-ics-sync's Issues

Script function not found: doGet

Script function not found: doGet

I've got this Error when I publish and open the script.
I noticed about it when I was finding why the Calendar does not update after installing this script.
Thanks for your help.

[Future] Rules

This is a future feature that probably won't be implemented for a while. We have bigger things to focus on before then

Filter Rules: only process events that match certain criteria

Examples (some of these may be multiple rules):

  • "Do not process any event where the title contains 'test'"
  • "Do not process any events on Fridays"
  • "Do not process any events occurring past 11/1/19"

Modification rules: modify event properties before processing the event

Examples (some of these may be multiple rules):

  • "Remove 'FW:' from any event titles" (as requested in #68)
  • "Replace Title with {DESCRIPTION} and Description with {TITLE}" (would be a better approach than our current "flag" setting)
  • "Modify all event start times to happen at 23:00 and end times to happen at 23:59" (as requested in #66)

Rules should be able to access the following properties: Title, Location, Description, Start, End, Duration

They should also have the following variables available:

  • {TITLE} (the original event title/summary)
  • {DESCRIPTION} (the original event description)
  • {LOCATION} (the original event location}
  • possibly more added on request

ical/ics url Caching issue

From Google-Apps-Script-Library created by jimmysingla : derekantrican/Google-Apps-Script-Library#8

This is a great library to use for continuous sync with google calendar. I was using it and found few issues. Don't know whether these issues are general or only for me. One of these issues is : The URL that I am using to profile ical/ics file, got cached in this script. I noticed this issue while i was testing by adding new events in file and trying to sync it with Google Calendar. New events are not captured.

I found and applied a solution for this. I would like to share and discuss it with you. If you allow me to commit my updates to your repo that would be help full to someone too. And we can discuss and solve issues further. :)

Again this script is Nice and saved lots of my time. Thanks!

Script will delete events not related to ICS file

One of the beauties of this custom script is that it can sync to an already-existing calendar (where there are other events not related to the ICS/ICAL file). But this means that those events won't have a FID tag on them.

We need to fix this section of the program:

var feedIndex = feedEventIds.indexOf( calendarEvents[i].getTag("FID") );
if(removeEventsFromCalendar){
  if( feedIndex  == -1  ){
    Logger.log("    Deleting "+calendarEvents[i].getTitle());
    calendarEvents[i].deleteEvent();
  }
}

The problem is that it is deleting events that may be on the calendar that are not related to the ICS/ICAL file.

Discussion: support full Google Calendar API?

@staffanf @jonas0b1011001 @amytencza @nvardi @agentd00nut (trying to tag most people that have participated in discussions on this repository for supporting recurrence. Feel free to tag others if you think they should be part of this discussion)

Currently this script uses the "Google Apps Version" of the Google Calendar API. I've thought multiple times about supporting the full Google Calendar API instead. Here are some pros & cons:

Pros:

  • Some features are more "wholly" supported in the full API. For instance, the "GAS API" doesn't support things like negative BYMONTHDAY in RRULEs. RRULE implementation would also be MUCH easier as we can simply use the RRULE rather than trying to write a custom parser for the RRULE
  • More features are supported in the full API. For instance, if we wanted to change something like event color or event availability/transparency this can only be done through the full API

Cons:

  • It would be a much more involved process for a user to set up. Currently when a user installs the script they just have to authorize it, then they're good to go. With the full API they would have to authorize it, enable it (Resources > Advanced Google Services), and also enable it on the Google Cloud Platform API Dashboard. Edit: It seems according to this that this was reworked a bit in April, 2019. If we move the script to a new document (therefore created after April, 2019) then people should be able to just "Make a Copy", authorize, and use just like before. I just tested it with an example script (you can do the same if you're curious: https://script.google.com/d/1MChjSD4yhIGEcrz1MddTLOfSy1oqZveDuwSNZuEkGd47UcoBHspRRZZi/edit?usp=sharing)
  • The script would have to be reworked quite a bit to change from the "GAS API" to the full API

Any thoughts, discussion, etc would be greatly appreciated. What do you think?

CalAPI v3 does not support default reminders for all day events

When creating an all day event using Google's Calendar API the default reminders for 'normal' events are applied instead of those defined for all day events.

This may lead to all day events having reminders even though the user has not defined any in the calendar settings at calender.google.com.

This issue was reported to Google but has not been fixed yet.

Where is .isDate?

G'day team,

Very very very new to dev world here and am using fun tools like this to build some base skills.

Totally understand if this isn't a focus or isn't even a script on your radar any more!

Installed the script and ran but didn't get any events. Checked out the execution transcript and saw.

Execution failed: TypeError: Cannot read property "isDate" from null. (line 267, file "Code")

I'm using a calendar from my training software. I think the script is looking for DTstart and finding something it doesn't expect and so its struggles to use the class??

the DTstart in the output of the calendar is: DTSTART:20190707T040000

Tried my very best to find a solution but can't quite get me head around it.

ICS/ICAL parsing issue (multiple lines, "\n" not being accounted for)

From Google-Apps-Script-Library created by derekantrican : derekantrican/Google-Apps-Script-Library#7

ICS link: http://msdwarren.blob.core.windows.net/calendar/sports-all.ics

Resulting event:
image

BEGIN:VEVENT
CREATED;VALUE=DATE:19000101
DESCRIPTION:Start Time: 5:30 PM\nEnd Time: 7:30 PM\nSport: Baseball\nGender
 : Male\nClass(es): V\nLocation: Lawrence North\nOpponent(s): Lawrence Nort
 h High School
DTEND:20190410T233000Z
DTSTART:20190410T213000Z
DTSTAMP:20180404T055405Z
LAST-MODIFIED;VALUE=DATE:19000101
LOCATION:Lawrence North
SEQUENCE:0
SUMMARY:Baseball\, Varsity @ Lawrence North
TRANSP:Transparent
UID:e3020681
END:VEVENT

My program parses the ics file line by line, so that's why the description is getting cut off (because the ics file here has the description split onto multiple lines). I can probably look into adjusting the program to account for this. I'll also look into why the \n isn't getting treated properly.

ICS/ICAL sync timezone issue

From Google-Apps-Script-Library created by derekantrican : derekantrican/Google-Apps-Script-Library#6

The following function is having trouble parsing timezones and needs to be improved:

function GetUTCTime(parameter){
  parameter = parameter.substr(1); //Remove leading ; or : character
  if (parameter.includes("TZID")){
    var tzid = parameter.split("TZID=")[1].split(":")[0];
    var time = parameter.split(":")[1];
    return Moment.moment.tz(time,tzid).tz("Etc/UTC").format("YYYYMMDDTHHmmss") + "Z";    
  }
  else
    return parameter;
}

The solution is to use regex to parse out the parts of the string. Here is documentation on how this parameter is formatted: https://www.kanzaki.com/docs/ical/dtstart.html

When VEVENT is a "whole day" event the script ends in error

Fout
22 sep. 2019 20:59:53
Error: invalid date-time value: "2019-10-04T::"
at unknown function
at unknown function
at unknown function
at unknown function
at unknown function
at unknown function
at ConvertToCustomEvent(Code:264)
at main(Code:138)

Handle recurrence

Hi,

The sync script doesn't copy recurring meetings from the sourceCalendarURL to the targetCalendarName.

Could you have a look at this?

Best regards

Implement code refactoring from PR #31

Although PR #31 is closed because we're doing recurrence handling differently, I think it still had some good refactoring. So after recurrence is pulled in from jonas' fork I can re-do that refactoring

Execution failed: Event start date must be before event end date.

Link to my ICS feed (from Canvas, it is a school tool for tracking assignments and stuff):
https://uwplt.instructure.com/feeds/calendars/user_ltI6MNY6ML1ZsYNEL9zwrRBiV38kZcB97NTZagce.ics

This is the error: Execution failed: Event start date must be before event end date. (line 172, file "Code")

I looked through the past issues that looked like this, but couldn't really figure it out. I have the default duration as 60 minutes, not really sure why this doesn't just override the time error.

Using vtimezone make script very long to execute

Hi,
I figure out than using vtimezone make the script very long to execute.
If I remove all code related to vtimezone in Code.js, execution time decrease from 120s to 2s.
The time is taken by toJSDate() method. I don't know why exactly.
But removing all vtimezone occurrences fixes it (for me).

By the way, thanks for your very useful script.

Manuel

If Script's timezone is different than calendar, all day events are created on the wrong day

Setup:

Calendar timezone: Central time - Chicago
Script timezone: Pacific Time
Test string (wiki):

var sourceCalendarString =
"BEGIN:VCALENDAR\n"+
"PRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN\n"+
"CALSCALE:GREGORIAN\n"+
"VERSION:2.0\n"+
"METHOD:PUBLISH\n"+
"BEGIN:VTIMEZONE\n"+
"TZID;X-RICAL-TZSOURCE=TZINFO:America/Chicago\n"+
"BEGIN:STANDARD\n"+
"DTSTART:20181104T020000\n"+
"RDATE:20181104T020000\n"+
"TZOFFSETFROM:-0500\n"+
"TZOFFSETTO:-0600\n"+
"TZNAME:CST\n"+
"END:STANDARD\n"+
"BEGIN:DAYLIGHT\n"+
"DTSTART:20190310T020000\n"+
"RDATE:20190310T020000\n"+
"TZOFFSETFROM:-0600\n"+
"TZOFFSETTO:-0500\n"+
"TZNAME:CDT\n"+
"END:DAYLIGHT\n"+
"END:VTIMEZONE\n"+
"BEGIN:VEVENT\n"+
"DTEND;VALUE=DATE:20190408\n"+
"DTSTART;VALUE=DATE:20190407\n"+
"DTSTAMP;VALUE=DATE-TIME:20190221T204949Z\n"+
"UID:event_448196497_ngin.com\n"+
"DESCRIPTION:Tag(s): 14U Mascheri\nhttps://sportsengine.page.link/?al=spor\n"+
" tsengine%3A%2F%2Fevent%2F448196497%3Fevent_start_time%3D2019-04-07T05%25\n"+
" 3A00%253A00Z%26team_ids%255B%255D%3D2830426&apn=com.sportngin.android&ct\n"+
" =iCalEventLink&ibi=com.ngin.sport.iphone&isi=499597400&link=http%3A%2F%2\n"+
" Fwww.lakecountystars.org%2Fevent%2Fshow%2F448196497%3Fresource_id%3D4481\n"+
" 96497%26start_time%3D2019-04-07T05%253A00%253A00Z%26team_ids%255B%255D%3\n"+
" D2830426%26type%3Devent&pt=319609&utm_campaign=iCalEventLink\n"+
"SUMMARY:14U Mascheri - Picture Day (time is TBD)\n"+
"LOCATION:\n"+
"END:VEVENT\n"+
"END:VCALENDAR";

image

Note how event in ics is set for April 7th, but is created on April 6th. If the Script timezone is changed to match the calendar (eg Central Time) then the issue disappears. We should make this rely on the calendar or ics timezone - not the Script timezone

Error: Creating too many calendar events

On first run I am getting the error: "You have been creating or deleting too many calendars or calendar events in a short time. Please try again later. at main(Code:190)"

All day events (start time = end time) issue

Yahoo calendar creates all day events by adding the same start time and end time to an event. This causes errors on Google: Event start date must be before event end date. at main(Code:172)

The event in question looks like this on the logs:
Title: Apple picking
Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Description:
Start: Sat Oct 05 2019 17:00:00 GMT-0700 (PDT)
End: Sat Oct 05 2019 17:00:00 GMT-0700 (PDT)

Triggers disabled

My triggers have been disabled after 1 try and did not wake up after the time set (15 mins). I found out that it has been disabled. I cannot find why it was disabled. Any reason?

image

Handling Microsoft Windows time zone IDs

My Outlook365 calendar reports a "Romance Standard Time" which is the equivalent of Western European TZID ("Europe/Copenhagen" and others). The GetUTCTime() function does not parse it correctly. Is there a general method to translate Windows time zones into TZIDs that Moment.moment.tz() will understand?

Does not work with Todoist calendars

Hi,
I tried to use your script to sync Todoist calendar with google calendar, and the script does not work. Every time it shows # of events: 0.

After quick debugging I have found that you assume, that response fetched from URL breaks lines using \r\n
response = response.getContentText().split("\r\n");
After 'correcting' this line to split using only \n everything worked fine.
I think you should not assume that file uses \r\n breaking but use logic to determinate that.

breakSign = \n
if \r\n in file:
     breakSign = \r\n 

or something like that.

Regards.

Automatically replace "webcal://" with "https://"

Sometimes users put in a webcal://......... link and that does not seem to work. The solution here is to replace webcal:// with https://. To reduce any issues for users in the future, we should probably add a simple "check and replace" in the main function.

Eventually, should support mapping between multiple ICS calendars and Google Calendars

Some day in the future a user should have the ability to add the urls for as many ICS calendars as they want and choose the Google calendar(s) that they sync to. Something like:

test.com/cal1.ics --> Personal
test.com/cal2.ics --> Work, Travel

After we make our initial "multiple calendars support" changes this will somewhat be possible, but only if you're running multiple instances of the program (as we only support 1 ics per instance). Eventually this should be possible with a single instance.

Need to support Windows timezones

Example ICAL from a user (generated from Microsoft Outlook):

BEGIN:VEVENT
DESCRIPTION:Test sync
UID:040000008200E00074C5B7101A82E00800000000C0F85EF4991CD401000000000000000
010000000D8D1B7BF8927144E9F2E19D9CBAEF85C
SUMMARY:Test
DTSTART;TZID=Mountain Standard Time:20180716T080000
DTEND;TZID=Mountain Standard Time:20180716T090000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20180716T034238Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT

Note how the timezones are "Mountain Standard Time". This is a Windows way of representing the timezone and is not supported by Moment.js (which uses IANA timezone formats)

It's also somewhat important to note that when Moment can't match a timezone, it assumes the datetime is in UTC

Make all events have certain time

I use this to sync my Canvas assignments to my personal calendar. Right now, they are created as all day events, but I don't want notifications to come the day before. I want multiple notifications to remind up to the due date. So 1 day before, 6 hours before, 1 hour before, etc. So that I won't forget to submit an assignment. The way canvas formats all the events are by all day. I would like to override those times to make it like 23:00-23:59 or something so that the notifications line up with how they should. I was looking at the code to see if I could hardcord something, but I couldnt figure out how to do that, without like cutting up the event.startTime and then appending the right date or something. I would love any help on this, I know this doesn't apply to everyone, but I would love it if I could get this to work. Thanks!

Possible to create too many triggers

The program should limit to only one trigger existing at any one time. Currently, if the user runs the Install function multiple times, it will create multiple triggers (this could cause execution issues). The Install function should first delete any existing triggers before creating a new one. Like this:

var triggers = ScriptApp.getProjectTriggers();
for (var i = 0; i < triggers.length; i++){
  if (triggers[i].getHandlerFunction() == "main"){
    ScriptApp.deleteTrigger(triggers[i]);
  }
}

Add email notifications to modifications

Currently there is emailWhenAdded that will email when a new event has been added to the calendar, but there should also be emails when an event is updated or deleted.

Suggested changes:

  1. Rename emailWhenAdded to emailWhenModified
  2. Add email notification calls to modification and removal section

Triggers Randomly Fail

  • Occasionally Triggers fail, with the new trigger method to allow random times this means that it can stop repeating as the new trigger won't be set up. Reinstalling works with no issues.

image

Changing password invalides events url key

This is possibly because I'm working from my own script which hasn't been kept up to date with this repo, but thought I'd add it here in case this hasn't been caught yet.

Thanks!

Same events are not recognized

Hi there;

I've been hit by a steady flow of:

You have been creating or deleting too many calendars or calendar events in a short time.

from Google, so I investigated a bit. It seems that lots of events were modified because a spurious change was detected. Two reasons for that:

  1. null vs empty string

The test e.getLocation() != fe.location failed because one was null while the other was the empty string. This is fixed by changing

event.location = vevent.getFirstPropertyValue('location');

to

event.location = vevent.getFirstPropertyValue('location') || '';

(This also applies to description!)

  1. comparing dates

Comparing dates should not be done with ==, but using getTime. The line used to compare time should be changed to:

if(e.getStartTime().getTime() != fe.startTime.getTime() || e.getEndTime().getTime() != fe.endTime.getTime())

Cheers;
M.

Events show up on wrong timeslot because of timezone

I already added this as a comment to another bug but I assumed it would be more handy to just create a new bug ticket for it.

I'm encountering a similar problem for events as @amytencza in #34.

Events that have been created in a different time zone end up at the wrong time slot in the google calendar. In my case the Event is created in India and should apprear at 11:00 (which it does in the original calendar) but in google calendar it appears at 14:30.

When I check the logs I see the following:
The event has a date of 05:30:00 GMT-0700 but India should be at GMT-5.5. I tried to look into the code myself but I have the feeling my programming skills are a bit to limited to really be of support here.

I can do some additional debugging if required
Screenshot 2019-08-21 at 09 51 22

End time cannot be same

For one-day all-day events I get an error: Event start date must be before event end date. (line 172, file "Code")

Example:
[19-04-11 10:38:53:653 CEST] Title: New Year's Day
[19-04-11 10:38:53:654 CEST] Id: [email protected]
[19-04-11 10:38:53:654 CEST] Description:
[19-04-11 10:38:53:654 CEST] Start: Tue Jan 01 2019 00:00:00 GMT-0800 (PST)
[19-04-11 10:38:53:655 CEST] End: Tue Jan 01 2019 00:00:00 GMT-0800 (PST)

Check for new version

Eventually, it would be nice to have a function that checks for a new version of the program from here (probably from the GitHub releases page?)

Something like this:

  1. Every time the main function runs, it calls the CheckForUpdate function
  2. CheckForUpdate will check the current version (a global variable in the code) against the most recent published version on GitHub releases page
  3. If a newer version is found, we will check a ScriptProperty to make sure we haven't found that before. If we haven't, we will email the user that there is a new version (and set that ScriptProperty). If we have, do nothing

ICS/ICAL sync duplicating events

image

As shown in the screenshot, events are being duplicated. Each event is duplicated exactly twice.

I don't think that this is due to a faulty link because when I let google sync the ICS this does not happen.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.