Skip to content

Instantly share code, notes, and snippets.

@ram-nadella
Created March 7, 2016 04:21
Show Gist options
  • Save ram-nadella/50998784ba5d64d92fc5 to your computer and use it in GitHub Desktop.
Save ram-nadella/50998784ba5d64d92fc5 to your computer and use it in GitHub Desktop.
Using TMDB (The Movie Database), find the air date of the next season for a TV show by name
~/code/misc/tv-show-next $ ruby check.rb
Silicon Valley Season 3 2016-04-24
Game of Thrones Season 6 2016-04-24
Togetherness Season 2 2016-02-21
House of Cards Season 4 2016-03-04
require "tmdb"
# https://www.themoviedb.org/faq/api?language=en
Tmdb::Api.key("<TMDB API key>")
def find_show_and_air_date(name)
search_response = Tmdb::Search.tv(name)
show_id = search_response.results.first.id
show = Tmdb::TV.detail(show_id)
latest_season = show.seasons.last
# p latest_season
puts "#{show.original_name} Season #{latest_season.season_number} #{latest_season.air_date}"
end
find_show_and_air_date("Silicon Valley")
find_show_and_air_date("Game of Thrones")
find_show_and_air_date("Togetherness")
find_show_and_air_date("House of Cards")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment