Created
October 7, 2010 11:21
-
-
Save chrisroos/614972 to your computer and use it in GitHub Desktop.
Command line util to download a google calendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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