lib/ruby-tmdb/tmdb.rb in ruby-tmdb-0.0.21 vs lib/ruby-tmdb/tmdb.rb in ruby-tmdb-0.1.0

- old
+ new

@@ -21,16 +21,22 @@ end def self.api_call(method, data, language = "en") raise ArgumentError, "Tmdb.api_key must be set before using the API" if(Tmdb.api_key.nil? || Tmdb.api_key.empty?) url = Tmdb.base_api_url + method + '/' + language + '/yaml/' + Tmdb.api_key + '/' + CGI::escape(data.to_s) + # Memoize this API call response = @@api_response[url] ||= begin Tmdb.get_url(url) end if(response.code.to_i != 200) - return [] + return nil end - YAML::load(response.body) + body = YAML::load(response.body) + if( body.first.include?("Nothing found")) + return nil + else + return body + end end # Get a URL and return a response object, follow upto 'limit' re-directs on the way def self.get_url(uri_str, limit = 10) return false if limit == 0 \ No newline at end of file