Skip to content

Instantly share code, notes, and snippets.

@tekei
Created August 22, 2012 20:35
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 tekei/3429101 to your computer and use it in GitHub Desktop.
Save tekei/3429101 to your computer and use it in GitHub Desktop.
[google reader] star一覧抽出
# googleのstarred-items-jas.jsonのままだと処理しにくいため、
# 一度単純なデータに変換する
#
# ファイル"bookmarks.json"に「登録時刻(time)/タイトル(title)/URL(url)」の
# 行列となったjsonファイルをはき出す
#
# 「情報をエクスポート」→「JSON アクティビティ ストリーム」から取得
require 'json'
require 'time'
require 'open-uri'
f = open('starred-items-jas.json')
json = f.read
f.close
j = JSON.parse(json)
dat = j.first[1];nil
conv = []
dat.each{ |l|
result = {"time" => Time.parse(l["published"])}
result["title"] = l["object"]["displayName"]
d = open(l["object"]["url"]) {|u| JSON.load u}
result["url"] = d["items"].first["alternate"].first["href"]
conv << result
}
open("bookmarks.json", "w") do |io|
io << JSON.pretty_generate(conv)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment