rendered paste body##################################################
# tvrage_today.tcl v0.2 by greenbear at gmail.com
#
# Enable with .chanset #channel +tv
#
setudef flag tv
package require http
bind pub - !today pub:tonight:tvrage
bind pub - !tonight pub:tonight:tvrage
proc pub:tonight:tvrage {nick uhost hand chan text} {
######config######################
# time offset
set DIFFERENCE 6
#programs from (in EST)
set START 8
#until (in EST)
set END 10
#######################################
if {![channel get $chan tv]} {return 0}
set data [::http::geturl http://www.tvrage.com/quickschedule.php]
set ignore {"Travel" "TV Land" "History" "MTV" "DSC" "Bravo" "E!" "Nick" "PBS" "TLC" "CMT" "MTV 2"}
set parse 0
foreach line [split [::http::data $data] \n] {
if {[string match -nocase "*DAY*/DAY*" $line]} {
if {$parse} {
foreach shw [lsort -dict [array names tvrage]] {
set raw [join [array get tvrage $shw]]
set t [lindex $raw 0]; set r [lrange $raw 1 end]
putquick "PRIVMSG $chan :\002$t\017 [join $r {, }]."
}
::http::cleanup $data ;return 0
}
regsub -all {\[DAY\]|\[/DAY\]} $line {} line
putquick "PRiVMSG $chan :\002$line\017"
set parse 1; continue
}
if {[string match -nocase "*TIME*/TIME*" $line]} {
regexp -nocase {\[TIME\](.*?).[ap]m} $line . time
continue
}
set hellmeistime ""
set est_time ""
set hr [lindex [split $time :] 0]; set hr [scan $hr %d]
set min [lindex [split $time :] 1]
if {($hr<$START)||($hr>$END)} {continue}
set hellmeisthour [expr ($hr + $DIFFERENCE)]
if {$hellmeisthour > 11} {
set hellmeisthour "0[expr ($hellmeisthour - 12)]"
}
if {$hellmeisthour < 0 } {
set hellmeisthour "0[expr ($hellmeisthour + 24)]"
}
set hr [expr ($hr + 12) ]
if {$hr > 23} {
set hr "0[expr ($hr - 24)]"
}
append est_time $hr ":" $min
append hellmeistime $hellmeisthour ":" $min
regsub -all {\[SHOW\]|\[/SHOW\]} $line {} line
set line [split $line ^]; set ch [lindex $line 0]
set sh [lindex $line 1]; set ep [lindex $line 2]
if {[lsearch -exact [string tolower $ignore] [string tolower $ch]] == -1} {
if {![info exists tvrage($hellmeistime)]} {
set tvrage($hellmeistime) [list "\($est_time\): $sh \00304$ep\017"]
} {
lappend tvrage($hellmeistime) "$sh \00304$ep\017"
}
}
}
}
putlog "hellmeist's fagscript loaded (tvrage)."