Created
November 28, 2011 14:42
-
-
Save rjp/1400641 to your computer and use it in GitHub Desktop.
Move certain posts from my primary Posterous to my instagram Posterous
This file contains hidden or 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 "rubygems" | |
require "posterous" | |
require ENV['HOME'] + "/.apikeys.rb" | |
Posterous.config = $apikeys[:posterous] | |
include Posterous | |
from_site = Site.find('zimpenfish') | |
to_site = Site.find('zimpenfishtagram') | |
puts "from: #{from_site.id} to: #{to_site.id}" | |
puts "from count: #{from_site.posts_count}" | |
def is_instagram?(post) | |
post.body_full =~ /instagr/ | |
end | |
to_process = from_site.posts_count | |
processed = 0 | |
page = 1 | |
while processed < to_process | |
posts = from_site.posts(:page => page) | |
posts.each do |post| | |
if is_instagram?(post) then | |
puts "#{post.title} on #{post.site_id} is instagram'd" | |
post.site_id = to_site.id | |
post.save | |
sleep 2 | |
end | |
processed = processed + 1 | |
end | |
page = page + 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment