Skip to content

Instantly share code, notes, and snippets.

@swindsor
Created February 7, 2011 16:23
Show Gist options
  • Save swindsor/814647 to your computer and use it in GitHub Desktop.
Save swindsor/814647 to your computer and use it in GitHub Desktop.
Add all netflix movies (from text file) to a redis sorted set
#!/usr/bin/env ruby
require 'netflix'
require 'redis'
redis = Redis.new
File.open("movies.txt", "r") do |f|
f.each_line do |line|
id = line.chomp
movie = Netflix.catalog_movie(id)
puts "#{movie.title} (#{movie.release_year}): #{movie.average_rating}"
redis.zadd "netflix_ratings", movie.average_rating, "#{movie.title} (#{movie.release_year})"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment