zeus.ugent.be/commands/fetch.rb

31 lines
778 B
Ruby
Raw Normal View History

2017-10-11 16:07:13 +00:00
# frozen_string_literal: true
require 'net/http'
require 'json'
usage 'fetch [facebook event id]'
aliases :f
summary 'Fetch an event from facebook'
description 'Fetch an event from facebook'
run do |_opts, args, _cmd|
fb_token = File.read('.fb_token')
2017-10-13 09:23:58 +00:00
event_id = args[0]
uri = URI("https://graph.facebook.com/v2.10/#{event_id}?fields=cover,name,description,start_time,place,end_time&access_token=#{fb_token}")
2017-10-11 16:07:13 +00:00
o = JSON.parse(Net::HTTP.get(uri))
puts <<~EOS
---
title: "#{o['name']}"
2017-10-13 09:38:02 +00:00
description: #Fill in
2017-10-11 16:07:13 +00:00
time: #{o['start_time']}
end: #{o['end_time']}
2017-10-13 09:23:58 +00:00
location: #{o['place']['name']}
2017-10-11 16:07:13 +00:00
banner: #{o['cover']['source']}
2017-10-13 09:38:02 +00:00
created_at: #Fill in
2017-10-13 09:23:58 +00:00
facebook: 'https://www.facebook.com/events/#{event_id}/'
2017-10-11 16:07:13 +00:00
---
#{o['description']}
EOS
end