#################### # tvrage.tcl # # v0.1 19Jan06 # # Coded By: GaveUp # #################### ################### # DESCRIPTION # ################################################################################# # This script pulls today's or tomorrow's schedule of new shows from tvrage.com # ################################################################################# #################### # Revision History # ########################## # 0.1 -- Initial Release # ########################## ######## # TODO # ################################################# # *Move hardcoded settings to variables. # # *Add support for changing timezones. # # *Add support for upto 5 days into the future. # ################################################# bind pub - !today pub:tvrage.com.today bind pub - !tomorrow pub:tvrage.com.tomorrow package require http setudef flag tv proc pub:tvrage.com.today {nick uhost hand chan text} { parse:tvrage.com $nick $uhost $hand $chan $text "0" } proc pub:tvrage.com.tomorrow {nick uhost hand chan text} { parse:tvrage.com $nick $uhost $hand $chan $text "1" } proc parse:tvrage.com {nick uhost hand chan text when} { if ![channel get $chan tv] return set token [http::geturl http://www.tvrage.com/quickschedule.php] set data [http::data $token] http::cleanup $token set date "" set systemTime [clock seconds] set systemTime [expr $systemTime + 3600] set currentTime "" set parsing 0 set currentOutput "" set gotTime 0 set neededDate "" if {$when == 0} { set neededDate [clock format $systemTime -format "%A, %d %b %Y"] } elseif {$when == 1} { set systemTime [expr "$systemTime + 86400"] set neededDate [clock format $systemTime -format "%A, %d %b %Y"] } foreach line [split $data \n] { if {[regexp {^\[DAY\]([\w\, ]+)\[\/DAY\]$} $line -> date]} { #putlog "THIS IS THE [censored] DATE: $date" if {$parsing == 1} { break; } if {$date == $neededDate} { putserv "PRIVMSG $chan :\00303New TV Shows for $date ***All Times in EST/EDT***\00315" set parsing 1 } } if {$parsing} { if {[regexp {^\[TIME\]([\w\: ]+)\[\/TIME\]$} $line -> currentTime]} { if {$gotTime} { set currentOutput [string trim $currentOutput <>] putserv "PRIVMSG $chan :$currentOutput" } set currentOutput "\002$currentTime:\002 " set gotTime 1 } if {[regexp {^\[SHOW\]([ \w]+)\^([\w \']+)\^([\dx]+)\^([\w\\\/\:\.]+)\[\/SHOW\]$} $line -> network title epnum url]} { set currentOutput [concat $currentOutput "\00304$network\00315 - \00314$title $epnum\00315 <>"] } } } } putlog "TVRage.com Primetime Schedule v0.1"