Skip to content

Instantly share code, notes, and snippets.

@caius
Forked from ysr23/gist:1340146
Created November 4, 2011 18:54
Show Gist options
  • Save caius/1340158 to your computer and use it in GitHub Desktop.
Save caius/1340158 to your computer and use it in GitHub Desktop.
Film.find_each do |f|
next if Film_imdb.find_by_title(f.title)
# Try to find it
imdb_search = Imdb::Search.new(f.title)
m = imdb_search.movies.first
# Check we found a movie
unless m
logger.error "couldn't find film for #{f.title.inspect} on IMDB"
next
end
# Save what we found!
f.update_attributes(
:IMDBurl => m.url,
:poster => m.poster,
:length => m.length,
:rating => m.rating,
:plot => m.plot,
:year => m.year,
:imdb_title => m.title,
:tagline => m.tagline
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment