class Plugins::Movie
Public Instance Methods
find_movie(m, movie)
click to toggle source
# File lib/Zeta/plugins/movie.rb, line 15 def find_movie(m, movie) data = query_movie(movie) if data && data.response == 'True' m.reply "Movie ⊥ #{data.title} (#{data.year}) <#{data.rated}> #{data.plot.to_s.strip[0..800]} [www.imdb.com/title/#{data.imdbid}/]" elsif data && data.response == 'False' m.reply data.error else m.reply 'Unable to find movie!' end end
Private Instance Methods
query_movie(m)
click to toggle source
# File lib/Zeta/plugins/movie.rb, line 27 def query_movie(m) parser = URI::Parser.new year = m[/:\d+/].gsub(/:/, '') if m[/:\d+/] movie = parser.escape(m.gsub(/:\d+/, '')) data = JSON.parse( # RestClient.get("http://www.omdbapi.com/?t=#{movie}&y=#{year}") RestClient.get("http://www.omdbapi.com/?t=#{movie}&y=#{year}&apikey=#{Config.secrets[:omdb]}").body ) OpenStruct.new( title: data['Title'], year: data['Year'], rated: data['Rated'], released: data['Released'], runtime: data['Runtime'], genre: data['Genre'], director: data['Director'], writer: data['Writer'], actors: data['Actors'], plot: data['Plot'], language: data['Language'], country: data['Country'], awards: data['Awards'], poster: data['Poster'], metascore: data['Metascore'], imdbrating: data['imdbRating'], imdbvotes: data['imdbVotes'], imdbid: data['imdbID'], type: data['Type'], response: data['Response'], error: data['Error'] ) rescue nil end