From: Giuseppe Bilotta Date: Sun, 8 Apr 2007 18:05:50 +0000 (+0000) Subject: imdb plugin: movies by person/year can now be shown in decades, and by shortening... X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=37c38bb9571052b75ede02602e568754c5ff8158;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git imdb plugin: movies by person/year can now be shown in decades, and by shortening the year (19xx or 1xxx is assumed) --- diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb index 0464ba3a..8c46f3fe 100644 --- a/data/rbot/plugins/imdb.rb +++ b/data/rbot/plugins/imdb.rb @@ -211,10 +211,10 @@ class Imdb return info if opts[:name_only] - if year = opts[:movies_in_year] + if opts[:movies_by_year] filmoyear = @bot.httputil.get(IMDB + sr + "filmoyear") if filmoyear - info << filmoyear.scan(/#{TITLE_MATCH} \(#{year}\)[^\[\n]*((?:\s+\[[^\]]+\](?:\s+\([^\[<]+\))*)+)\s+ year) + info = info_name(url, :movies_by_year => true) debug info.inspect @@ -296,11 +312,13 @@ class Imdb bclip = b[1][0,5] quot = '"' (aclip == quot ? 1 : -1) <=> (bclip == quot ? 1 : -1) - }.each { |url, pre_title, pre_roles| + }.each { |url, pre_title, year, pre_roles| + next unless years.include?(year) title = fix_article(pre_title.ircify_html) if title[0] == ?" and not @bot.config['imdb.tv_series_in_movies'] next end + title << " (#{year})" unless years.length == 1 role_array = [] pre_roles.strip.scan(/\[([^\]]+)\]((?:\s+\([^\[]+\))+)?/) { |txt, comm| if txt.match(/^(.*)\s+\.\.\.\.\s+(.*)$/) @@ -401,7 +419,7 @@ class ImdbPlugin < Plugin # def movies(m, params) who = params[:who].to_s - year = params[:year] + years = params[:years] name_urls = i.search(who, :type => :name) unless name_urls @@ -409,7 +427,7 @@ class ImdbPlugin < Plugin return end - movie_urls = i.year_movies(name_urls, year) + movie_urls = i.year_movies(name_urls, years) debug movie_urls.inspect debug movie_urls[0][1] @@ -417,7 +435,7 @@ class ImdbPlugin < Plugin m.reply movie_urls.join("\n") else m.reply movie_urls.map { |si| - si[1] = "no movies in #{year}" unless si[1] + si[1] = "no movies in #{years}" unless si[1] Utils.decode_html_entities si.join(" | ") }.join("\n") end @@ -466,7 +484,7 @@ end plugin = ImdbPlugin.new plugin.map "imdb [:type] *what", :requirements => { :type => /name|title/ }, :defaults => { :type => 'both' } -plugin.map "movies :prefix *who in :year", :requirements => { :prefix => /with|by|from/, :year => /\d+/ } +plugin.map "movies :prefix *who in [the] :years", :requirements => { :prefix => /with|by|from/, :years => /'?\d+s?/ } plugin.map "character [played] by *who in *movie" plugin.map "character of *who in *movie" plugin.map "characters in *movie", :action => :imdb