there's a script like this called tvshow.tcl written by Ryal
it gets the data from episodeworld.com
Code: Select all
#####################
# EPisodeWorld 1.4 #
#####################
# Enable with .chanset #channel +epw
# Set your chan name here
set mychan "#szabadka"
# e.g. set tgcmdhelp "helpme" will make the bot give help when someone
# does "/msg <botnick> helpme"
set epwcmdhelp "!ephelp"
# [0/1] public or private reply's (public 0, private 1)
set epinforeply 0
set whatsonreply 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."
}
set whatsontime 1
set whatsontimer [timer $whatsontime whatson]
setudef flag epw
bind pub - $epwcmdhelp epwgivehelp
bind join -|- "$mychan *" epwjoinmsg
bind pub - !epinfo epinfo
#bind pub - !tomorrow whatsontomorrowdisplay
#bind pub - !today whatsontodaydisplay
#bind pub - !yesterday whatsonyesterdaydisplay
#bind pub - !whatson whatsondisplay
proc epinfo {nick uhost hand chan text} {
if ![channel get $chan epw] return
if {$::epinforeply} {set target $nick} {set target $chan}
if {$text==""} {putserv "PRIVMSG $chan :\002Usage: $::lastbind <show> -l <language>"; return}
set sep "-l"
set data [split [string map [list $sep \0] $text] \0]
set text [string trim [lindex $data 0]]
if {[llength $data] >1} {
set language [string trim [lindex $data 1]]
} else {
set language "english"
}
set search [join [lrange [split $text] 0 e] {+}]
set language [join [lrange [split $language] 0 e] {+}]
set d [date:offset [clock seconds] %m%d%y]
set url "http://episodeworld.com/botsearch/$search/$language"
set sock [egghttp:geturl $url [list parseinfo.episodeworld.com $target $url] -headers "Cookie: tv_promo_$d=1"]
}
proc parseinfo.episodeworld.com {target url sock} {
set data [egghttp:data $sock]
egghttp:cleanup $sock
set i 0
if {$data==""} {
putserv "PRIVMSG $target :\002Unknown Show, check the spelling"
} else {
foreach line [split $data \n] {
incr i
if {$i==1} {
if [regexp {(.*)<br>} $line . titletemp] {
set title $titletemp
}
}
if {$i==2} {
if [regexp {Previous: (.*) Name} $line . number_prevtemp] {
set number_prev $number_prevtemp
}
if [regexp {Name: (.*) Date} $line . name_prevtemp] {
set name_prev $name_prevtemp
}
if [regexp {Date: (.*)<br>} $line . date_prevtemp] {
set date_prev $date_prevtemp
}
}
if {$i==3} {
if [string match -nocase "*Next: Name: Date: <br>*" $line] {
set date "No Info Available"
} else {
if [regexp {Next: (.*) Name} $line . numbertemp] {
set number $numbertemp
}
if [regexp {Name: (.*) Date} $line . nametemp] {
set name $nametemp
}
if [regexp {Date: (.*)<br>} $line . datetemp] {
set date $datetemp
}
}
}
if {$i==4} {
if [regexp {(.*)<br>} $line . urltemp] {
set url $urltemp
}
}
}
if {$i==4} {
if {$date== "No Info Available"} {
putquick "PRIVMSG $target :(Show: \00304$title\00300)-(\00304No Info Available\00300)-(Previous: \00304$number_prev\00300-\00304$name_prev\00300 - aired the \00304$date_prev\00300)"
} else {
if {$date== "0000-00-00"} {
putquick "PRIVMSG $target :(Show: \00304$title\00300)-(Next: \00304$number\00300-\00304$name\00300 - \00304Airing date unknown\00300)-(Previous: \00304$number_prev\00300-\00304$name_prev\00300 - aired the \00304$date_prev\00300)"
} else {
putquick "PRIVMSG $target :(Show: \00304$title\00300)-(Next: \00304$number\00300-\00304$name\00300 - airs the \00304$date\00300)-(Previous: \00304$number_prev\00300-\00304$name_prev\00300 - aired the \00304$date_prev\00300)"
}
}
putquick "PRIVMSG $target :For more info: \00304$url"
}
}
}
proc whatson {} {
global mychan whatsontime whatsontimer
global first
if ![channel get $mychan epw] return
set d [date:offset [clock seconds] %m%d%y]
set langs(1) "english"
set langs(2) "german"
set langs(3) "french"
set langs(4) "spanish"
set langs(5) "italian"
set langs(6) "polish"
set langs(7) "japanese"
set langs(8) "portuguese"
set langs(9) "finnish"
for {set j 1} {$j<10} {incr j 1} {
set url "http://www.episodeworld.com/rss/rss-all.php?l=$j"
set language $langs($j)
set sock [egghttp:geturl $url [list parseinfo.home.episodeworld.com $url $language] -headers "Cookie: tv_promo_$d=1"]
}
if {[timerexists whatson]!=""} {killtimer $whatsontimer}
if {[info exists first]} {
set whatsontime 240
putlog "Next parsing scheduled in 240'"
} else {
set whatsontime 1
putlog "Parsing failed, next try in 1'"
}
set whatsontimer [timer $whatsontime whatson]
}
proc parseinfo.home.episodeworld.com {url language sock} {
global nb show number epname
global first
set today [clock format [clock sec] -format %Y-%m-%d]
set data [egghttp:data $sock]
egghttp:cleanup $sock
putlog "Parsing www.episodeworld.com"
if {[info exists nb("$today","$language")]} {
unset nb("$today","$language")
}
if {[info exists first]} {
# unset first
}
foreach day [array names goon] {
set goon($day) 0
}
set first 0
foreach line [split $data \n] {
if {[regexp {<description>(.*) - } $line . showtemp]} {
if {[regexp {Broadcast: (.*)<BR><BR><BR>} $line . datetemp]} {
set day $datetemp
if {![info exists nb("$day","$language")]} {
set goon("$day") 1
set nb("$day","$language") 0
}
if {$goon("$day")==1} {
incr nb("$day","$language")
if {[regexp { - (.*) - } $line . numbertemp]} {
set number("$day","$language",$nb("$day","$language")) $numbertemp
} else {
set number("$day","$language",$nb("$day","$language")) ""
}
if {[regexp { - (.*)<BR><BR>} $line . nametemp]} {
set sep " *"
set epnamedata [lindex [split [string map [list $sep \0] $nametemp] \0] 0]
set sep " - "
set epnamedata2 [split [string map [list $sep \0] $epnamedata] \0]
set epname("$day","$language",$nb("$day","$language")) [lindex $epnamedata2 [expr [llength $epnamedata2] -1]]
} else {
set epname("$day","$language",$nb("$day","$language")) ""
}
set sep " - "
set show("$day","$language",$nb("$day","$language")) [lindex [split [string map [list $sep \0] $showtemp] \0] 0]
}
}
}
}
}
proc whatsondisplay {nick uhost hand chan text} {
global first
global compt
global nb show number epname
if {[info exists first]} {
if {$::whatsonreply} {set target $nick} {set target $chan}
if {$text==""} {putserv "PRIVMSG $chan :\002Usage: $::lastbind <day> -l <language>"; return}
set sep "-l"
set data [split [string map [list $sep \0] $text] \0]
set text [string trim [lindex $data 0]]
if {[llength $data] >1} {
set language [string trim [lindex $data 1]]
} else {
set language "english"
}
set day [join [lrange [split $text] 0 e] {+}]
set language [join [lrange [split $language] 0 e] {+}]
if {$day=="today"} { set day [clock format [clock sec] -format %Y-%m-%d] }
if {$day=="yesterday"} { set day [clock format [expr [clock sec] - 86400] -format %Y-%m-%d] }
putserv "PRIVMSG $target :**************************************"
putserv "PRIVMSG $target :Airing Date - Show Name - Episode Name"
putserv "PRIVMSG $target :**************$day**************"
set compt($nick) 0
if {[info exists nb("$day","$language")]} {
if {$nb("$day","$language")>0} {
whatsondisplay2 $nick $target $day $language
}
} else {
putserv "PRIVMSG $target :**************************************"
}
} else {
if {$::whatsonreply} {set target $nick} {set target $chan}
putserv "PRIVMSG $target :Please $nick, wait for the bot to actually parse something."
}
}
proc whatsondisplay2 {name target day language} {
global compt nb show number epname
# putserv "PRIVMSG $target :$nb("$day","$language") $compt($name)"
if {[expr $compt($name)+4] < $nb("$day","$language")} {
for {set k 1} {$k<5} {incr k 1} {
incr compt($name)
putserv "PRIVMSG $target :\00304$day \00301- \00302$show("$day","$language",$compt($name)) \00301- $number("$day","$language",$compt($name)) - \00303$epname("$day","$language",$compt($name))"
}
} else {
set tempcompt $compt($name)
for {set k 1} {$k< [expr $nb("$day","$language") - $tempcompt+1]} {incr k 1} {
incr compt($name)
putserv "PRIVMSG $target :\00304$day \00301- \00302$show("$day","$language",$compt($name)) \00301- $number("$day","$language",$compt($name)) - \00303$epname("$day","$language",$compt($name))"
}
}
if {$compt($name) < $nb("$day","$language")} {
if {[utimerexists whatsondisplay2]!=""} {killutimer $whatsontimer2}
set whatsontime2 5
set whatsontimer2 [utimer $whatsontime2 "whatsondisplay2 $name $target $day $language"]]
} else {
putserv "PRIVMSG $target :**************************************"
}
}
proc date:offset {epox arg} {
set t [expr $epox-((60*60)*$::tvoffset)]
set w [clock format $t -format $arg]
return $w
}
proc epwjoinmsg {nick host hand chan} {
global botnick epwcmdhelp
if {$nick != $botnick} {
putnotc $nick "Type !epinfo <show> -l <language> to get airing info, !whatson <day> -l <language> to get whats on tv, $epwcmdhelp if you need help. Enjoy your stay! :-)"
}
}
proc epwgivehelp {nick uhost hand chan text} {
putnotc $nick "You have access to the following commands: !epinfo <show> -l <language>, !whatson <day> -l <language>"
putnotc $nick "If you have any suggestion or want to report a bug just use the www.episodeworld.com forums or send a mail to h124186@hotmail.com"
}
putlog "*********************************************************"
putlog "* script made by ryal *"
putlog "* episodeworld.com.tcl v1.4 successfully loaded *"
putlog "* Thanks goes to wuff whose tv site is really the best. *"
putlog "* Go check it out: www.episodeworld.com *"
putlog "*********************************************************"