Netflix OData Episodes Feb 13 2013 5:00 PM Software Engineering api odata ruby 2420 views Retrieving Netflix OData episodes: require 'csv' require 'rubygems' require 'ruby_odata' IDS_PATTERN = /http:\/\/api.netflix.com\/catalog\/titles\/programs\/(?\d+)\/(?\d+)/ NAMES = [ 'Arrested Development', 'Hemlock Grove', 'House of Cards', 'Lilyhammer' ] service = OData::Service.new 'http://odata.netflix.com/Catalog/' results = [] NAMES.each do |name| service.Titles.filter("Name eq '#{name}' and Type eq 'Series'").expand('Episodes') titles = service.execute if titles and titles.count > 0 and titles[0].respond_to?(:Episodes) titles[0].Episodes.each do |episode| ids = IDS_PATTERN.match(episode.NetflixApiId) results << { id: episode.Id, movie_id: ids[:movie_id], episode_id: ids[:episode_id], name: episode.Name, short_name: episode.ShortName, runtime: episode.Runtime, rating: episode.Rating } end end end # Save output filename = File.expand_path('../output/netflix.tsv', __FILE__) CSV.open(filename, 'wt', {col_sep: "\t"}) do |csv| csv << %w(id movie_id episode_id name short_name runtime rating) results.each { |result| csv << result.values } end main.rb Netflix has discontinued their public OData API as of March 2013: Netflix has abandoned OData – does the standard have a future without an ecosystem? Netflix Stops Issuing API Keys To New Developers, Effectively Ending Its Developer Program Netflix kills third party app platform, current apps will continue to work See also OData