egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

dlx's tvrage LOOKUP SCRIPT (v2.3fix)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Znuff
Voice


Joined: 17 May 2010
Posts: 9

PostPosted: Mon May 17, 2010 1:53 am    Post subject: dlx's tvrage LOOKUP SCRIPT (v2.3fix) Reply with quote

Hi,

Code is not mine, but dlx's. Just changed the api url and added a timeout value so the bot doesn't crash anymore if the service is unresponsive.

Wished I could write better error handling, but this will do, I guess Smile

Code:
###########################################################
# tvrage LOOKUP SCRIPT (dlx @ linknet)                    #
###########################################################
# v2.3fix - changed API url                               #
#         - added timeout after 5 seconds (stops crashing #
#           if tvrage.com is slow                         #
#         - modified by znuff on 17/05/2010               #
###########################################################
# v2.3 - changed the way !today and                       #
#        !tomorrow reply for less spam                    #
###########################################################
# v2.2 - added tvrage(inline) support                     #
#        for iPoRn                                        #
###########################################################
# v2.1 - added time output to !tonight                    #
#         and !tomorrow for nogruk                        #
###########################################################
# v2.0 - new commands !next/!last/                        #
#                !tonight/!tomorrow                       #
###########################################################

bind pub - .tv dlx:tvrage:tv
bind pub - .tvnext dlx:tvrage:next
bind pub - .tvlast dlx:tvrage:last
#bind pub - .tvtonight dlx:tvrage:tonight
#bind pub - .tvtomorrow dlx:tvrage:tomorrow

# Channels not to be displayed on !tonight/!tomorrow
set tvrage(excluded_Channels) [list "Nickelodeon" "Disney Channel" "Style" "VH1" "HGTV" "PBS" "Cooking Channel" "Food Network" "TLC" "Discovery Channel" "Spike TV" "E!" "A&E" "Cartoon Network" "Animal Planet"]

# timeout value - in miliseconds
set tvrage(timeout) "5000"

# Show the Time of the show?
set tvrage(show_time) "TRUE"

# Show the Episode number of the show?
set tvrage(show_episode) "TRUE"

# Display !tonight and !tomorrow in one line?
# TRUE will squeeze all shows into one line
# FALSE will split them up by channel (DEFAULT)
set tvrage(inline) "FALSE"

