Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Command line util to download a google calendar
#!/usr/bin/env ruby
calendar_url = ARGV.shift
unless calendar_url
puts "Usage: #{File.basename(__FILE__)} <calendar-url> [<download-directory>]"
exit 1
download_directory = ARGV.shift
download_directory = File.dirname(__FILE__) unless download_directory and
unless calendar_name = calendar_url["/ical/(.*)/private-"), 1]
puts "I can't determine the calendar's name from the URL (#{calendar_url})"
exit 1
calendar_filename = [calendar_name, 'ics'].join('.')
calendar_path = File.join(download_directory, calendar_filename)
puts "#{} - 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