X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fimdb.rb;h=0f5c6024b6306ddcd73079500208dde7a02dbf55;hb=90656f4203a0a989b6fb110d4a07598dd186b84c;hp=e5f3b7c20eed46945f2de33acf594b64df7e1c21;hpb=93c89892b9603bda7665e0ae490ad0935da2ba84;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git
diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb
index e5f3b7c2..0f5c6024 100644
--- a/data/rbot/plugins/imdb.rb
+++ b/data/rbot/plugins/imdb.rb
@@ -11,16 +11,18 @@
#
# License:: MIT license
-require 'uri/common'
-
class Imdb
- IMDB = "http://us.imdb.com"
- TITLE_OR_NAME_MATCH = /]*)>([^<]*)<\/a>/
- TITLE_MATCH = /]*)>([^<]*)<\/a>/
- NAME_MATCH = /]*)>([^<]*)<\/a>/
+ IMDB = "https://www.imdb.com"
+ TITLE_OR_NAME_MATCH = /]*)>([^<]*)<\/a>/
+ TITLE_MATCH = /]*)>([^<]*)<\/a>/
+ NAME_MATCH = /]*)>([^<]*)<\/a>/
+ CHAR_MATCH = /]*)>([^<]*)<\/a>/
+ CREDIT_NAME_MATCH = /#{NAME_MATCH}\s*<\/td>\s*
]+>\s*\.\.\.\s*<\/td>\s* | ]+>\s*(.+?)\s*<\/td>/m
FINAL_ARTICLE_MATCH = /, ([A-Z]\S{0,2})$/
+ DESC_MATCH = //
MATCHER = {
+ :character => CHAR_MATCH,
:title => TITLE_MATCH,
:name => NAME_MATCH,
:both => TITLE_OR_NAME_MATCH
@@ -31,8 +33,12 @@ class Imdb
end
def search(rawstr, rawopts={})
- str = URI.escape(rawstr)
- str << ";site=aka" if @bot.config['imdb.aka']
+ # allow the user to search directly for (movie) IDs
+ if rawstr.match /$tt\d+^/ then
+ return ["/movie/#{rawstr}/"]
+ end
+ str = CGI.escape(rawstr)
+ str << "&site=aka" if @bot.config['imdb.aka']
opts = rawopts.dup
opts[:type] = :both unless opts[:type]
return do_search(str, opts)
@@ -53,6 +59,9 @@ class Imdb
matcher = MATCHER[opts[:type]]
if resp.code == "200"
+ if opts[:all]
+ return resp.body.scan(matcher).map { |m| m.first }.compact.uniq
+ end
m = []
m << matcher.match(resp.body) if @bot.config['imdb.popular']
if resp.body.match(/\(Exact Matches\)<\/b>/) and @bot.config['imdb.exact']
@@ -89,9 +98,9 @@ class Imdb
type = sr.match(/^\/([^\/]+)\//)[1].downcase.intern rescue nil
case type
when :title
- results << info_title(sr)
+ results << info_title(sr, opts)
when :name
- results << info_name(sr)
+ results << info_name(sr, opts)
else
results << "#{sr}"
end
@@ -100,7 +109,7 @@ class Imdb
end
def grab_info(info, body)
- / |