proc dlx:tvrage:tv { nick host hand chan arg } {
    global tvrage
    package require http
    set prefix "\002\0037TV ->\003\002 "
 
    set arg [string map { " " "%20" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $tvrage(timeout)]]

    regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page gotname show_name
    regexp {Show URL@http://www.tvrage.com/([A-Za-z_0-9/-]+)} $page goturl show_url
    regexp {Premiered@([0-9]+)} $page gotpremiere show_premiered
    regexp {Latest Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([A-Za-z0-9/]+)} $page gotlatest latest_ep latest_ep_title latest_ep_date
    set gotnext [regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page gotnext next_ep next_ep_title next_ep_date]
    regexp {Country@([A-Za-z]+)} $page gotcountry show_country
    regexp {Status@([A-Za-z/ ]+)} $page gotstatus show_status
    regexp {Classification@([A-Za-z ]+)} $page gotclassification show_classification
    set gotgenres [regexp {Genres@([A-Za-z |]+)} $page gotgenres show_genres]
    regexp {Network@([A-Za-z 0-9]+)} $page gotnetwork show_network
    regexp {Airtime@([A-Za-z, 0-9:]+)} $page gotairtime show_airtime

    if { ![info exists show_name] } {
       putquick "PRIVMSG $chan :$prefix Error! (timeout or something similar)"
       return -1
    }

    set show_url "http://www.tvrage.com/$show_url"
    if { $gotgenres == 0 } { set show_genres "N/A" }
    if { $gotnext == 0 } {
            set next_ep "00x00"
            set next_ep_title "-N/A-"
            set next_ep_date "not available"
    }
   putquick "PRIVMSG $chan :$prefix Show: $show_name ($show_classification \| $show_genres)"
   putquick "PRIVMSG $chan :$prefix Premiered: $show_premiered"
   putquick "PRIVMSG $chan :$prefix Status: $show_status"
   putquick "PRIVMSG $chan :$prefix Network: $show_network"
   putquick "PRIVMSG $chan :$prefix URL: $show_url"
}

proc dlx:tvrage:next { nick host hand chan arg } {
    global tvrage
    package require http
    set prefix "\002\0037TV ->\003\002 "
    set arg [string map { " " "_" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $tvrage(timeout)]]
 
    regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page gotname show_name
    set gotnext [regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page gotnext next_ep next_ep_title next_ep_date]
    regexp {Airtime@([A-Za-z, 0-9:]+)} $page gotairtime show_airtime
   
    if { ![info exists show_name] } {
       putquick "PRIVMSG $chan :$prefix Error! (timeout or something similar)"
       return -1
    }

    if { $gotnext == 0 } {
      putquick "PRIVMSG $chan :$prefix The next episode of \002$show_name\002 is not yet scheduled. That makes me a sad panda :("
    } else {
   putquick "PRIVMSG $chan :$prefix The next episode of \002$show_name\002 is \002$next_ep_title \[$next_ep\]\002, it will air on \002$show_airtime\002 \002$next_ep_date\002"
   }
}
 
proc dlx:tvrage:last { nick host hand chan arg } {
    global tvrage
    package require http
    set prefix "\002\0037TV ->\003\002 "
    set arg [string map { " " "_" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $tvrage(timeout)]]
 
    regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page gotname show_name
    regexp {Latest Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([A-Za-z0-9/]+)} $page gotlatest latest_ep latest_ep_title latest_ep_date
    set gotnext [regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page gotnext next_ep next_ep_title next_ep_date]

    if { ![info exists show_name] } {
       putquick "PRIVMSG $chan :$prefix Error! (timeout or something similar)"
       return -1
    }
   
   putquick "PRIVMSG $chan :$prefix The last episode of \002$show_name\002 is \002$latest_ep_title $latest_ep\ \002 it aired on \002$latest_ep_date\002"
}

proc dlx:tvrage:tonight { nick host hand chan arg } {
   global tvrage
   if { [info exists chans] } { unset chans }
   package require http
   set prefix "\002\0037TV ->\003\002 "
   set schedule [http::data [http::geturl "http://www.tvrage.com/quickschedule.php" -timeout $tvrage(timeout)]]

   set end [string first "\n\n" $schedule]
   set today [string range $schedule 0 $end]

   putquick "PRIVMSG $chan :$prefix TV Schedule for Today:"

   set showList "$prefix "

   foreach line [split $today "\n"] {
      set found_time [regexp {\[TIME\](.*)\[\/TIME\]} $line found_time time]
      set found_show [regexp {\[SHOW\](.*)\^(.*)\^(.*)\^(.*)\[\/SHOW\]} $line found_show show_channel show_name show_ep show_url]
      if { $found_show && [lsearch -exact $tvrage(excluded_Channels) $show_channel] == -1 } {
         if { $tvrage(inline) } {
            append showList "$show_name ($show_ep) - "
         } else {
            if {$tvrage(show_time)} { append chans($show_channel) "\037$time\037 " }
            append chans($show_channel) "\002$show_name\002 "
            if {$tvrage(show_episode)} { append chans($show_channel) "($show_ep) " }
         }
      }
   }
   if { $tvrage(inline) } {
      set showList [string range $showList 0 [expr [string length $showList] - 3]]
      putquick "PRIVMSG $chan :$showList"
   } else {
      set chanlist [array names chans]
      foreach x $chanlist {
         putquick "PRIVMSG $chan :$x\: $chans($x)"
      }
   }
}

proc dlx:tvrage:tomorrow { nick host hand chan arg } {
   global tvrage
   if { [info exists chans] } { unset chans }
   package require http
   set prefix "\002\0037TV ->\003\002 "
   set schedule [http::data [http::geturl "http://www.tvrage.com/quickschedule.php" -timeout $tvrage(timeout)]]

   set start [string first "\n\n" $schedule]
   set schedule [string range $schedule [expr $start+3] end]

   set end [string first "\n\n" $schedule]
   set tomorrow [string range $schedule 0 $end]

   putquick "PRIVMSG $chan :$prefix TV Schedule for Tomorrow:"

   set showList "$prefix "

   foreach line [split $tomorrow "\n"] {
      set found_time [regexp {\[TIME\](.*)\[\/TIME\]} $line found_time time]
      set found_show [regexp {\[SHOW\](.*)\^(.*)\^(.*)\^(.*)\[\/SHOW\]} $line found_show show_channel show_name show_ep show_url]
      if { $found_show && [lsearch -exact $tvrage(excluded_Channels) $show_channel] == -1 } {
         if { $tvrage(inline) == "TRUE" } {
            append showList "$show_name ($show_ep) - "
         } else {
            if {$tvrage(show_time)} { append chans($show_channel) "\037$time\037 " }
            append chans($show_channel) "\002$show_name\002 "
            if {$tvrage(show_episode)} { append chans($show_channel) "($show_ep) " }
         }
      }
   }
   if { $tvrage(inline) == "TRUE" } {
      set showList [string range $showList 0 [expr [string length $showList] - 3]]
      putquick "PRIVMSG $chan :$showList"
   } else {
      set chanlist [array names chans]
      foreach x $chanlist {
         putquick "PRiVmsg $chan :$x\: $chans($x)"
      }
   }
}

putlog "dlx-tvrage_v2.3f.tcl loaded. enjoy!"

Back to top
View user's profile Send private message
Znuff
Voice


Joined: 17 May 2010
Posts: 9

PostPosted: Mon May 17, 2010 4:26 am    Post subject: Reply with quote

if the above code doesn't really work for you (it worked for me, but not for a friend...), try this one:


Code:
###########################################################
# tvrage LOOKUP SCRIPT (dlx @ linknet)                    #
###########################################################
# v2.3fix - changed API url                               #
#         - added timeout after 5 seconds (stops crashing #
#           if tvrage.com is slow                         #
#         - modified by znuff on 17/05/2010               #
###########################################################
# v2.3 - changed the way !today and                       #
#        !tomorrow reply for less spam                    #
###########################################################
# v2.2 - added tvrage(inline) support                     #
#        for iPoRn                                        #
###########################################################
# v2.1 - added time output to !tonight                    #
#         and !tomorrow for nogruk                        #
###########################################################
# v2.0 - new commands !next/!last/                        #
#                !tonight/!tomorrow                       #
###########################################################

bind pub - .tv dlx:tvrage:tv
bind pub - .tvnext dlx:tvrage:next
bind pub - .tvlast dlx:tvrage:last
#bind pub - .tvtonight dlx:tvrage:tonight
#bind pub - .tvtomorrow dlx:tvrage:tomorrow

# Channels not to be displayed on !tonight/!tomorrow
set tvrage(excluded_Channels) [list "Nickelodeon" "Disney Channel" "Style" "VH1" "HGTV" "PBS" "Cooking Channel" "Food Network" "TLC" "Discovery Channel" "Spike TV" "E!" "A&E" "Cartoon Network" "Animal Planet"]

# timeout value - in miliseconds
set tvrage(timeout) "5000"

# Show the Time of the show?
set tvrage(show_time) "TRUE"

# Show the Episode number of the show?
set tvrage(show_episode) "TRUE"

# Display !tonight and !tomorrow in one line?
# TRUE will squeeze all shows into one line
# FALSE will split them up by channel (DEFAULT)
set tvrage(inline) "FALSE"

proc dlx:tvrage:tv { nick host hand chan arg } {
    global tvrage
    package require http
    set prefix "\002\0037TV ->\003\002 "
 
    set arg [string map { " " "%20" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $tvrage(timeout)]]

    regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page gotname show_name
    regexp {Show URL@http://www.tvrage.com/([A-Za-z_0-9/-]+)} $page goturl show_url
    regexp {Premiered@([0-9]+)} $page gotpremiere show_premiered
    regexp {Latest Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([A-Za-z0-9/]+)} $page gotlatest latest_ep latest_ep_title latest_ep_date
    set gotnext [regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page gotnext next_ep next_ep_title next_ep_date]
    regexp {Country@([A-Za-z]+)} $page gotcountry show_country
    regexp {Status@([A-Za-z/ ]+)} $page gotstatus show_status
    regexp {Classification@([A-Za-z ]+)} $page gotclassification show_classification
    set gotgenres [regexp {Genres@([A-Za-z |]+)} $page gotgenres show_genres]
    regexp {Network@([A-Za-z 0-9]+)} $page gotnetwork show_network
    regexp {Airtime@([A-Za-z, 0-9:]+)} $page gotairtime show_airtime

    if { ![info exists show_name] } {
       putquick "PRIVMSG $chan :$prefix Error! (timeout or something similar)"
    #   return -1
    }

    set show_url "http://www.tvrage.com/$show_url"
    if { $gotgenres == 0 } { set show_genres "N/A" }
    if { $gotnext == 0 } {
            set next_ep "00x00"
            set next_ep_title "-N/A-"
            set next_ep_date "not available"
    }
   putquick "PRIVMSG $chan :$prefix Show: $show_name ($show_classification \| $show_genres)"
   putquick "PRIVMSG $chan :$prefix Premiered: $show_premiered"
   putquick "PRIVMSG $chan :$prefix Status: $show_status"
   putquick "PRIVMSG $chan :$prefix Network: $show_network"
   putquick "PRIVMSG $chan :$prefix URL: $show_url"
}

proc dlx:tvrage:next { nick host hand chan arg } {
    global tvrage
    package require http
    set prefix "\002\0037TV ->\003\002 "
    set arg [string map { " " "_" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $tvrage(timeout)]]
 
    regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page gotname show_name
    set gotnext [regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page gotnext next_ep next_ep_title next_ep_date]
    regexp {Airtime@([A-Za-z, 0-9:]+)} $page gotairtime show_airtime
   
    if { ![info exists show_name] } {
       putquick "PRIVMSG $chan :$prefix Error! (timeout or something similar)"
    #   return -1
    }

    if { $gotnext == 0 } {
      putquick "PRIVMSG $chan :$prefix The next episode of \002$show_name\002 is not yet scheduled. That makes me a sad panda :("
    } else {
   putquick "PRIVMSG $chan :$prefix The next episode of \002$show_name\002 is \002$next_ep_title \[$next_ep\]\002, it will air on \002$show_airtime\002 \002$next_ep_date\002"
   }
}
 
proc dlx:tvrage:last { nick host hand chan arg } {
    global tvrage
    package require http
    set prefix "\002\0037TV ->\003\002 "
    set arg [string map { " " "_" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $tvrage(timeout)]]
 
    regexp {Show Name@([A-Za-z 0-9\&\':]+)} $page gotname show_name
    regexp {Latest Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:\.,]+)\^([A-Za-z0-9/]+)} $page gotlatest latest_ep latest_ep_title latest_ep_date
    set gotnext [regexp {Next Episode@([0-9x]+)\^([A-Za-z0-9 -\`\"\'\&:.,]+)\^([A-Za-z0-9/]+)} $page gotnext next_ep next_ep_title next_ep_date]

    if { ![info exists show_name] } {
       putquick "PRIVMSG $chan :$prefix Error! (timeout or something similar)"
    #   return -1
    }
   
   putquick "PRIVMSG $chan :$prefix The last episode of \002$show_name\002 is \002$latest_ep_title $latest_ep\ \002 it aired on \002$latest_ep_date\002"
}

proc dlx:tvrage:tonight { nick host hand chan arg } {
   global tvrage
   if { [info exists chans] } { unset chans }
   package require http
   set prefix "\002\0037TV ->\003\002 "
   set schedule [http::data [http::geturl "http://www.tvrage.com/quickschedule.php" -timeout $tvrage(timeout)]]

   set end [string first "\n\n" $schedule]
   set today [string range $schedule 0 $end]

   putquick "PRIVMSG $chan :$prefix TV Schedule for Today:"

   set showList "$prefix "

   foreach line [split $today "\n"] {
      set found_time [regexp {\[TIME\](.*)\[\/TIME\]} $line found_time time]
      set found_show [regexp {\[SHOW\](.*)\^(.*)\^(.*)\^(.*)\[\/SHOW\]} $line found_show show_channel show_name show_ep show_url]
      if { $found_show && [lsearch -exact $tvrage(excluded_Channels) $show_channel] == -1 } {
         if { $tvrage(inline) } {
            append showList "$show_name ($show_ep) - "
         } else {
            if {$tvrage(show_time)} { append chans($show_channel) "\037$time\037 " }
            append chans($show_channel) "\002$show_name\002 "
            if {$tvrage(show_episode)} { append chans($show_channel) "($show_ep) " }
         }
      }
   }
   if { $tvrage(inline) } {
      set showList [string range $showList 0 [expr [string length $showList] - 3]]
      putquick "PRIVMSG $chan :$showList"
   } else {
      set chanlist [array names chans]
      foreach x $chanlist {
         putquick "PRIVMSG $chan :$x\: $chans($x)"
      }
   }
}

proc dlx:tvrage:tomorrow { nick host hand chan arg } {
   global tvrage
   if { [info exists chans] } { unset chans }
   package require http
   set prefix "\002\0037TV ->\003\002 "
   set schedule [http::data [http::geturl "http://www.tvrage.com/quickschedule.php" -timeout $tvrage(timeout)]]

   set start [string first "\n\n" $schedule]
   set schedule [string range $schedule [expr $start+3] end]

   set end [string first "\n\n" $schedule]
   set tomorrow [string range $schedule 0 $end]

   putquick "PRIVMSG $chan :$prefix TV Schedule for Tomorrow:"

   set showList "$prefix "

   foreach line [split $tomorrow "\n"] {
      set found_time [regexp {\[TIME\](.*)\[\/TIME\]} $line found_time time]
      set found_show [regexp {\[SHOW\](.*)\^(.*)\^(.*)\^(.*)\[\/SHOW\]} $line found_show show_channel show_name show_ep show_url]
      if { $found_show && [lsearch -exact $tvrage(excluded_Channels) $show_channel] == -1 } {
         if { $tvrage(inline) == "TRUE" } {
            append showList "$show_name ($show_ep) - "
         } else {
            if {$tvrage(show_time)} { append chans($show_channel) "\037$time\037 " }
            append chans($show_channel) "\002$show_name\002 "
            if {$tvrage(show_episode)} { append chans($show_channel) "($show_ep) " }
         }
      }
   }
   if { $tvrage(inline) == "TRUE" } {
      set showList [string range $showList 0 [expr [string length $showList] - 3]]
      putquick "PRIVMSG $chan :$showList"
   } else {
      set chanlist [array names chans]
      foreach x $chanlist {
         putquick "PRiVmsg $chan :$x\: $chans($x)"
      }
   }
}

putlog "dlx-tvrage_v2.3f.tcl loaded. enjoy!"
Back to top
View user's profile Send private message
luminoso
Voice


Joined: 02 Jul 2007
Posts: 7

PostPosted: Tue May 18, 2010 3:10 pm    Post subject: Reply with quote

thank you!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber