Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Command line util to download a google calendar

View download-calendar.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/env ruby
 
calendar_url = ARGV.shift
 
unless calendar_url
puts "Usage: #{File.basename(__FILE__)} <calendar-url> [<download-directory>]"
exit 1
end
 
download_directory = ARGV.shift
download_directory = File.dirname(__FILE__) unless download_directory and File.directory?(download_directory)
 
unless calendar_name = calendar_url[Regexp.new("/ical/(.*)/private-"), 1]
puts "I can't determine the calendar's name from the URL (#{calendar_url})"
exit 1
end
 
calendar_filename = [calendar_name, 'ics'].join('.')
calendar_path = File.join(download_directory, calendar_filename)
 
puts "#{Time.now} - Downloading calendar to #{calendar_path}"
`curl -s "#{calendar_url}" > #{calendar_path}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.