Learning To Code

Optimize your binge-watching with this new gem

Flatiron School / 9 February 2016
SHARE:

This post originally appeared on June 19, 2015.

It’s a common dilemma we’ve all faced at some point: you want to watch a certain movie or TV show, but you don’t know which streaming service you’ll be able to find it on.


netflix

Sure, you could go to five different sites and punch in the names one by one, but why do that when you could just use a gem instead? By re-using code to improve the now defunct MWhich gem, Flatiron School student Bryan Gross found a way to restore a service that no longer worked due to Netflix shutting down their API. Ladies and gentlemen, we introduce to you the Strepi gem.

Bryan fixed this by using the Netflix Roulette gem, and added Crunchyroll as well (an Anime streaming service). People with this gem can search for media on Netflix, Amazon, Hulu, iTunes, and Crunchyroll all in one. Here is how Strepi accesses the data from each of these services:

  • Netflix: The Netflix Roulette gem and api (netflixroulette.net/api/)
  • Amazon: Official Amazon ECS (Required credentials)
  • Hulu: Hacks publisher tool endpoint
  • iTunes: Their Store Web Service Search API via AffiliatesSearch2.1.pdf
  • Crunchyroll: Scrapes Crunchyroll pages

What’s more, movies can be searched for on specific streaming services as well. Here are the simple steps to add this gem to your collection:

First, get these gems:

  • yajl-ruby
  • nokogiri
  • ruby-hmac

Then, create a basic Strepi instance:
w = Strepi::Client.new

After, look for your favorite movie:
w.search(“Jurassic Park”)
# => {:amazon=>[], :hulu=>[], :itunes=>[“feature-movie: Jurassic Park ($9.99)”], :netflix=>[Jurassic Park is available!, :crunchyroll=>[]}

Once you put this in, a hash of key/value pairs will indicate the service on which your movie or TV show is found.

jurassicpark
 

 

We know, it’s pretty spectacular.



The value is a simple string including the type of media found, along with the title. Comments specific to each service may also appear. For example:

Hulu sometimes links to external content, so “Not on hulu!” will identify this for you, and iTunes will display product prices.

If you want to limit your searches by service:

w = Strepi::Client.new(:services => [:netflix, :crunchyroll, :hulu])
w.search(“Naruto”)
# => {:netflix=>[], :crunchyroll=>[“Naruto is on Crunchyroll!”], :hulu=>[“: Naruto”, “: (Sub) Departure”, “: (Sub) The Ultimate Weapon Reborn”, “: (Sub) The Counterattack!”, “: (Sub) Sand Alliance with the Leaf Shinobi”, “: (Sub) The Targeted Shukaku”, “: (Sub) A Past to Be Erased”, “: (Sub) Bringing Back Reality”, “: (Sub) Vanished Memories”, “: (Sub) To Each His Own Path”]}

Amazon is an exception in all this: if you want to be able to use the API, you’ll have to give them a special “password” by including your Amazon credentials when you set up the Strepi instance, or store it in the initializer file.

Enter the Amazon credentials:

w = Strepi::Client.new(:services => [:amazon], :ecs_credentials => {:associate_tag => ‘Your associate tag’, :AWS_access_key_id => ‘Your access key ID’, :AWS_secret_key => ‘Your secret key’})

Or, store them in the initializer file:

ECS_CREDENTIALS = {:associate_tag => ‘Your associate tag’, :AWS_access_key_id => ‘Your access key ID’, :AWS_secret_key => ‘Your secret key’}

Get on that snuggie and prepare for some binge-watching this weekend. You can check out a more detailed account of the Strepi gem at GitHub here.

From Linguistics Major to Software Developer - Jen's Summer at Flatiron Previous Post What Are Bootcamps Looking For In a Student? Next Post