Skip to content

Instantly share code, notes, and snippets.

@micahbrich
Created January 16, 2009 20:31
Show Gist options
  • Save micahbrich/48106 to your computer and use it in GitHub Desktop.
Save micahbrich/48106 to your computer and use it in GitHub Desktop.
require 'fleakr'
class Fetchr < ActiveRecord::Base
# This script fetches flickr photos
@flickr ||= Fleakr.api_key = < my key >
@user ||= Fleakr.user('info@micahrich.com')
@photos ||= @user.sets.first.photos
@photos.each do |photo|
@post = Post.find_or_create_by_url(:url => photo.url, :title => photo.title, :description => photo.description, :created_at => photo.posted_at, :updated_at => photo.updated_at, :image => photo.large.url, :thumb => photo.small.url, :flickr_id => photo.id )
unless @post.updated_at == photo.updated_at
@post.update_attributes!(:url => photo.url, :title => photo.title, :description => photo.description, :created_at => photo.posted_at, :updated_at => photo.updated_at, :image => photo.large.url, :thumb => photo.small.url, :flickr_id => photo.id )
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment