Searches TVRage.com for show and responds to channel with information.
To use just type !tv than the show name. Or !tv by itself for a list of commands
Please let me know of any issues so i can get them resolved as quickly as possible..
v2.0 - Added where it will show how long till the
next episode airs.
Added !next !last !today !tomorrow.
Added an announcer for whats coming up.
v2.1 - Added Error checking for TVRage Site
v2.2 - Added ability to change Time Offset through
Partyline
v2.3 - Added ability to show show summary for a
specific show or show episode
v2.4 - Added option to turn off time change and
displaying airing to. This speeds up the
output.
Fixed where if there were no shows airing
on selected networks for schedule doesn't
show just the time.
Added commands to partyline. Type .tvhelp
for list of options.
Added option on where to show schedule. Can be
changed through the party line.
v2.5 - Tweaked some of the code. Fixed some minor bugs.
#|---------------------------------------------------------|
#| TVRage Sctipt by Gecko321 - P2P-Network |
#| JeepXJ92@gmail.com |
#|---------------------------------------------------------|
#| Checks TVRage.com for information on shows and on |
#| what is scheduled. |
#|---------------------------------------------------------|
#| Updates: |
#| v2.0 - Added where it will show how long till the |
#| next episode airs. |
#| Added !next !last !today !tomorrow. |
#| Added an announcer for whats coming up. |
#| |
#| v2.1 - Added Error checking for TVRage Site |
#| |
#| v2.2 - Added ability to change Time Offset through |
#| Partyline |
#| |
#| v2.3 - Added ability to show show summary for a |
#| specific show or show episode |
#| |
#| v2.4 - Added option to turn off time change and |
#| displaying airing to. This speeds up the |
#| output. |
#| Fixed where if there were no shows airing |
#| on selected networks for schedule doesn't |
#| show just the time. |
#| Added commands to partyline. Type .tvhelp |
#| for list of options. |
#| Added option on where to show schedule. Can be |
#| changed through the party line. |
#| v2.5 - Tweaked some of the code. Fixed some minor bugs.|
#|---------------------------------------------------------|
#| ---Commands--- |
#|---------------------------------------------------------|
#| Channel Commands: |
#| |
#| !tv <show> |
#| Gets information on <show> |
#| !next <show> |
#| Shows when the <show> is airing next |
#| !last <show> |
#| Show what the <show> was aired last |
#| !today/!tomorrow |
#| Show the schedule for either <today> or |
#| <tomorrow>. |
#| !sum <show> <SseasonXepisode> |
#| Example !sum House (Optional s2x04) |
#| Shows the summary of the specific episode |
#| |
#| Partyline Commands |
#| |
#| .timechange (+/- 0-12) |
#| Changes time offset through the partyline |
#|---------------------------------------------------------|
bind pub - !tv tv:search
bind pub - !today tv:today
bind pub - !tomorrow tv:tomorrow
bind pub - !next tv:next
bind pub - !last tv:last
bind pub - !sum tv:summary
bind dcc - timechange tv:timechange
bind dcc - airing tv:duration
bind dcc - tvhelp tv:help
bind dcc - schedule tv:schedule
#---------------------------------------------------------------------------------------
#Comment or uncomment the following line to turn off the announcement of upcoming shows
#Uncomment if using eggdrop 1.6.19
#bind time - "?0 * * * *" tv:anon
#Uncomment if using eggdrop 1.6.20
bind cron - {*/10 * * * *} tv:anon
#----------------------------------------------------------------------------------------
#Select networks to show
#A&E|ABC|ABC Family|Adult Swim|AMC|Animal Planet|BBC America|Biography Channel|Bounce|Bravo|Cartoon Network|CBS|CineMax|CMT|Comedy Central|Cooking Channel|Destination America|DIRECTV|Discovery Channel|Disney Channel|Disney XD|DIY Network|E!|Food Network|FOX|Fox Business Network|Fuel TV|Fuse|FX|G4|GAC|Golf Channel|H2 TV|HBO|HDNet|HGTV|History Channel|HLN|HUB|ID: Investigation Discovery|IFC|Investigation Discovery|Lifetime|Logo|Military Channel|MTV|MTV2|National Geographic Channel|National Geographic Wild|NBC|NBC Sports Network|Nick @ Nite|Nickelodeon|NickToons|Ovation TV|OWN|Oxygen|Pay-Per-View|PBS|Playboy TV|ReelzChannel|Science Channel|Showtime|Smithsonian Channel|Speed Channel|Spike TV|Style|Sundance|Syfy|Syndicated|TBS|TeenNick|The CW|The Golf Channel|TLC|TNT|Travel Channel|truTV|TV Guide Channel|TV Land|TV One|USA|Velocity|VH1|WE|Weather Channel
set networks "A&E|ABC|ABC Family|Adult Swim|AMC|Animal Planet|BBC America|Biography Channel|Bounce|Bravo|Cartoon Network|CBS|CineMax|CMT|Comedy Central|Cooking Channel|Destination America|DIRECTV|Discovery Channel|Disney Channel|Disney XD|DIY Network|E!|Food Network|FOX|Fox Business Network|Fuel TV|Fuse|FX|G4|GAC|Golf Channel|H2 TV|HBO|HDNet|HGTV|History Channel|HLN|HUB|ID: Investigation Discovery|IFC|Investigation Discovery|Lifetime|Logo|Military Channel|MTV|MTV2|National Geographic Channel|National Geographic Wild|NBC|NBC Sports Network|Nick @ Nite|Nickelodeon|NickToons|Ovation TV|OWN|Oxygen|Pay-Per-View|PBS|Playboy TV|ReelzChannel|Science Channel|Showtime|Smithsonian Channel|Speed Channel|Spike TV|Style|Sundance|Syfy|Syndicated|TBS|TeenNick|The CW|The Golf Channel|TLC|TNT|Travel Channel|truTV|TV Guide Channel|TV Land|TV One|USA|Velocity|VH1|WE|Weather Channel"
#Time offset, all of the times are reported in Us times, if
#you want to convert it to local time. Set the offset here
#set to 0 not to convert. otherwise use -hours or +hours
#0 is for EST
set time_offset "0"
#sets location for schedule display.
# chan displays it in a channel
# nick diplays it in a PM
set location "chan"
#Change to (on/off) to turn on to show time airing till.
set tv_time "on"
#select channel to show Upcoming in
set chan "#Chan"
#------------------------
#Do not edit below here!!
#------------------------
set site "http://services.tvrage.com/tools"
set site2 "http://www.tvrage.com/"
catch {unset tv}
global tv
proc tv:search {nick host hand chan arg} {
global time_offset tv_time site site2 tv
if {$arg == ""} {
tv:send $chan "Commands for TVRage Bot."
tv:send $chan "-!tv <show>"
tv:send $chan "-!last/!next <show>"
tv:send $chan "-!today/!tomorrow"
tv:send $chan "-!sum <show> (seasonXepisode)"
} else {
set arg [string map { " " "%20" } $arg]
set url "$site/quickinfo.php?show=$arg"
set page [tv:web2data $url]
if {$page == "timeout" || $page == ""} { tv:send $chan "TVRage has timed out. Please try again later."
} elseif {$page == 0} { tv:send $chan "TVRage services are currently down"
} else { tv:info $page
if {![info exists tv(show)]} { tv:send $chan "No Such Show!"
} else {
if {$time_offset != 0} { set tv(airtime) [tv:time $tv(lepd) $tv(time)] }
tv:send $chan "$tv(show) -- $tv(airtime) $tv(network) (Runtime: $tv(runtime) minutes) ($tv(status)) ($tv(genre))"
tv:send $chan "Episode URL: $site2$tv(url)"
tv:send $chan "Last Episode: $tv(lepd) $tv(lep) $tv(lept)"
if { [info exists tv(rfc)] } {
if {$tv_time == "on"} { set airing "(Airing in [duration [expr {[chng_time [clock scan "$tv(nepd) $tv(time)" -format {%b/%d/%Y %I:%M %p}]] - [unixtime]}]])"
} else { set airing "" }
tv:send $chan "Next Episode: $tv(nepd) $tv(nep) $tv(nept) $airing"
}
}
}
}
unset tv
}
proc tv:anon {minute hour day month weekday} {
global chan networks time_offset site
set url "$site/quickschedule.php"
set page [tv:web2data $url]
if {$page != 0 || $page != ""} {
regexp {(\[DAY\].*?)\[DAY\]} $page gotday show_day
if {[info exists show_day]} {
regexp {\[DAY\](.*?)\[/DAY\]} $show_day gotday show_date
set show_day "$show_day\[TIME\]"
while {[regexp {\[TIME\](.*?)\[\/TIME\]} $show_day gottime time]} {
regexp {(\[TIME\].*?)\[TIME\]} $show_day gottime shows
if {[info exists shows]} {
set show_date_time [chng_time [clock scan "$show_date $time"]]
regexp {[0-9]+\:([0-9]+).*?([A-Za-z]+)} $time m min hr
if { $hr == "am"} { set show_date_time [expr {$show_date_time + 86400}] }
set time_till [expr {$show_date_time - [unixtime]}]
regsub {(\[TIME\].*?\[/TIME\])} $show_day "" show_day
if {$time_till < 600 && $time_till > 0} {
foreach line [split $shows "\n"] {
if {[regexp {\[SHOW\](.*?)\[/SHOW\]} $line gotshow show]} { regexp {(.*?)\^(.*?)\^(.*?)\^} $show t network show episode
if {[info exists network]} { if {[regexp $network $networks]} { append new_shows "-($network) $show - $episode \n" } ; unset network show episode } }
}
if {[info exists new_shows]} {
if {$time_offset != 0} { set time [strftime {%I:%M %p} [chng_time [clock scan $time]]]}
tv:send $chan "The following shows are airing in [duration $time_till]" ; foreach line [split $new_shows "\n"] { if {$line != ""} { tv:send $chan "$line" }}
unset new_shows
}
if {$min == "00" || $min == "30"} { break }
}
}
}
}
}
}
proc tv:tomorrow {nick host hand chan arg} {
global networks time_offset location site
set url "$site/quickschedule.php"
set page [tv:web2data $url]
if {$page == "timeout"} { tv:send $chan "TVRage has timed out. Please try again in a few minutes"
} elseif {$page == 0 || $page == ""} { tv:send $chan "TVRage services are currently down"
} else {
regsub {(\[DAY\].*?\[/DAY\])} $page "" page
regexp {(\[DAY\].*?)\[DAY\]} $page gotday show_day
regexp {\[DAY\](.*?)\[/DAY\]} $show_day gotday show_date
set show_day "$show_day\[TIME\]"
tv:send [set $location] "Shows airing tomorrow $show_date:"
while {[regexp {\[TIME\](.*?)\[\/TIME\]} $show_day gottime show_time]} {
if {[info exists show_time]} {
regexp {\[TIME\](.*?)\[/TIME\]} $show_day gottime time
regexp {(\[TIME\].*?\[TIME\])} $show_day gottime shows
regsub {(\[TIME\].*?\[TIME\])} $show_day "\[TIME\]" show_day
foreach line [split $shows "\n"] {
if {[regexp {\[SHOW\](.*?)\[/SHOW\]} $line gotshow show]} {
regexp {([A-Za-z 0-9@\:]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([0-9x]+)\^} $show t network show episode
if {[info exists network] && [regexp $network $networks]} { append new_shows "--($network) $show - $episode \n" ; unset network show episode }
}
}
if {[info exists new_shows]} {
if {$time_offset != 0} { set time [strftime {%I:%M %p} [chng_time [clock scan $time]]]}
tv:send [set $location] "-$time" ; foreach line [split $new_shows "\n"] { if {$line != ""} { tv:send [set $location] "$line" }}
unset new_shows
}
}
}
}
}
proc tv:today {nick host hand chan arg} {
global networks time_offset location site
set url "$site/quickschedule.php"
set page [tv:web2data $url]
if {$page == "timeout"} { tv:send [set $location] "TVRage has timed out. Please try again in a few minutes"
} elseif {$page == 0 || $page == ""} { tv:send [set $location] "TVRage services are currently down"
} else {
regexp {(\[DAY\].*?)\[DAY\]} $page gotday show_day
regexp {\[DAY\](.*?)\[/DAY\]} $show_day gotday show_date
set show_day "$show_day\[TIME\]"
tv:send [set $location] "hows airing today $show_date:"
while {[regexp {\[TIME\](.*?)\[\/TIME\]} $show_day gottime show_time]} {
if {[info exists show_time]} {
regexp {\[TIME\](.*?)\[/TIME\]} $show_day gottime time
regexp {(\[TIME\].*?\[TIME\])} $show_day gottime shows
regsub {(\[TIME\].*?\[TIME\])} $show_day "\[TIME\]" show_day
foreach line [split $shows "\n"] {
if {[regexp {\[SHOW\](.*?)\[/SHOW\]} $line gotshow show]} {
regexp {([A-Za-z 0-9@\:]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([0-9x]+)\^} $show t network show episode
if {[info exists network] && [regexp $network $networks]} { append new_shows "--($network) $show - $episode \n" ; unset network show episode }
}
}
if {[info exists new_shows]} {
if {$time_offset != 0} { set time [strftime {%I:%M %p} [chng_time [clock scan $time]]]}
tv:send [set $location] "-$time" ; foreach line [split $new_shows "\n"] { if {$line != ""} { tv:send [set $location] "$line" }}
unset new_shows
}
}
}
}
}
proc tv:next {nick host hand chan arg} {
global time_offset tv_time site tv
set arg [string map { " " "%20" } $arg]
set url "$site/quickinfo.php?show=$arg"
set page [tv:web2data $url]
if {$page == "timeout" || $page == ""} { tv:send $chan "TVRage has timed out. Please try again in a few minutes"
} elseif {$page == 0} { tv:send $chan "TVRage services are currently down"
} else { tv:info $page
if {$time_offset != 0} { set tv(airtime) [tv:time $tv(nepd) $tv(time)] }
if {[info exists tv(rfc)]} {
if {$tv_time == "on"} { set sec [clock seconds]
set airing "- [duration [expr {[chng_time [clock scan "$tv(nepd) $tv(time)" -format {%b/%d/%Y %I:%M %p}]] - $sec}]] from now"
} else { set airing "" }
tv:send $chan "$tv(show) - $tv(nep) $tv(nept) - Airs: $tv(nepd) - $tv(airtime) on $tv(network) $airing"
} elseif {![info exists tv(show)]} { tv:send $chan "No Such Show!"
} elseif {$tv(status) == "Canceled/Ended" } { tv:send $chan "There will be no more episodes of $tv(show) airing"
} else { tv:send $chan "The next episode of $tv(show) is not yet scheduled." }
}
unset tv
}
proc tv:last {nick host hand chan arg} {
global time_offset site tv
set arg [string map { " " "%20" } $arg]
set url "$site/quickinfo.php?show=$arg"
set page [tv:web2data $url]
if {$page == "timeout" || $page == ""} { tv:send $chan "TVRage has timed out. Please try again in a few minutes"
} elseif {$page == 0} { tv:send $chan "TVRage services are currently down"
} else { tv:info $page
if {![info exists tv(show)]} { tv:send $chan "No Such Show!"
} else {
if {$time_offset != 0} { set tv(lepd) [tv:time $tv(lepd) $tv(time)] }
tv:send $chan "$tv(show) - $tv(lep) $tv(lept) - Aired: $tv(lepd) - $tv(airtime) on $tv(network)"
}
}
unset tv
}
proc tv:summary {nick host hand chan arg} {
global site site2 tv
set ep ""
regexp {[Ss]?([1-9]+[XxEe][0-9]+)} $arg => ep
regsub {[Ss]?([1-9]+[XxEe][0-9]+)} $arg "" arg
set arg [string map { " " "%20" } [string trim $arg]]
if {[info exists ep]} { set ep [string map {"e" "x" "s" "" } $ep] ; set url "$site/quickinfo.php?show=$arg&ep=$ep"
} else { set url "$site/quickinfo.php?show=$arg" }
set page [tv:web2data $url]
if {$page == "timeout" || $page == ""} { tv:send $chan "TVRage has timed out. Please try again in a few minutes"
} elseif {$page == 0} { tv:send $chan "TVRage services are currently down"
} else { tv:info $page
if {![info exists tv(show)]} { tv:send $chan "No Such Show!"
} else {
if {[info exists tv(epurl)]} { set page [tv:web2data "$site2$tv(epurl)"]
} else { set page [tv:web2data "$site2$tv(url)"] }
regexp {show_synopsis['|"]>(.*)<\/div>} $page a sum
regsub -all {(<script.*?<\/script>)} $sum "" summary
regsub {<b>Source: <\/b>.*?<br>} $summary "" summary
regsub -all {(<.*?>)} $summary "" summary
set summary [string trim $summary]
if {[string length $summary] > 250} { set summary "[string range $summary 0 250] ..." }
if {[info exists tv(epurl)]} { set tv(url) $tv(epurl) }
if {![info exists summary]} { tv:send $chan "There is no show summary for $tv(show) $ep"
} else { tv:send $chan "Summary of $tv(show) $ep: [string trim $summary] : $site2$tv(url)"}
}
}
unset tv
}
proc tv:web2data {website} {
package require http
if { [catch { set token [http::geturl $website -timeout 500000]} error] } { return 0
} elseif { [http::ncode $token] == "404" } { return 0
} elseif { [http::status $token] == "ok" } { set data [http::data $token]
} elseif { [http::status $token] == "timeout" } { return "timeout"
} elseif { [http::status $token] == "error" } { return 0 }
http::cleanup $token
if { [info exists data] } { return $data
} else { return 0 }
}
proc chng_time {temptime} {
global time_offset
if {[string index $time_offset 0] == "+" || ( [string index $time_offset 0] == "-" )} {
set offset_type [string index $time_offset 0]
set offset [string range $time_offset 1 end]
if {[string is integer -strict $offset] && $offset != 0} { set temptime [expr $temptime $offset_type [expr $offset * 3600]]}
}
return $temptime
}
proc tv:timechange {hand idx arg} {
global time_offset
if {$arg == 0} { set time_offset $arg ; putdcc $idx "Time offset changed to: $arg for TVRage"
} elseif {[string index $arg 0] == "+" || ( [string index $arg 0] == "-" )} {
set offset [string range $arg 1 end]
if {[string is integer -strict $offset] && $offset != 0} { set time_offset $arg ; putdcc $idx "Time offset changed to: $arg for TVRage" }
}
}
proc tv:help {hand idx arg} {
putdcc $idx "Commands for TVRage Bot"
putdcc $idx "Channel Commands"
putdcc $idx "!tv <show>"
putdcc $idx "!next/!last <show>"
putdcc $idx "!today/!tomorrow"
putdcc $idx "!sum <show> (seasonXepisode)"
putdcc $idx "Partyline Commands"
putdcc $idx ".timechange (+/- 0-12) (Changes time offset)"
putdcc $idx ".airing (Changes the showing of Airing in)"
putdcc $idx ".schedule (Adjusts the schedule location)"
}
proc tv:time {date time } { return [strftime {%A at %I:%M %p} [chng_time [clock scan "$date $time" -format {%b/%d/%Y %I:%M %p}]]] }
proc tv:duration {hand idx arg} {
global tv_time
if {$tv_time == "on"} { set tv_time "off"
} else { set tv_time "on" }
putdcc $idx "Airing in has been turned: $tv_time"
}
proc tv:schedule {hand idx arg} {
global location
if {$location == "chan"} { set location "nick"
} else { set location "chan" }
putdcc $idx "Schedule will now be sent to: $location"
}
proc tv:send { where text} { putserv "PRIVMSG $where :$text" }
proc tv:info {page} {
global tv site2
regexp -line "Episode URL@$site2\(.*\)" $page -> tv(epurl)
regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page => tv(show)
regexp -line "Show URL@$site2\(.*\)" $page -> tv(url)
regexp {Latest Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([A-Za-z0-9/]+)} $page -> tv(lep) tv(lept) tv(lepd)
regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page -> tv(nep) tv(nept) tv(nepd)
regexp {Episode Info@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page -> tv(ep) tv(ept) tv(epd)
regexp {Status@([A-Za-z/ ]+)} $page -> tv(status)
regexp {Network@([A-Za-z 0-9\!@\:]+)} $page -> tv(network)
regexp {Airtime@([A-Za-z, 0-9:]+)} $page -> tv(airtime)
regexp {Runtime@([0-9]+)} $page -> tv(runtime)
regexp {[0-9]+\:([0-9]+).*?([A-Za-z]+)} $tv(airtime) tv(time)
regexp {RFC3339@([A-Za-z 0-9-]+[0-9:]+)} $page -> tv(rfc)
regexp -line {Genres@(.*)} $page -> tv(genre)
}
putlog "TVRage v2.5"
When using the !next(or any command that has -format in it, like !last or !tv(when searching for shows)) command I get:
Tcl error [tv:next]: bad switch "-format": must be -base or -gmt
and when I change '-format- to 'base' or -'gmt- I get:
Tcl error [tv:next]: expected integer but got "%b/%d/%Y %I:%M %p"
I'm not sure if this is some error on my side of with the script. Help would be MUCH appreciated! Thanks for the amazing tvrage script :D
could create a function to do the repetitive code of:
...
if {$page == "timeout" || $page == ""} { tv:send $chan "TVRage has timed out. Please try again in a few minutes"
} elseif {$page == 0} { tv:send $chan "TVRage services are currently down"
} else { tv:info $page
if {![info exists tv(show)]} { tv:send $chan "No Such Show!"
} else {
...