+ if params[:movie]
+ movie = params[:movie].to_s
+ info = i.info(movie, :type => :title, :characters => true)
+ else
+ what = params[:what].to_s
+ type = params[:type].intern
+ info = i.info(what, :type => type)
+ if !info
+ m.reply "nothing found for #{what}"
+ return nil
+ end
+ end
+ if info.length == 1
+ m.reply Utils.decode_html_entities(info.first.join("\n"))
+ else
+ m.reply info.map { |si|
+ Utils.decode_html_entities si.join(" | ")
+ }.join("\n")
+ end
+ end
+
+ # Find the movies with a participation of :who in the year :year
+ # TODO: allow year to be either a year or a decade ('[in the] 1960s')
+ #
+ def movies(m, params)
+ who = params[:who].to_s
+ years = params[:years]
+ role = params[:role]
+ if role and role.downcase == 'anything'
+ role = nil
+ elsif not role
+ case params[:prefix].intern
+ when :with
+ role = /actor|actress/i
+ when :by
+ role = 'director'
+ end
+ end
+
+ name_urls = i.search(who, :type => :name)
+ unless name_urls
+ m.reply "nothing found about #{who}, sorry"
+ return
+ end
+
+ movie_urls = i.year_movies(name_urls, years, role)
+ debug movie_urls.inspect
+ debug movie_urls[0][1]
+
+ if movie_urls.length == 1 and movie_urls[0][1]
+ m.reply movie_urls.join("\n")
+ else
+ m.reply movie_urls.map { |si|
+ si[1] = "no movies in #{years}" unless si[1]
+ Utils.decode_html_entities si.join(" | ")
+ }.join("\n")
+ end
+ end
+
+ # Find the character played by :who in :movie
+ #
+ def character(m, params)
+ who = params[:who].to_s
+ movie = params[:movie].to_s
+
+ name_urls = i.search(who, :type => :name)
+ unless name_urls
+ m.reply "nothing found about #{who}, sorry"
+ return
+ end
+
+ movie_urls = i.search(movie, :type => :title)
+ unless movie_urls
+ m.reply "nothing found about #{who}, sorry"
+ return
+ end
+
+ info = i.name_in_movie(name_urls, movie_urls)
+ if info.empty?
+ m.reply "nothing found about #{who} in #{movie}, sorry"
+ else
+ m.reply info.join("\n")
+ end
+ end
+
+ # Report the characters in movie :movie
+ #
+ def characters(m, params)
+ movie = params[:movie].to_s
+
+ urls = i.search(movie, :type => :title)
+ unless urls
+ m.reply "nothing found about #{movie}"