Code: Select all
###
# Parse show info from tv.com
# Enable with .chanset #channel +tvi
# [0/1] public or private reply's (public 0, private 1)
set tvreply 0
# offset to EST
# 6 hours makes sense for CET (Europe)
set tvoffset 6
if ![info exists egghttp(version)] {
putlog "egghttp.tcl was NOT successfully loaded."
}
setudef flag tvi
bind pub - !tvinfo pub:info.tv.com
proc pub:info.tv.com {nick uhost hand chan text} {
if ![channel get $chan tvi] return
if {$::tvreply} {set target $nick} {set target $chan}
if {$text==""} {putserv "PRIVMSG $target :Usage: $::lastbind <show>"; return}
set search [join [lrange [split $text] 0 e] {+}]
set d [date:offset [clock seconds] %m%d%y]
set url "http://www.tv.com/search.php?type=11&stype=program&qs=$search&search=Search/"
set sock [egghttp:geturl $url [list findrealurl:tv.com $target] -headers "Cookie: tv_promo_$d=1"]
}
proc findrealurl:tv.com {target sock} {
set data [egghttp:data $sock]
egghttp:cleanup $sock
foreach line [split $data \n] {
if [string match -noc "*returned no results*" $line] {
putserv "PRIVMSG $target :Unknown show."
return
}
if [string match -noc *www.tv.com*show*summary.html* $line] {
regexp -nocase {(http://)[^\"]+} $line url
set d [date:offset [clock seconds] %m%d%y]
set s [egghttp:geturl $url [list parseinfo:tv.com $target $url] -headers "Cookie: tv_promo_$d=1"]
return
}
}
}
proc parseinfo:tv.com {target url sock} {
set data [egghttp:data $sock]
egghttp:cleanup $sock
set data [string map {"\n" "" "</div>" "</div>\n" "<br />" "<br />\n"} $data]
set dV 0
foreach line [split $data \n] {
if [regexp {<title>(.*).TV Show} $line . show] {
putserv "PRIVMSG $target :Show: $show"
}
if [string match -nocase "*Airs:*" $line] {
regsub -all {<(.|\n)*?>} $line {} airs
putserv "PRIVMSG $target :[concat [join $airs]]"
}
if [string match -nocase "*Status:*" $line] {
regsub -all {<(.|\n)*?>} $line {} status
putserv "PRIVMSG $target :[concat [join $status]]"
}
if [string match -nocase "*Premiered*" $line] {
regsub -all {<(.|\n)*?>} $line {} premiered
putserv "PRIVMSG $target :[concat [join $premiered]]"
}
if [string match -nocase "*Show Category:*" $line] {
regsub -all {<(.|\n)*?>} $line {} category
putserv "PRIVMSG $target :[concat [join $category]]"
}
if [string match -nocase "*, 200*" $line] {
regsub -all {<(.|\n)*?>} $line {} Dates
if ![string match -nocase "*Premiered*" $line] {
if {$dV == 0} {
putserv "PRIVMSG $target :Next Air Date: [concat [join $Dates]]"
} else {
putserv "PRIVMSG $target :Last Air Date: [concat [join $Dates]]"
}
incr dV
}
}
}
putserv "PRIVMSG $target :URL: $url"
}
proc date:offset {epox arg} {
set t [expr $epox-((60*60)*$::tvoffset)]
set w [clock format $t -format $arg]
return $w
}
.chanset changed also from +tv >>> +tvi ( coz i allready used +tv in tv.com.tcl v0.2 by greenbear )
Might contain unlogical data , but it works
Code: Select all
<~me> !tvinfo 24
<@MyBot> Show: 24
<@MyBot> Airs: Monday 9:00 PM on FOX (60 mins)
<@MyBot> Status: Returning Series
<@MyBot> Premiered November 6, 2001
<@MyBot> Show Category: Action/Adventure , Drama
<@MyBot> Next Air Date: Sunday January 15, 2006
<@MyBot> Last Air Date: Monday May 23, 2005
<@MyBot> URL: http://www.tv.com/24/show/3866/summary.html?q=24