This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

imdb tcl aint working anymore

Old posts that have not been replied to for several years.
Locked
D
DrMobius

imdb tcl aint working anymore

Post by DrMobius »

hi dudes ,

today imdb changed something on their website and know the imdb script from GQsm isnt working anymore

anyone could help with updating the script or knowing the email address of GQsm

thx for helping me


DrMobius
r
r00tb0y

Post by r00tb0y »

heya...
i got a fix for ya...

search for this line in imdb.tcl:
set newurl [string range $location 9 [expr [string length $location] - 12]]

and insert following line below:
set newurl "[string range $newurl 0 18]title/tt[string range $newurl 25 [string length $newurl]]/"

that's it...

r00tb0y
T
TheDevil

Post by TheDevil »

i tried to change this line, but doesnt work ??? can you give an url to download the new imdb.tcl file ?
j
jdp

Post by jdp »

Yeah, r00tb0y's fix didn't work for me either. Maybe he just has a different version? I'm using imdb-20030014.tcl.

Well anyway, I decided to figure it out for myself and after an hour and a half (tcl noob, here) I got it to work. Try this fix:



Search for:
set title [string range $title 6 [expr [string length $title] - 2]]
and change to...
set title [string range $title 13 [expr [string length $title] - 2]]/

Search for: (same as r00tb0y's..)
set newurl [string range $location 9 [expr [string length $location] - 12]]
and change to...
append newurl $imdburl [string range $location 34 [expr [string length $location] -12]]/

Also change the imdburl variable as so:
set imdburl "http://www.imdb.com/title/tt"



That should do it. At least it did for me. :wink:
T
TheDevil

Post by TheDevil »

thxx it works very fine now !
A
Ajaxjood

Post by Ajaxjood »

i got this error now :(

[14:31] Tcl error [imdb_handler]: couldn't open socket: host is unreachable
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Ajaxjood, that means there is no network :o
try showing usthe imdb_handler proc.
A
Ajaxjood

Post by Ajaxjood »

Code: Select all

#########################################################################
# Chilla's IMDb info script
# 
##
# Notes for this version: Thanks to 2dee for showing me his
# imdb site update fix. Thanks to TotaLGaZ for his help.
# Thanks to Chilla and FAN for their work on this brilliant script.
# Would like to make the options selectable from the partyline and also
# add a disable trigger in channel(both specific and global) option. Who 
# knows might get round to it one day but if anyone else wants to then it 
# will save me a job.
##
#
# Version: 20030014 - works with updated imdb site, new option of public
# or notice response to chan triggers.
# - GQsm http://forum.egghelp.org
##
# Version: 20020604 - fixed misc http/html stuff, added msg command - FAN
##
# Version: 20011031 - - Chilla
#########################################################################

# base imdb url, to which you can append "/Title?######" or whatever
set imdburl "http://www.imdb.com"

# the imdb search script
set imdbsearchurl "http://imdb.com:80/Tsearch?"

# 1 for each of these means that the respective values will ALWAYS show
# and that command options for these will be disregarded
# leave zero to keep them an option at the command line
set show_rating 1 
set show_genre 1
set show_tagline 1
set show_outline 0
set show_cast 0

# for a channel !imdb request
# set to 1 = title ,rating, genre and tagline(if selected) will be displayed
# publicly to the channel
# set to 0 = all results will be sent as private notice
set pub_or_not 0

#########################################################################
# DO NOT MODIFY BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!
#########################################################################

set DEBUG 0
set imdbVERSION 20030014
set b_agent "MSIE 6.0" 

# If you are getting http error messages, try uncommentign this next line:
#package forget http
package require http 2.3

bind pub -|- !imdb imdb_handler
bind msg -|- !imdb imdb_msghandler

proc imdb_handler { nick uhost hand chan args } {
	global DEBUG imdbVERSION imdburl imdbsearchurl b_agent
	global show_rating show_genre show_tagline show_outline show_cast
	global pub_or_not

   # How do you want your results ? chan or priv
	if {$pub_or_not == 1 } {
	set toput "PRIVMSG $chan"
	} else {
	set toput "NOTICE $nick"
	}

          # set to defaults
		set o_rating $show_rating 
		set o_genre $show_genre 
		set o_tagline $show_tagline
		set o_outline $show_outline 
		set o_cast $show_cast


		set checkargs [string trim $args " \n"]

		# if no arguments passed, show help
		if {[string compare $checkargs "{}"] == 0} {
			putserv "NOTICE $nick :IMDb info script v$imdbVERSION - 7General Help"
			putserv "NOTICE $nick :14<===========================================>"
			putserv "NOTICE $nick :7!imdb \[options\] <imdb title>"
			putserv "NOTICE $nick :7options: -r     ratings" 
			putserv "NOTICE $nick :7         -g     genre" 
			putserv "NOTICE $nick :7         -t     tagline" 
			putserv "NOTICE $nick :7         -o     plot outline" 
			putserv "NOTICE $nick :7         -c     cast" 
			putserv "NOTICE $nick :7Example: !imdb -o -c Beautiful Mind" 
			return	
		} 

	# Look for command line options and enable each, as desired
	set fargs ""
		set imdbtitle ""
		foreach piece [split $args " "] {
			set piece	[string trim $piece "{}"]
				if {[string compare $piece "-r"] == 0 } {
					set o_rating 1
				} elseif {[string compare $piece "-g"] == 0 } {
					set o_genre 1
				} elseif {[string compare $piece "-t"] == 0 } {
					set o_tagline 1
				} elseif {[string compare $piece "-o"] == 0 } {
					set o_outline 1
				} elseif {[string compare $piece "-c"] == 0 } {
					set o_cast 1
				} else {
					set fargs "$fargs $piece"
				}
		}
        #set fargs [string trimleft $args]
	if {$DEBUG == 1} {
		putserv "NOTICE $nick :I am doing a search for \"$fargs\" on imdb.com"
	}

	set query $fargs

		# do initial search
		set searchString [ ::http::formatQuery $query ] 
                set searchString [string trimleft $searchString "+"]		
                if {$DEBUG == 1} {
		 putserv "NOTICE $nick :searchString: \"$searchString\""		
		}
                set page [::http::config -useragent $b_agent]
                set page [::http::geturl ${imdbsearchurl}title=${searchString}&sort=smart&tv=off]

		set redirect 0
		set newurl ""

		set lines [split [::http::data $page] \n]
		set numLines [llength $lines]

		for {set i 0} {$i < $numLines} {incr i 1} {
			set line [lindex $lines $i]
				#if redirect necessary, find first link and redirect
                                #putserv "NOTICE $nick : $line"
				if {[string compare $line "<TITLE>IMDb title search</TITLE>"] == 0} {
					set redirect 1
		                        #putserv "NOTICE $nick : redirect 1"
						for {} {$i < $numLines} {incr i 1} {
							set line [lindex $lines $i]
								if {[string compare -length 8 $line "<OL><LI>"] == 0} {
									regexp HREF=\"\[^\"\]*\" $line title
										set title [string range $title 6 [expr [string length $title] - 2]] 
										append newurl $imdburl $title
	
										# get the page redirected to
										set page [::http::config -useragent $b_agent]
										set page [::http::geturl ${newurl}]
										set lines [split [::http::data $page] \n]
								}
						}
					set i $numLines
				}
		}

	# if no redirect happened, then get first page on match

	if {$redirect == 0} {
		upvar 0 $page oldpage
			regexp Location\ \[^\ \]*\ Connection $oldpage(meta) location
		        #putserv "NOTICE $nick : $oldpage(meta)"                        
			set newurl [string range $location 9 [expr [string length $location] - 12]]
			set page [::http::config -useragent $b_agent]
			set page [::http::geturl ${newurl}]
			set lines [split [::http::data $page] \n]
	}

	# for bogus searches
	if {[string length $newurl] == 0} {
		putserv "NOTICE $nick :No no no! I can't find that!"
			return
	}

	set numLines [llength $lines]

	# scan for wanted data from the page
		for {set i 0} {$i < $numLines} {incr i 1} {
			set line [lindex $lines $i]
				if {[string compare -length 7 $line "<title>"] == 0} {
					# the movie title, year, url
					set title [string range $line 7 [expr [string length $line] - 9]]
						set title [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $title]
						putserv "$toput :$title \( $newurl \)"
				} elseif {($o_tagline == 1) && ([regexp \[.\]*Tagline:\[.\]* $line] > 0)} {
					# the tagline
					regsub -all \<\[^\>\]*\> $line "" tagline
						regsub -all \\\(\[^\\\)\]*\\\) $tagline "" tagline 
						regsub -all \[\ \t\]+ $tagline " " tagline 
						regsub -all \&nbsp\; $tagline " " tagline
						set tagline [string trim $tagline " "]
						set tagline [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $tagline]
						putserv "$toput :$tagline"
				} elseif {($o_outline == 1) && ([regexp \[.\]*Outline:\[.\]* $line] > 0)} {
					# the outline
					regsub -all \<\[^\>\]*\> $line "" outline
						regsub -all \\\(\[^\\\)\]*\\\) $outline "" outline 
						regsub -all \[\ \t\]+ $outline " " outline 
						regsub -all \&nbsp\; $outline " " outline
						set outline [string trim $outline " "]
						set outline [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $outline]
						putserv "NOTICE $nick :$outline"
				} elseif {($o_genre == 1) && ([regexp \[.\]*Genres\[.\]* $line] > 0)} {
					# the genre
					regsub -all \<\[^\>\]*\> $line "" genre
						regsub -all \\\(\[^\\\)\]*\\\) $genre "" genre
						regsub -all \[\ \t\]+ $genre " " genre
						set genre [string trim $genre " "]
						set genre "Genre: $genre"
						putserv "$toput :$genre"
				} elseif {($o_rating == 1) && ([regexp \[.\]*User\ Rating\[.\]* $line] > 0)} { 
					# the user rating 
					set j [expr $i + 3] 
					set line2 [lindex $lines $j] 
					set j [expr $i + 4] 
					set line3 [lindex $lines $j] 
					regsub -all \<\[^\>\]*\> $line3 "" rating 
						regsub -all \&nbsp\; $rating " " rating 
						regsub -all \[\ \t\]+ $rating " " rating 
						set rating [string trim $rating " "] 
						set goldstars [regexp -all goldstar $line2] 
						set greystars [expr 10 - $goldstars] 
					
						# generating the rating bar 
						set marker "*" 
						set rating_bar "11\[7" 
						for {set i2 0} {$i2 < $goldstars} {incr i2 1} { 
							set rating_bar "$rating_bar$marker" 
						} 
					set marker "-" 
						set rating_bar "$rating_bar14" 
						for {set i3 0} {$i3 < $greystars} {incr i3 1} { 
							set rating_bar "$rating_bar$marker" 
						} 
					set rating_bar "$rating_bar11\]" 
						putserv "$toput :$rating $rating_bar"
				} elseif {($o_cast == 1) && ([regexp \[.\]*\\\.\\\.\\\.\\\.\[.\]* $line] > 0)} {

					if {[regexp Name $line] > 0} {
						regsub -all \<\[^\>\]*\> $line "" cast
						set cast [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $cast]
		                                set checkargs [string trim $args " \n"]						
							putserv "NOTICE $nick :$cast"
					}
				}
		}

}

proc imdb_msghandler { nick uhost hand args } {
	global DEBUG imdbVERSION imdburl imdbsearchurl b_agent
	global show_rating show_genre show_tagline show_outline show_cast

          # set to defaults
		set o_rating $show_rating 
		set o_genre $show_genre 
		set o_tagline $show_tagline
		set o_outline $show_outline 
		set o_cast $show_cast

		set checkargs [string trim $args " \n"]

		# if no arguments passed, show help
		if {[string compare $checkargs "{}"] == 0} {
			putserv "PRIVMSG $nick :IMDb info script v$imdbVERSION - 7General Help"
			putserv "PRIVMSG $nick :14<===========================================>"
			putserv "PRIVMSG $nick :7!imdb \[options\] <imdb title>"
			putserv "PRIVMSG $nick :7options: -r     ratings" 
			putserv "PRIVMSG $nick :7         -g     genre" 
			putserv "PRIVMSG $nick :7         -t     tagline" 
			putserv "PRIVMSG $nick :7         -o     plot outline" 
			putserv "PRIVMSG $nick :7         -c     cast" 
			putserv "PRIVMSG $nick :7Example: !imdb -o -c Beautiful Mind" 
			return	
		} 

	# Look for command line options and enable each, as desired
	set fargs ""
		set imdbtitle ""
		foreach piece [split $args " "] {
			set piece	[string trim $piece "{}"]
				if {[string compare $piece "-r"] == 0 } {
					set o_rating 1
				} elseif {[string compare $piece "-g"] == 0 } {
					set o_genre 1
				} elseif {[string compare $piece "-t"] == 0 } {
					set o_tagline 1
				} elseif {[string compare $piece "-o"] == 0 } {
					set o_outline 1
				} elseif {[string compare $piece "-c"] == 0 } {
					set o_cast 1
				} else {
					set fargs "$fargs $piece"
				}
		}
        #set fargs [string trimleft $args]
	if {$DEBUG == 1} {
		putserv "PRIVMSG $nick :I am doing a search for \"$fargs\" on imdb.com"
	}

	set query $fargs

		# do initial search
		set searchString [ ::http::formatQuery $query ] 
                set searchString [string trimleft $searchString "+"]		
                if {$DEBUG == 1} {
		 putserv "PRIVMSG $nick :searchString: \"$searchString\""		
		}
                set page [::http::config -useragent $b_agent]
                set page [::http::geturl ${imdbsearchurl}title=${searchString}&sort=smart&tv=off]

		set redirect 0
		set newurl ""

		set lines [split [::http::data $page] \n]
		set numLines [llength $lines]

		for {set i 0} {$i < $numLines} {incr i 1} {
			set line [lindex $lines $i]
				#if redirect necessary, find first link and redirect
                                #putserv "PRIVMSG $nick : $line"
				if {[string compare $line "<TITLE>IMDb title search</TITLE>"] == 0} {
					set redirect 1
		                        #putserv "PRIVMSG $nick : redirect 1"
						for {} {$i < $numLines} {incr i 1} {
							set line [lindex $lines $i]
								if {[string compare -length 8 $line "<OL><LI>"] == 0} {
									regexp HREF=\"\[^\"\]*\" $line title
										set title [string range $title 6 [expr [string length $title] - 2]] 
										append newurl $imdburl $title
	
										# get the page redirected to
										set page [::http::config -useragent $b_agent]
										set page [::http::geturl ${newurl}]
										set lines [split [::http::data $page] \n]
								}
						}
					set i $numLines
				}
		}

	# if no redirect happened, then get first page on match

	if {$redirect == 0} {
		upvar 0 $page oldpage
			regexp Location\ \[^\ \]*\ Connection $oldpage(meta) location
		        #putserv "PRIVMSG $nick : $oldpage(meta)"                        
			set newurl [string range $location 9 [expr [string length $location] - 12]]
			set page [::http::config -useragent $b_agent]
			set page [::http::geturl ${newurl}]
			set lines [split [::http::data $page] \n]
	}

	# for bogus searches
	if {[string length $newurl] == 0} {
		putserv "PRIVMSG $nick :No no no! I can't find that!"
			return
	}

	set numLines [llength $lines]

	# scan for wanted data from the page
		for {set i 0} {$i < $numLines} {incr i 1} {
			set line [lindex $lines $i]
				if {[string compare -length 7 $line "<title>"] == 0} {
					# the movie title, year, url
					set title [string range $line 7 [expr [string length $line] - 9]]
						set title [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $title]
						putserv "PRIVMSG $nick :$title \( $newurl \)"
				} elseif {($o_tagline == 1) && ([regexp \[.\]*Tagline:\[.\]* $line] > 0)} {
					# the tagline
					regsub -all \<\[^\>\]*\> $line "" tagline
						regsub -all \\\(\[^\\\)\]*\\\) $tagline "" tagline 
						regsub -all \[\ \t\]+ $tagline " " tagline 
						regsub -all \&nbsp\; $tagline " " tagline
						set tagline [string trim $tagline " "]
						set tagline [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $tagline]
						putserv "PRIVMSG $nick :$tagline"
				} elseif {($o_outline == 1) && ([regexp \[.\]*Outline:\[.\]* $line] > 0)} {
				# the outline
					regsub -all \<\[^\>\]*\> $line "" outline
						regsub -all \\\(\[^\\\)\]*\\\) $outline "" outline 
						regsub -all \[\ \t\]+ $outline " " outline 
						regsub -all \&nbsp\; $outline " " outline
						set outline [string trim $outline " "]
						set outline [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $outline]
						putserv "PRIVMSG $nick :$outline"
				} elseif {($o_genre == 1) && ([regexp \[.\]*Genres\[.\]* $line] > 0)} {
					# the genre
					regsub -all \<\[^\>\]*\> $line "" genre
						regsub -all \\\(\[^\\\)\]*\\\) $genre "" genre
						regsub -all \[\ \t\]+ $genre " " genre
						set genre [string trim $genre " "]
						set genre "Genre: $genre"
						putserv "PRIVMSG $nick :$genre"
				} elseif {($o_rating == 1) && ([regexp \[.\]*User\ Rating\[.\]* $line] > 0)} { 
					# the user rating 
					set j [expr $i + 3] 
					set line2 [lindex $lines $j] 
					set j [expr $i + 4] 
					set line3 [lindex $lines $j] 
					regsub -all \<\[^\>\]*\> $line3 "" rating 
						regsub -all \&nbsp\; $rating " " rating 
						regsub -all \[\ \t\]+ $rating " " rating 
						set rating [string trim $rating " "] 
						set goldstars [regexp -all goldstar $line2] 
						set greystars [expr 10 - $goldstars] 
					
						# generating the rating bar 
						set marker "*" 
						set rating_bar "11\[7" 
						for {set i2 0} {$i2 < $goldstars} {incr i2 1} { 
							set rating_bar "$rating_bar$marker" 
						} 
					set marker "-" 
						set rating_bar "$rating_bar14" 
						for {set i3 0} {$i3 < $greystars} {incr i3 1} { 
							set rating_bar "$rating_bar$marker" 
						} 
					set rating_bar "$rating_bar11\]" 
						putserv "PRIVMSG $nick :$rating $rating_bar"
				} elseif {($o_cast == 1) && ([regexp \[.\]*\\\.\\\.\\\.\\\.\[.\]* $line] > 0)} {

					if {[regexp Name $line] > 0} {
						regsub -all \<\[^\>\]*\> $line "" cast
						set cast [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è è  é é ê ê á á à à } $cast]
		                                set checkargs [string trim $args " \n"]						
							putserv "PRIVMSG $nick :$cast"
					}
				}
		}

}

putlog " -=\[ chilla's IMDB info version $imdbVERSION loaded \]=- lastupdate 22-08-02 "
D
DrMobius

Post by DrMobius »

thx works fine for me :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Ajaxjood, I only requested the imdb_handler proc, not the whole script :s

anyways, it must be a problem from the site your bot was trying to connect to, or from your ISP.
j
jago

Post by jago »

also if your bot is connecting to imdb through proxy:

change this:
regexp Location\ \[^\ \]*\ Connection $oldpage(meta) location

to this:
regexp Location\ \[^\ \]*\ Content-Type $oldpage(meta) location

and the new line posted by jdp:
append newurl $imdburl [string range $location 34 [expr [string length $location] -12]]/

goes to :

append newurl $imdburl [string range $location 34 [expr [string length $location] -13]]/

and to be correct about error reporting:
and this row on the next line after if {$redirect == 0} {

set location ""


that's all, now it fully working.
Locked