View Single Post
Old 09-24-2003, 04:32 PM  
Blackthunder
Junior Member
 
Join Date: Sep 2003
Posts: 21
Default

*UPDATE*
German IMDB for DZSBOT 0.91:
Code:
#################################################################################
# SEARCH ON IMDB                                                                #
#################################################################################
package require http 2.4
proc imdbcall {vpath url user group winpath} {
	global star binary disable IMDBTAG IMDBMSG_STYLE
	set title "" ; set name "" ; set genre "" ; set plot "" ; set rating "" ; set bar "" ; set runtime "" ; set budget "" ; set screens ""
	set page [::http::config -useragent "MSIE 6.0"]
	set page [::http::geturl ${url}]
	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 {[string compare -length 7 $line "<title>"] == 0} {
			# movie title, year
			set title [string range $line 7 [expr [string length $line] - 9]]
			set title [htmlcodes $title]
		}
		if {([regexp \[.\]*Regie\[.\]* $line] > 0)} {
			# Directed by
			set jj [expr $i + 1]
			set name [lindex $lines $jj]
			regsub -all \<\[^\>\]*\> $name "" name
			set name [htmlcodes $name]
		}
		if {([regexp \[.\]*Genres\[.\]* $line] > 0)} {
			# genres
			regsub -all \<\[^\>\]*\> $line "" genre
			regsub -all \\\(\[^\\\)\]*\\\) $genre "" genre
			regsub -all \[\ \t\]+ $genre " " genre
			set genre [string trim $genre " "]
			#set genre [lindex $genre 0]
			set genre [htmlcodes $genre]
		}
		if {([regexp \[.\]*Plot\ Outline:\[.\]* $line] > 0) || ([regexp \[.\]*Kurzbeschreibung:\[.\]* $line] > 0)} {
			# plots
			regsub -all \<\[^\>\]*\> $line "" plot
			regsub -all \\\(\[^\\\)\]*\\\) $plot "" plot 
			regsub -all \[\ \t\]+ $plot " " plot 
			regsub -all \&nbsp\; $plot " " plot
			set plot [string trim $plot " "]
			set plot [lrange $plot 2 end]
			set plot [htmlcodes $plot]
		}
		if {([regexp \[.\]*Ihre\ Bewertung\[.\]* $line] > 0)} {
			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 "$star"
			set bar "\[\0037"
			for {set i2 0} {$i2 < $goldstars} {incr i2 1} {
				set bar "$bar$marker"
			}
			set marker "$star"
			set bar "$bar\003"
			for {set i3 0} {$i3 < $greystars} {incr i3 1} {
				set bar "$bar$marker"
			}
			set bar "$bar\]"
		}
		if {([regexp \[.\]*L*nge:\[.\]* $line] > 0)} {
			# runtime
			set jj [expr $i + 1]
			set runtime [lindex $lines $jj]
		}
	}
	set business "${url}business"
	set page2 [::http::geturl ${business}]
	set lines2 [split [::http::data $page2] \n]
	set numLines2 [llength $lines2]
	for {set i 0} {$i < $numLines2} {incr i 1} {
		set line [lindex $lines2 $i]
		if {([regexp \[.\]*Budget\[.\]* $line] > 0)} {
			# Budget
			set jj [expr $i + 1]
			set budget [lindex $lines2 $jj]
			regsub -all \<\[^\>\]*\> $budget "" budget
			set budget [string map {€ € £ £ } $budget]
		}
		if {([regexp \[.\]*Opening\[.\]* $line] > 0)} {
			# Screens
			set kk [expr $i + 1] ; set screens "NA"
			set owline [lindex $lines2 $kk]
			regsub -all \<\[^\>\]*\> $owline "" owline
			regsub -all \[\ \t\]+ $owline " " owline
			if {[lsearch $owline "(USA)"] == -1} {break}
			set owline [lrange $owline [lsearch $owline "(USA)"] end]
			set screens [string range [lrange $owline 4 5] 1 end-1]
			break
		}
	}
	if { $disable(IMDBMSG) == 0 } {
		if { $IMDBMSG_STYLE == 0 } {
			set fileid [open "$winpath/.ioFTPD.imdb" w]
			puts $fileid ""
			puts $fileid ""
			puts $fileid "                          I M D B  I N F O                            "
			puts $fileid "+--------------------------------------------------------------------+"
			puts $fileid "   Title....: [format %-55.55s $title] "
			puts $fileid "   Rating...: [format %-55.55s $rating] "
			puts $fileid "   Genre....: [format %-55.55s $genre] "
			puts $fileid "   Director.: [format %-55.55s $name] "
			puts $fileid "   URL......: [format %-55.55s $url] "
			puts $fileid "   Runtime..: [format %-55.55s $runtime] "
			puts $fileid "   Budget...: [format %-55.55s $budget] "
			puts $fileid "   Screens..: [format %-55.55s $screens] "
			puts $fileid "+--------------------------------------------------------------------+"
			close $fileid
		}
		if { $IMDBMSG_STYLE == 1 } {
			set fileid [open "$winpath/.ioFTPD.imdb" w]
			puts $fileid ""
			puts $fileid "  ...::(  The IMDB!  )::...                                            "
			puts $fileid ".-===================================================================-."
			puts $fileid "|                                                                     |"
			puts $fileid "| Title....: [format %-56.56s $title] |"
			puts $fileid "| Rating...: [format %-56.56s $rating] |"
			puts $fileid "| Genre....: [format %-56.56s $genre] |"
			puts $fileid "| Director.: [format %-56.56s $name] |"
			puts $fileid "| URL......: [format %-56.56s $url] |"
			puts $fileid "| Runtime..: [format %-56.56s $runtime] |"
			puts $fileid "| Budget...: [format %-56.56s $budget] |"
			puts $fileid "| Screens..: [format %-56.56s $screens] |"
			puts $fileid "|                                                                     |"
			puts $fileid "`-===================================================================-'"
			close $fileid                                                                       
		}                                                                                       
	}
	if { $disable(IMDBTAG) == 0 } {
		regsub -all {/} $rating { of } rating2
		set year [lindex $title end]
		if { $IMDBTAG == "dir" } {
			regsub -all {/} $genre {} genre2
			file mkdir "$winpath/\[IMDB\] - $genre2 $year - $rating2 - \[IMDB\]"
		}
		if { $IMDBTAG == "file" } {
			regsub -all {/} $genre {} genre2
			set fileid [open "$winpath/\[IMDB\] - $genre2 $year - $rating2 - \[IMDB\]" w]
			close $fileid
		}
	}
	set result "\"$vpath\" \"$url\" \"$title\" \"$name\" \"$genre\" \"$plot\" \"$rating\" \"$bar\" \"$runtime\" \"$budget\" \"$screens\" \"$user\" \"$group\" \"$winpath\""
	return $result
}
Blackthunder is offline   Reply With Quote