class P3::Tvdb::Search
Attributes
language[RW]
Public Class Methods
new(the_api_key, language = 'en', cache_options = {})
click to toggle source
# File lib/p3-tvdb/search.rb, line 10 def initialize(the_api_key, language = 'en', cache_options = {}) @api_key = the_api_key @language = language if cache_options.keys.size > 0 self.class.cache cache_options end end
Public Instance Methods
get_actors(series)
click to toggle source
# File lib/p3-tvdb/search.rb, line 75 def get_actors(series) response = self.class.get("/#{@api_key}/series/#{series.id}/actors.xml").parsed_response if response["Actors"] && response["Actors"]["Actor"] response["Actors"]["Actor"].collect {|a| Actor.new(a)} else nil end end
get_all_episodes(series, language = self.language)
click to toggle source
# File lib/p3-tvdb/search.rb, line 62 def get_all_episodes(series, language = self.language) response = self.class.get("/#{@api_key}/series/#{series.id}/all/#{language}.xml").parsed_response return [] unless response["Data"] && response["Data"]["Episode"] case response["Data"]["Episode"] when Array response["Data"]["Episode"].map{|result| Episode.new(self, result)} when Hash [Episode.new(response["Data"]["Episode"])] else [] end end
get_episode(series, season_number, episode_number, language = self.language)
click to toggle source
# File lib/p3-tvdb/search.rb, line 53 def get_episode(series, season_number, episode_number, language = self.language) response = self.class.get("/#{@api_key}/series/#{series.id}/default/#{season_number}/#{episode_number}/#{language}.xml").parsed_response if response["Data"] && response["Data"]["Episode"] Episode.new(self, response["Data"]["Episode"]) else nil end end
get_episode_by_id(episode_id, language = self.language)
click to toggle source
# File lib/p3-tvdb/search.rb, line 44 def get_episode_by_id(episode_id, language = self.language) response = self.class.get("/#{@api_key}/episodes/#{episode_id}/#{language}.xml").parsed_response if response["Data"] && response["Data"]["Episode"] Episode.new(self, response["Data"]["Episode"]) else nil end end
get_series_by_id(series_id, language = self.language)
click to toggle source
# File lib/p3-tvdb/search.rb, line 34 def get_series_by_id(series_id, language = self.language) response = self.class.get("/#{@api_key}/series/#{series_id}/#{language}.xml").parsed_response if response["Data"] && response["Data"]["Series"] Series.new(self, response["Data"]["Series"]) else nil end end
search(series_name)
click to toggle source
# File lib/p3-tvdb/search.rb, line 20 def search(series_name) response = self.class.get("/GetSeries.php", {:query => {:seriesname => series_name, :language => @language}}).parsed_response return [] unless response["Data"] case response["Data"]["Series"] when Array response["Data"]["Series"] when Hash [response["Data"]["Series"]] else [] end end