Code: Select all
Tcl error [imdb_proc]: can't read "location": no such variable
Would appreciate it if someone could take a look and see if there is something wrong, or if imdb updated or something that might cause this error.
Thanks
Code: Select all
# imdb info (ppx edition) v1.1.0 by phillie
# based on the original imdb info script released by bounty
#
# this script is based on bounty's imdb info script which is, as
# far as i known, distributed via www.ioftpd.com's forum.
# ive added various features that ive missed in his version, so here
# is mine.
#
# added/changelog:
#
# - added 6 variables from newest imdb by b0unty
# - added a break to channel_check if clause so it wont set permission to 0 in some cases
#
# usage:
#
# &imdb [-hPrx] <releasename/moviename>
#
# -h show help
# -P just parse releasename and return it (debug-mode only)
# -r use releasename parsing
# -x use extended output
#
# if -x is not given, the limited output will be used.
#
# cookies for output configuration:
#
# title = %title
# url = %url
# director = %name
# genre = %genre
# synopsis = %plot
# rating = %rating
# votes = %votes
# runtime = %time
# budget = %budget
# screens = %screens
# (added in 1.1.0)
# tagline = %tagline
# mpaa = %mpaa
# country = %country
# language = %language
# sound mix = %soundmix
# top 250 = %top250
#
# cookies for output format:
#
# bold = %bold
# underline = %uline
# colors = %color#,#
# new line = \n
#
# to reset colors, just use %color without any arguments.
#
# output configuration preset:
#
# limited: <bot> [iMDB] moviename (2003) (action) -> rating 9.6/10 (1,000 votes)
#
# extended:
#
# <bot> [iMDB] moviename (2003) (action) -> rating 9.6/10 (1,000 votes) -> runtime 98 mins.
# <bot> [iMDB] plot: this movie is about how much perplex rocks.
# <bot> [iMDB] screens: 5,000 Screens -> director: phillie -> budget: $10,000,000,000
# <bot> [iMDB] url: http://perplex.home.page.is.coming.soon.org/
#
# config:
# -------
# define your limited output here:
set announce(limited) "\[%boldiMDB%bold] %title (%genre) -> rating %rating (%votes votes) -> runtime %time mins.\n\[%boldiMDB%bold] screens: %screens -> director: %name -> budget: %budget\n\[%boldiMDB%bold] url: %url"
# define your extended output here:
set announce(extended) "\[%boldiMDB%bold] %title (%genre) -> rating %rating (%votes votes) -> runtime %time mins.\n\[%boldiMDB%bold] plot: %plot\n\[%boldiMDB%bold] screens: %screens -> director: %name -> budget: %budget\n\[%boldiMDB%bold] url: %url"
# debug mode?
set IMDB_DEBUG 0
# proxy support. leave empty to disable
set IMDBhost ""
set IMDBport ""
# trigger you want to use
set IMDBtrigger "!imdb"
# userflags needed to use this script
set IMDBrights "-|-"
# use +imdb chan-mode
set IMDBperm 0
# 0 for response via notice to $nick, 1 for msg to $chan
set pub_or_not 1
#################################################################
setudef flag imdb
package require http
bind pub $IMDBrights $IMDBtrigger imdb_proc
bind pub n|n &imdbparsetest imdb_parse
set CUTer(langs) "german english spanish dutch frensh polish swedub swedish swesub"
set CUTer(types) "xxx dvdrip ld ts dl subbed line dubbed dubbed mic screener dvdscreener tvrip dtv proper limited custom crypted repack uncut internal unsubbed ws dvdscr satrip nfo dc se ac3"
set CUTer(forms) "xvid divx vcd svcd dvdr"
proc htmlcodes {tempfile} {
set mapfile [string map {" ' & & [ ( \ / ] ) { ( } ) £ £ ¨ ¨ © © « « ® ® } $tempfile]
set mapfile [string map {´ ´ · · ¹ ¹ » » ¼ ¼ ½ ½ ¾ ¾ À À Á Á Â Â } $mapfile]
set mapfile [string map {Ã Ã Ä Ä Å Å Æ Æ Ç Ç È È É É Ê Ê Ë Ë Ì Ì Í Í Î Î Ï Ï Ð Ð Ñ Ñ Ò Ò Ó Ó Ô Ô Õ Õ Ö Ö } $mapfile]
set mapfile [string map {× × Ø Ø Ù Ù Ú Ú Û Û Ü Ü Ý Ý Þ Þ ß ß à à á á â â ã ã ä ä å å æ æ ç ç è è é é ê ê } $mapfile]
set mapfile [string map {ë ë ì ì í í î î ï ï ð ð ñ ñ ò ò ó ó ô ô õ õ ö ö ÷ ÷ ø ø ù ù ú ú û û ü ü ý ý þ þ } $mapfile]
return $mapfile
}
proc channel_check { chan } {
foreach setting [channel info $chan] {
if {[regexp -- {^[\+-]} $setting]} {
if {![string compare "+imdb" $setting]} {
set permission 1
break
} else {
set permission 0
}
}
}
return $permission
}
proc replacevar {strin what withwhat} {
set output $strin
set replacement $withwhat
set cutpos 0
while { [string first $what $output] != -1 } {
set cutstart [expr [string first $what $output] - 1]
set cutstop [expr $cutstart + [string length $what] + 1]
set output [string range $output 0 $cutstart]$replacement[string range $output $cutstop end]
}
return $output
}
proc imdb_parse_rel {rel} {
global CUTer
set rel [lreplace [string map {. " " _ " "} $rel] end end]
foreach LANG $CUTer(langs) { set Ls [lsearch [string tolower $rel] [string tolower $LANG]]; if {$Ls != "-1"} { set rel [lreplace $rel $Ls $Ls] } }
foreach TYPE $CUTer(types) { set Ts [lsearch [string tolower $rel] [string tolower $TYPE]]; if {$Ts != "-1"} { set rel [lreplace $rel $Ts $Ts] } }
foreach FORM $CUTer(forms) { set Fs [lsearch [string tolower $rel] [string tolower $FORM]]; if {$Fs != "-1"} { set rel [lreplace $rel $Fs $Fs] } }
return "$rel"
}
proc imdb_parse { nick uhost handle chan arg } {
set output [imdb_parse_rel $arg]
putserv "PRIVMSG $chan :$output"
return
}
proc imdb_proc { nick uhost handle chan argv } {
global IMDB_DEBUG IMDBtrigger announce pub_or_not IMDBperm
# channel_check permission
if {$IMDBperm == 1} {
set permission_result [channel_check $chan]
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG permission_result == $permission_result" }
if { $permission_result == 0 } { return }
}
if {$pub_or_not == 1 } { set toput "PRIVMSG $chan" } else { set toput "NOTICE $nick" }
set start 0
set extended 0
if {$argv == ""} {
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG no argv passed, show help notice" }
putserv "PRIVMSG $chan :\[\002iMDB\002\] try $IMDBtrigger -h"
return
}
if {[lindex $argv 0] == "-h" || [lindex $argv 1] == "-h" || [lindex $argv 2] == "-h" || [lindex $argv 3] == "-h"} {
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG argv == help, show help" }
putserv "PRIVMSG $nick :IMDB INFO (PPX EDITION) V1.1 BY PHILLIE/PPX - ORIGINAL BY BOUNTY"
putserv "PRIVMSG $nick :----------------------------------------------------------------"
putserv "PRIVMSG $nick :&imdb \[-hPrx\] <moviename/releasename>"
putserv "PRIVMSG $nick : "
putserv "PRIVMSG $nick :\002options\002:"
putserv "PRIVMSG $nick :\002-x\002 use detailed output"
putserv "PRIVMSG $nick :\002-r\002 convert releasename to moviename"
putserv "PRIVMSG $nick :\002-P\002 releasename parsing test (debug-mode only)"
putserv "PRIVMSG $nick :\002-h\002 show help"
return
}
# check for commands
if {[lindex $argv 0] == "-x" || [lindex $argv 1] == "-x" || [lindex $argv 2] == "-x" || [lindex $argv 3] == "-x"} {
incr start
incr extended
}
if {[lindex $argv 0] == "-r" || [lindex $argv 1] == "-r" || [lindex $argv 2] == "-r" || [lindex $argv 3] == "-r"} {incr start}
if {[lindex $argv 0] == "-P" || [lindex $argv 1] == "-P" || [lindex $argv 2] == "-P" || [lindex $argv 4] == "-P"} {
if {$IMDB_DEBUG == 1} {
incr start
putserv "PRIVMSG $chan :\[\002iMDB\002\] \002IMDB_DEBUG\002: [imdb_parse_rel [lrange $argv $start end]]"
return
} else {
putserv "PRIVMSG $chan :\[\002iMDB\002\] debug mode is disabled."
return
}
}
# create moviename using $start
if {[lindex $argv 0] == "-r" || [lindex $argv 1] == "-r" || [lindex $argv 2] == "-r" || [lindex $argv 3] == "-r"} {
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :releasename parsing [lrange $argv $start end] -> [imdb_parse_rel [lrange $argv $start end]]" }
set moviename [imdb_parse_rel [lrange $argv $start end]]
} else {
set moviename [lrange $argv $start end]
}
# initial search
set imdburl "http://us.imdb.com"
set imdbsearchurl "http://akas.imdb.com/find?tt=on;nm=on;mx=3;"
set searchString [::http::formatQuery $moviename]
set searchString [string trimleft $searchString "+"]
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG searchString: \"$searchString\"" }
set page [::http::config -useragent "MSIE 6.0" -proxyhost $::IMDBhost -proxyport $::IMDBport]
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG ${imdbsearchurl}q=$searchString" }
if {[catch {::http::geturl ${imdbsearchurl}q=$searchString -timeout 10000} page]} {
putlog "\002IMDB Error\002: $page"
} elseif {[http::status $page] == "timeout"} {
putlog "\002IMDB Error\002: Timeout after 10 seconds"
}
set html [::http::data $page]
::http::Finish $page
#if redirect necessary, find first link and redirect
if { [regexp {<title>IMDb name and title search} $html] == 1 } {
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG redirect 1" }
set ttcode "0000001"
if [regexp {/title/tt[0-9]+} $html ttcode] {
set pos [string last / $ttcode] ; incr pos
set ttcode [string range $ttcode $pos end]
}
# for bogus ttcode
if { $ttcode == "0000001" } {
putserv "$toput :No no no! I can't find that!"
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG bogus ttcode" }
return
}
set newurl "$imdburl/title/$ttcode/"
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG redirect 1 = $newurl" }
# get the page redirected to
unset html
set page [::http::config -useragent "MSIE 6.0" -proxyhost $::IMDBhost -proxyport $::IMDBport]
if {[catch {::http::geturl $newurl -timeout 10000} page]} {
putlog "\002IMDB Error\002: $page"
} elseif {[http::status $page] == "timeout"} {
putlog "\002IMDB Error\002: Timeout after 10 seconds"
}
set html [::http::data $page]
::http::Finish $page
# if no redirect happened, then get first page on match
} else {
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG redirect 0" }
upvar 0 $page oldpage
regexp {title/tt[0-9]+/} $oldpage(meta) location
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG redirect 0 Location == $location" }
set newurl "$imdburl/$location"
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG redirect 0 = $newurl" }
unset html
set page [::http::config -useragent "MSIE 6.0" -proxyhost $::IMDBhost -proxyport $::IMDBport]
if {[catch {::http::geturl $newurl -timeout 10000} page]} {
putlog "\002IMDB Error\002: $page"
} elseif {[http::status $page] == "timeout"} {
putlog "\002IMDB Error\002: Timeout after 10 seconds"
}
set html [::http::data $page]
::http::Finish $page
}
# for bogus searches
if {[string length $newurl] == 0} {
putserv "$toput :No no no! I can't find that!"
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG bogus searches" }
return
}
set title "N/A" ; set name "N/A" ; set genre "N/A"
set plot "N/A" ; set rating "N/A" ; set votes "N/A"
set runtime "N/A" ; set budget "N/A" ; set screens "N/A"
set tagline "N/A" ; set mpaa "N/A" ; set country "N/A"
set language "N/A" ; set soundmix "N/A" ; set top250 "N/A"
## get title
if [regexp {<title>[^<]+} $html title] {
set pos [expr [string last > $title] + 1]
set title [string range $title $pos end]
set title [htmlcodes $title]
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG title == $title" }
## get director
if [regexp {Directed by</b><br>\n<[^>]+>[^<]+} $html name] {
set pos [string last > $name] ; incr pos
set name [string range $name $pos end]
set name [htmlcodes $name]
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG director == $name" }
## get genre
if [regexp {<b class=\"ch\">Genre:</b>[\s\n]?<[^>]+>[\w-]+} $html genre] {
set pos [string last > $genre] ; incr pos
set genre [string range $genre $pos end]
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG genre == $genre" }
## get tagline
if [regexp {<b class="ch">Tagline:</b>[^<]+} $html tagline] {
set pos [string last > $tagline] ; incr pos
set tagline [string range $tagline $pos end]
set tagline [string trim $tagline]
set tagline [htmlcodes $tagline]
}
if {$IMDB_DEBUG == 1} { puthelp "NOTICE $nick :IMDB_DEBUG tagline == $tagline" }
## get plot
if [regexp {<b class=\"ch\">Plot (Summary|Outline):</b>[\s\n]+[^<]+} $html plot] {
set pos [string last > $plot] ; incr pos
set plot [string range $plot $pos end]
regsub -all {[\n\s]+} [string map "" {} {\"} '" $plot] { } plot
set plot [string trim $plot]
set plot [htmlcodes $plot]
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG plot == $plot" }
## get iMDb rating
if [regexp {<b>\d.\d/10</b> \([\w\s\d,]+\)} $html rating] {
set pos [string last ( $rating]
set pos1 [string first { } $rating $pos]
incr pos ; incr pos1 -1
set votes [string range $rating $pos $pos1]
set rating [string range $rating 3 8]
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG rating == $rating | votes == $votes" }
## get TOP 250
if [regexp {<a href="/top_250_films">[^\n]+} $html top250] {
regexp {#[^<]+} $top250 top250
}
if {$IMDB_DEBUG == 1} { puthelp "NOTICE $nick :IMDB_DEBUG top250 == $top250" }
## get MPAA
if [regexp {<b class="ch"><a href="/mpaa">[^\n]+} $html mpaa] {
regsub -all {<[^\>]*>} $mpaa {} mpaa
regsub {MPAA: } $mpaa {} mpaa
set mpaa [htmlcodes $mpaa]
}
if {$IMDB_DEBUG == 1} { puthelp "NOTICE $nick :IMDB_DEBUG mpaa == $mpaa" }
## get runtime
if [regexp {<b class=\"ch\">Runtime:</b>([\n\s]+)([\w:]+)(\d+)} $html runtime] {
regsub -all {[\n\s]+} $runtime {} runtime
set pos [string last > $runtime] ; incr pos
set runtime [string range $runtime $pos end]
set pos [string last : $runtime]
if {$pos != -1} {incr pos ; set runtime [string range $runtime $pos end]}
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG runtime == $runtime" }
## get country
if [regexp {<a href=./Sections/Countries[^\n]+} $html country] {
regsub -all {<[^\>]*>} $country {} country
}
if {$IMDB_DEBUG == 1} { puthelp "NOTICE $nick :IMDB_DEBUG country == $country" }
## get language
if [regexp {<a href=./Sections/Languages[^\n]+} $html language] {
regsub -all {<[^\>]*>} $language {} language
}
if {$IMDB_DEBUG == 1} { puthelp "NOTICE $nick :IMDB_DEBUG language == $language" }
## get soundmix
if [regexp {<a href=./List.sound-mix=[^\n]+} $html soundmix] {
regsub -all {<[^\>]*>} $soundmix {} soundmix
}
if {$IMDB_DEBUG == 1} { puthelp "NOTICE $nick :IMDB_DEBUG soundmix == $soundmix" }
unset html
set page2 [::http::config -useragent "MSIE 6.0" -proxyhost $::IMDBhost -proxyport $::IMDBport]
if {[catch {::http::geturl ${newurl}business -timeout 10000} page2]} {
putlog "\002IMDB Error\002: $page2"
} elseif {[http::status $page2] == "timeout"} {
putlog "\002IMDB Error\002: Timeout after 10 seconds"
}
set html [::http::data $page2]
::http::Finish $page2
## get budget
if [regexp {<b>Budget</b></dt>[\s\n]?<dd><[^>]+>[^<]+} $html budget] {
set pos [string last > $budget] ; incr pos
set budget [string range $budget $pos end]
set budget [string map {€ € £ £ } $budget]
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG budget == $budget" }
## get screens
if [regexp {<b>Opening Weekend</b></dt>[\s\n]?[^\n]+} $html opweek] {
if [regexp {\(USA\) \([^)]+\) \([^)]+\)} $opweek screens] {
set pos [string last ( $screens]
set pos1 [string last ) $screens]
incr pos ; incr pos1 -1
set screens [string range $screens $pos $pos1]
}
}
if {$IMDB_DEBUG == 1} { putserv "NOTICE $nick :IMDB_DEBUG screens == $screens" }
if {$extended == 1} {
set output $announce(extended)
} else {
set output $announce(limited)
}
set output [replacevar $output "%bold" "\002"]
set output [replacevar $output "%color" "\003"]
set output [replacevar $output "%uline" "\037"]
set output [replacevar $output "%title" $title]
set output [replacevar $output "%url" $newurl]
set output [replacevar $output "%name" $name]
set output [replacevar $output "%genre" $genre]
set output [replacevar $output "%tagline" $tagline]
set output [replacevar $output "%plot" $plot]
set output [replacevar $output "%rating" $rating]
set output [replacevar $output "%votes" $votes]
set output [replacevar $output "%time" $runtime]
set output [replacevar $output "%budget" $budget]
set output [replacevar $output "%screens" $screens]
set output [replacevar $output "%top250" $top250]
set output [replacevar $output "%mpaa" $mpaa]
set output [replacevar $output "%country" $country]
set output [replacevar $output "%language" $language]
set output [replacevar $output "%soundmix" $soundmix]
foreach line [split $output "\n"] {
putserv "$toput :$line"
}
}
putlog "imdb info - ppx edition v1.1.0 loaded ..."