Skip to content

Instantly share code, notes, and snippets.

@kristianfreeman
Created October 2, 2012 03:48
Show Gist options
  • Save kristianfreeman/3816058 to your computer and use it in GitHub Desktop.
Save kristianfreeman/3816058 to your computer and use it in GitHub Desktop.
Tent.is posts to Day One
## Tent.io work
require 'json'
require 'time'
# Change these to suit your needs
# You probably don't want my posts.
username = "kmf"
post_location = "/Users/kristian/Dropbox/ifttt/tent"
Dir.chdir post_location
puts "Waiting for download..."
`curl -s -o #{post_location} https://#{username}.tent.is/tent/posts`
json = File.read('posts')
posts = JSON.parse(json)
skip = Array.new
# Uncomment the following lines after running for the first time
# skiplist = File.open('lastid')
# list = skiplist.readline.to_s.split(',')
posts.reverse_each do |post|
next if post["content"]["text"].nil?
# Uncomment the following line after running for the first time
# next if list.include?(post["id"])
text = post["content"]["text"]
id = post["id"]
skip.push(id)
unDate = post["published_at"]
time = Time.at(unDate).to_time.strftime("%I:%M %p")
date = Time.at(unDate).to_time.strftime("%m/%d/%Y %I:%M%p")
post = "[[#{time}](http://#{username}.tent.is/posts/#{id})]: #{text}
Posted on Tent.is"
`echo "#{post}" | dayone -d="#{date}" new`
end
if !skip.empty?
File.open('lastid', 'a') {|f| f.write(skip.join(","))}
else
puts "No new posts found."
end
@kristianfreeman
Copy link
Author

Things to know about this gist

  • Change your username and location you want to save the plain text version of this to. I like having it in Dropbox, in my IFTTT folder (along with my aborted Twitter archive -_-).
  • The first time you run the script, it's going to download all of your posts. After that, you're going to want to uncomment the couple lines I have labeled (for simplicity's sake, lines 19, 20, and 26) to stop the script from adding posts it has already seen.

This is really rough, but I wanted a way to import these into Day One so I don't lose track of them. There might be (hint, probably are) bugs, so fork away!

PS — if you want to use this all power-user-y, you should use a cron job or maybe Lingon with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment