Created
January 26, 2019 16:58
-
-
Save jaredculp/fed96cfd91103e42ee07588dbd49dad8 to your computer and use it in GitHub Desktop.
Delete Facebook: export birthdays
This file contains 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
require 'net/http' | |
class Birthday | |
def initialize(date, name) | |
@date = date | |
@name = name | |
end | |
def ics | |
"BEGIN:VEVENT\r\nDTSTART;VALUE=DATE:#{@date}\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:Birthday #{@name}\r\nEND:VEVENT\r\n" | |
end | |
end | |
cal = ENV['FB_CALENDAR_URL'] | |
raise "Must specify FB_CALENDAR_URL" unless cal | |
data = Net::HTTP.get(URI(cal)) | |
puts "BEGIN:VCALENDAR\r\n" | |
birthdays = data.split("BEGIN:VEVENT").drop(1) | |
.map { |x| x.split("\r\n") } | |
.map { |x| Birthday.new(x[1].split(":")[1], x[2].split(":")[1]) } | |
.each { |x| puts x.ics } | |
puts "END:VCALENDAR\r\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment