X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=data%2Frbot%2Fplugins%2Fimdb.rb;h=57cae635d4535bb75cccc1c1dfaa6360ed6b12ee;hb=c4e7896a87d97988926d3b57f62599384c5c7189;hp=6e3ec53047fd8fa53fe9c90bd7317a08f9b00ade;hpb=43d4d3929a07b1ac432d4bf173370938d1e704db;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git
diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb
index 6e3ec530..57cae635 100644
--- a/data/rbot/plugins/imdb.rb
+++ b/data/rbot/plugins/imdb.rb
@@ -13,13 +13,16 @@
class Imdb
IMDB = "http://www.imdb.com"
- TITLE_OR_NAME_MATCH = /]*)>([^<]*)<\/a>/
- TITLE_MATCH = /]*)>([^<]*)<\/a>/
- NAME_MATCH = /]*)>([^<]*)<\/a>/
- CREDIT_NAME_MATCH = /#{NAME_MATCH}<\/td>
]+> \.\.\. <\/td> | ]+>(.+?)<\/td>/
+ 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
@@ -30,8 +33,12 @@ class Imdb
end
def search(rawstr, rawopts={})
+ # 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']
+ str << "&site=aka" if @bot.config['imdb.aka']
opts = rawopts.dup
opts[:type] = :both unless opts[:type]
return do_search(str, opts)
@@ -52,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']
@@ -99,7 +109,7 @@ class Imdb
end
def grab_info(info, body)
- / |