Created
February 12, 2018 11:05
-
-
Save josh-/cb84879add88a2202418f70194745596 to your computer and use it in GitHub Desktop.
Export iCloud Tabs to CSVs
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
#!/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