+
+ def year_movies(urls, years_txt_org, role_req)
+ years_txt = years_txt_org.dup
+ years_txt.sub!(/^'/,'')
+ years_txt = "9#{years_txt}" if years_txt.match(/^\d\ds?$/)
+ years_txt = "1#{years_txt}" if years_txt.match(/^\d\d\ds?$/)
+
+ years = []
+ case years_txt
+ when /^\d\d\d\d$/
+ years << years_txt
+ when /^(\d\d\d\d)s$/
+ base = $1.to_i
+ base.upto(base+9) { |year|
+ years << year.to_s
+ }
+ end
+
+ urls.map { |url|
+ info = info_name(url, :movies_by_year => true)
+
+ debug info.inspect
+
+ name_url = info.first
+ data = info[1]
+
+ movies = []
+ # Sort by pre-title putting movies before TV series
+ data.sort { |a, b|
+ aclip = a[1][0,5]
+ bclip = b[1][0,5]
+ quot = '"'
+ (aclip == quot ? 1 : -1) <=> (bclip == quot ? 1 : -1)
+ }.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|
+ role = nil
+ extra = nil
+ if txt.match(/^(.*)\s+\.\.\.\.\s+(.*)$/)
+ role = $1
+ extra = "(#{$2.ircify_html})"
+ else
+ role = txt
+ end
+ next if role_req and not role.match(/^#{role_req}/i)
+ if comm
+ extra ||= ""
+ extra += comm.ircify_html if comm
+ end
+ role_array << [role, extra]
+ }
+ next if role_req and role_array.empty?
+
+ roles = role_array.map { |ar|
+ if role_req
+ ar[1] # works for us both if it's nil and if it's something
+ else
+ ar.compact.join(" ")
+ end
+ }.compact.join(', ')
+ roles = nil if roles.empty?
+ movies << [roles, title].compact.join(": ")
+ }
+
+ if movies.empty?
+ [name_url, nil]
+ else
+ [name_url, movies.join(" | ")]
+ end
+ }
+ end
+
+ def name_in_movie(name_urls, movie_urls)
+ info = []
+ movie_urls.each { |movie|
+ title_info = info_title(movie, :title_only => true)
+ valid = []
+
+ data = @bot.httputil.get(IMDB + movie + "fullcredits")
+ data.scan(CREDIT_NAME_MATCH).each { |url, name, role|
+ valid << [url, name.ircify_html, role.ircify_html] if name_urls.include?(url)
+ }
+ valid.each { |url, name, role|
+ info << "%s : %s was %s in %s" % [name, IMDB + url, role, title_info]
+ }
+ }
+ return info
+ end
+
+