Skip to content

Instantly share code, notes, and snippets.

@josh-
Created February 12, 2018 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josh-/cb84879add88a2202418f70194745596 to your computer and use it in GitHub Desktop.
Save josh-/cb84879add88a2202418f70194745596 to your computer and use it in GitHub Desktop.
Export iCloud Tabs to CSVs
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'csv'
class CloudyTabsServer
attr_accessor :port
attr_accessor :http
def initialize(port)
@port = port || 8181
@http = Net::HTTP.new('0.0.0.0', @port)
end
def devices
JSON.parse(self.http.get('/devices').body)
end
def tabs(deviceID)
JSON.parse(self.http.get("/tabs/#{deviceID}").body)
end
end
local_port = ENV['CLOUDYTABS_LOCAL_PORT']
cloudy_tabs = CloudyTabsServer.new(if local_port then local_port.to_i end)
cloudy_tabs.devices.each do |device|
CSV.open("#{device['name']}.txt", 'w') do |csv|
cloudy_tabs.tabs(device['deviceID']).each do |tab|
csv << [tab['url'], tab['title']]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment