module Tvdb
Public Class Methods
harvest(apiKey, seriesId)
click to toggle source
# File lib/tvdb/ruby.rb, line 17 def harvest(apiKey, seriesId) url = "http://thetvdb.com/api/#{apiKey}/series/#{seriesId}/all/en.xml" doc = Nokogiri::HTML(open(url)) show = Show.new( id: doc.css("id").text, name: doc.css("seriesname").text, airsDayOfWeek: doc.css("airs_dayofweek").text, airsTime: doc.css("airs_time").text, firstAired: doc.css("firstaired").text, genre: doc.css("genre").text, network: doc.css("network").text, overview: doc.css("overview").text, rating: doc.css("rating").text, ratingCount: doc.css("ratingcount").text, runtime: doc.css("runtime").text, status: doc.css("status").text, poster: doc.css("poster").text ) doc.css("episode").each do |episode| show.epidosodes.new( seasonNumber: episode.css("seasonnumber").text, id: episode.css("episodenumber").text, name: episode.css("episodename").text, firstAired: episode.css("firstaired").text, overview: episode.css("overview").text ) end end
initialize(apiKey, seriesName)
click to toggle source
# File lib/tvdb/ruby.rb, line 7 def initialize(apiKey, seriesName) #apiKey = '9EF1D1E7D28FDA0B' #seriesName = 'Breaking+Bad' url = "http://thetvdb.com/api/GetSeries.php?seriesname=#{seriesName}" doc = Nokogiri::HTML(open(url)) seriesId = doc.at_css("seriesid").text harvest(apiKey, seriesId) end