Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 94 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save gene1wood/02ed0d36f62d791518e452f55344240d to your computer and use it in GitHub Desktop.
Save gene1wood/02ed0d36f62d791518e452f55344240d to your computer and use it in GitHub Desktop.

Given a subscribed calendar with a url like

https://example.com/example.ics

To force Google Calendar to refresh and reload the contents right now, unsubscribe from the calendar and subscribe to a new calendar with a URL like

https://example.com/example.ics#1

Adding the anchor tag will force Google Calendar to think of it as a new calendar

Many people who come to this gist are not looking for a one time forced refresh but instead to refresh recurringly. If that's you, you should check out @derekantrican 's Google App Script

https://github.com/derekantrican/GAS-ICS-Sync

Which can refresh a calendar automatically every N minutes

https://script.google.com/home/projects/1BOk8MDLbLaHh6SwG1M1tsgNXjkcC-79LE0QoipRuTDxbO3fMVvqoROQD/edit

Thanks to @rattrayalex for pointing people to this script

@orvilleboggs
Copy link

When I use the anchor tag (#1) to update my calendar, it works perfectly. I added the anchor tag to the webcal url in Google Calendar. I don’t want to go in manually and change the calendar all the time, so I installed the script and I run it without errors but my calendar is not updating.

On line 28 ["icsUrl1", "targetCalendar1"], I added in my target url and calendar name.

This is the webcal url for the calendar: webcal://p114-caldav.icloud.com/published/2/OTU0NTQwNzk1NDU0MDc5NY0GfaMdNrmofxaskYFk8I9ZnMV1JBhhZIkTGL90GL00#1

This is the public url to this calendar from Google: https://calendar.google.com/calendar/embed?src=udru2fk5hldka3rbj4u9cm5frb63b6f0%40import.calendar.google.com&ctz=America%2FNew_York

I’m pretty sure that I am making a mistake with the url. I tried many different combinations from above but no luck. I was hoping that someone could point me in the right direction? Thank you!!

@jonas0b1011001
Copy link

On line 28 ["icsUrl1", "targetCalendar1"], I added in my target url and calendar name.

You have to add the source url not the target url. The second item is the name of the google calendar you want to sync to (in case you want to sync to your main calendar you have to use the account gmail address)

@orvilleboggs
Copy link

On line 28 ["icsUrl1", "targetCalendar1"], I added in my target url and calendar name.

You have to add the source url not the target url. The second item is the name of the google calendar you want to sync to (in case you want to sync to your main calendar you have to use the account gmail address)

@jonas0b1011001 Thank you so much for the quick response! I really appreciate it! I will add the source file in a bit. Thanks!

@orvilleboggs
Copy link

I finally got this working and it’s great! I wanted to post a mistake I was making in case it helps anyone out in the future. It seems like a simple mistake but took me a few days to figure out.

I created a calendar in Google from an iCloud url called “Appointments.” It was a read-only calendar. When I added in my source url and target calendar on code.gs line 28, nothing worked. I thought I was inputting the wrong url.

After searching the boards, I realized I needed to create a new calendar in Google and delete the read-only calendar. I called the new calendar “Appointments” as well. I put in my source url and the target calendar (Appointments) and everything worked. Hope this makes sense and I hope it helps.

@andreamoro-git
Copy link

Is the issue arising only because google calendar refreshes infrequently, or is it because they NEVER refresh? I am almost certain that some of the calendars I subscribe to are updated from time to time but I never checked how promptly

@orvilleboggs
Copy link

It's because google calendar refreshes infrequently. I'm not sure how long it takes to refresh but it is a considerable amount of time. It will update eventually but I wanted it to refresh much more quickly. This solved the problem for me.

@andreamoro-git
Copy link

andreamoro-git commented Jan 30, 2024

ok thanks but does infrequently mean hours or days/weeks?

@orvilleboggs
Copy link

It usually takes some where between 12 and 24 hours to refresh.

@malazarocom
Copy link

Great!

@olgabot
Copy link

olgabot commented Mar 15, 2024

Thank you so much! @derekantrican, you are a lifesaver!

@TDReservas
Copy link

Hi all, This is fantastic really saved me a headache and works great. I have 50 Air Bnb properties that I manage and need all there calenders in one place.

Because of this, is it possible to add unlimited calenders to this script? and if so how do i do this? do I just copy and paste into new inserted lines?

First time using scripts etc

TIA

@jonas0b1011001
Copy link

is it possible to add unlimited calenders to this script?

Of course, you can either combine x calendars into one google calendar or sync them all to a different google calendar.

Just edit/add additional calendars to:

var sourceCalendars = [                
  ["icsUrl1", "targetCalendar1"],
  ["icsUrl2", "targetCalendar2"],
  ["icsUrl3", "targetCalendar1"]
];

Make sure to get the commas at the line ends correct ;)

@TDReservas
Copy link

is it possible to add unlimited calenders to this script?

Of course, you can either combine x calendars into one google calendar or sync them all to a different google calendar.

Just edit/add additional calendars to:

var sourceCalendars = [                
  ["icsUrl1", "targetCalendar1"],
  ["icsUrl2", "targetCalendar2"],
  ["icsUrl3", "targetCalendar1"]
];

Make sure to get the commas at the line ends correct ;)

Thankyou thats fantastic, So how do Iput them all into 1 calender? I just put the same name for target calendar?

@jonas0b1011001
Copy link

I just put the same name for target calendar?

Yes

@Johnyryal
Copy link

Johnyryal commented Apr 3, 2024

Hi, this is just what I was looking for and have it setup and running. It has created and populated a new calendar in my google calendar with the ics data. I have added a new entry in the iCal source to see that it is working. When it runs I don't ever see the new entry populate in the google calendar and under executions I get one of these two entries. Timing is set to every 15 minutes. Any thoughts or guidance would be helpful. Thanks.

Info - Completed:
Another iteration is currently running! Exiting...

Error - Failed:
DNS error: http://h
at callWithBackoff(Helpers:1078:9)
at fetchSourceCalendars(Helpers:136:5)
at startSync(Code:168:21)

@jonas0b1011001
Copy link

Hi, this is just what I was looking for and have it setup and running. It has created and populated a new calendar in my google calendar with the ics data. I have added a new entry in the iCal source to see that it is working. When it runs I don't ever see the new entry populate in the google calendar and under executions I get one of these two entries. Timing is set to every 15 minutes. Any thoughts or guidance would be helpful. Thanks.

Info - Completed: Another iteration is currently running! Exiting...

Error - Failed: DNS error: http://h at callWithBackoff(Helpers:1078:9) at fetchSourceCalendars(Helpers:136:5) at startSync(Code:168:21)

Your var sourceCalendars is missing a set of [], recheck with the given example.


Many of the questions asked here are already answered in the official repo of the script. As one of the maintainers, I can only encourage anyone to head over there if they are facing problems with the script!

@Johnyryal
Copy link

Hi, this is just what I was looking for and have it setup and running. It has created and populated a new calendar in my google calendar with the ics data. I have added a new entry in the iCal source to see that it is working. When it runs I don't ever see the new entry populate in the google calendar and under executions I get one of these two entries. Timing is set to every 15 minutes. Any thoughts or guidance would be helpful. Thanks.
Info - Completed: Another iteration is currently running! Exiting...
Error - Failed: DNS error: http://h at callWithBackoff(Helpers:1078:9) at fetchSourceCalendars(Helpers:136:5) at startSync(Code:168:21)

Your var sourceCalendars is missing a set of [], recheck with the given example.

Many of the questions asked here are already answered in the official repo of the script. As one of the maintainers, I can only encourage anyone to head over there if they are facing problems with the script!

Thank you @jonas0b1011001 for helping me correct my error. Sorry I couldn't find my answer in the repo. My error for "cleaning up" to much of the comments in that line. Many thanks!

@gene1wood
Copy link
Author

@jonas0b1011001 Given that most people who come to this gist are looking for functionality provided by your project ( https://github.com/derekantrican/GAS-ICS-Sync ), not for the trick outlined above about adding an anchor tag to a URL, is there anything you'd like to see me change/update about this gist to try to get those users away from this gist and over to your repo? Maybe I go through and try to delete some old comments in order to simplify this landing page so it's easier for people to find their way to your repo? Any ideas are welcome. I have a contact form linked on my GitHub profile, feel free to use it to email me with any ideas for how to improve this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment