This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

TVInfo Light v001 / Lightweight tvrage.com lookup

Support & discussion of released scripts, and announcements of new releases.
Z
Znuff
Voice
Posts: 9
Joined: Mon May 17, 2010 1:00 am

TVInfo Light v001 / Lightweight tvrage.com lookup

Post by Znuff »

Hello,

I've stripped apart an older version of dlx's TVRage script and made it lighter.
It only includes the tv, tvnext and tvlast commands.
<znf> .tv Game of Thrones
<Lamestbot> (TV) Show: Game of Thrones (Scripted | Action | Drama | Fantasy)
<Lamestbot> (TV) Premiered: 2010 • Status: Returning Series
<Lamestbot> (TV) URL: http://www.tvrage.com/Game_of_Thrones
<Lamestbot> (TV) Previous Ep: 01x10 on Jun/19/2011 • Next Ep: 02x01 on Apr/15/2012

<znf> .tvnext Game of Thrones
<Lamestbot> (TV) The next episode of Game of Thrones is Season 2, Episode 1 [02x01], it will air on Sunday at 09:00 pm Apr/15/2012. Previous episode was 01x10 on Jun/19/2011.

<znf> .tvlast Game of Thrones
<Lamestbot> (TV) The last episode of Game of Thrones was Fire and Blood [01x10], it aired on Jun/19/2011. Next episode is 02x01 scheduled on Apr/15/2012.

Code: Select all


################################################################################
# TVInfo Light                                                                 #
# Based on dlx's tvrage lookup script                                          #
################################################################################
#                                                                              #
# v001 - 23/08/2011                                                            #
# - Initial release, stripped appart dlx's tvrage script                       #
#                                                                              #
################################################################################

bind pub - .tv tv
bind pub - .tvnext tvnext
bind pub - .tvlast tvlast

# timeout value - in miliseconds
set timeout "5000"

#set a prefix for the output, you can use %bull, %bold, %uline, %color
set prefix "(TV) "

proc showinfo { chan arg } {
    global prefix
    set arg "$prefix$arg"
    set arg [replacevar $arg "%bold" "\002"]
    set arg [replacevar $arg "%uline" "\037"]
    set arg [replacevar $arg "%bull" "\u2022"]
    set arg [replacevar $arg "%color" "\003"]
    set arg [encoding convertto utf-8 $arg]
    putquick "PRIVMSG $chan :$arg"
}

proc tv { nick host hand chan arg } {
    global timeout
    package require http
 
    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 $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] } {
       showinfo $chan "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"
    }
    showinfo $chan "%color7Show:%color %bold$show_name%bold ($show_classification \| $show_genres)"
    showinfo $chan "%color7Premiered:%color %bold$show_premiered%bold %bull %color7Status:%color %bold$show_status%bold"
    showinfo $chan "%color7URL:%color %bold$show_url"
    showinfo $chan "%color7Previous Ep:%color %bold$latest_ep on $latest_ep_date%bold %bull %color7Next Ep:%color %bold$next_ep on $next_ep_date"
}

proc tvnext { nick host hand chan arg } {
    global timeout
    package require http
    set arg [string map { " " "_" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $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]
    regexp {Airtime@([A-Za-z, 0-9:]+)} $page gotairtime show_airtime
    
    if { ![info exists show_name] } {
       showinfo $chan "Error! (timeout or something similar)"
    }

    if { $gotnext == 0 } {
      showinfo $chan "The next episode of %bold$show_name%bold is not yet scheduled. That makes me a %color7sad panda%color :(."
    } else {
    showinfo $chan "The next episode of %bold$show_name%bold is %bold$next_ep_title \[$next_ep\]%bold, it will air on %bold$show_airtime $next_ep_date%bold. Previous episode was $latest_ep on $latest_ep_date."
   }
}
 
proc tvlast { nick host hand chan arg } {
    global timeout
    package require http
    set arg [string map { " " "_" } $arg]
 
    set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg"
    set page [http::data [http::geturl $url -timeout $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] } {
       showinfo $chan "Error! (timeout or something similar)"
    }
    if {$gotnext == 0} {
      showinfo $chan "The last episode of %bold$show_name%bold was %bold$latest_ep_title \[$latest_ep\]%bold, it aired on %bold$latest_ep_date%bold. Next episode is not yet scheduled :-(."
    }
    showinfo $chan "The last episode of %bold$show_name%bold was %bold$latest_ep_title \[$latest_ep\]%bold, it aired on %bold$latest_ep_date%bold. Next episode is %bold$next_ep%bold scheduled on %bold$next_ep_date%bold."
}

putlog "TVInfo Light v001: LOADED"
http://z.linge-ma.ws/eggdrop/tvinfolight.tcl
User avatar
Anahel
Halfop
Posts: 48
Joined: Fri Jul 03, 2009 6:18 pm
Location: Dom!

Post by Anahel »

great script! could you tell me - is it possible to add option to display in .tvnext how much time (days/hours) left to air?

eg: some series will air on someday (in 1 day, 5 hours)
Z
Znuff
Voice
Posts: 9
Joined: Mon May 17, 2010 1:00 am

Post by Znuff »

I'll try to see what I can make if/when I have time.
g
goalie204
Halfop
Posts: 44
Joined: Thu Apr 28, 2011 7:31 pm

Post by goalie204 »

<goalie> !next dexter
[methlab(dcc)] [15:55] Tcl error [tvnext]: invalid command name "replacevar"
..[methlab(dcc)] [15:56] Tcl error [tvnext]: Illegal characters in URL path
User avatar
Anahel
Halfop
Posts: 48
Joined: Fri Jul 03, 2009 6:18 pm
Location: Dom!

Post by Anahel »

Code: Select all

[23:30:39] <&tomek> .tvnext dexter
[23:30:43] <&Nekomimi> The next episode of Dexter is Those Kinds of Things [06x01], it will air on Sunday at 09:00 pm Oct/02/2011. Previous episode was 05x12 on Dec/12/2010.
.tvnext is working for me ^
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

replacevar... lmao.. this has been discussed before.

Replace this below:

Code: Select all

    set arg [replacevar $arg "%bold" "\002"]
    set arg [replacevar $arg "%uline" "\037"]
    set arg [replacevar $arg "%bull" "\u2022"]
    set arg [replacevar $arg "%color" "\003"] 
With this:

Code: Select all

    set arg [string map [list "%bold" "\002" "%uline" "\037" "%bull" "\u2022" "%color" "\003"] $arg]
It works for some people because they already have scripts "sourced" that make use of that silly replacevar procedure...


Then...

Change this:

Code: Select all

set url "http://services.tvrage.com/tools/quickinfo.php?show=$arg" 
To this:

Code: Select all

set url "http://services.tvrage.com/tools/quickinfo.php?show=[::http::formatQuery $arg]"
That will stop the "Illegal characters in URL path" error.
g
goalie204
Halfop
Posts: 44
Joined: Thu Apr 28, 2011 7:31 pm

Post by goalie204 »

<goalie> !next dexter
<methlab> (TV) The next episode of Dexter is Those Kinds of Things [06x01], it will air on Sunday at 09:00 pm Oct/02/2011. Previous episode was 05x12 on Dec/12/2010.


SWEET! Thx man
g
granddad
Voice
Posts: 5
Joined: Mon May 19, 2008 5:17 pm

Post by granddad »

.tv csi miami
i get first 2- 3 x this
(tv)Error! (timeout or something similar)
Tcl error [tv]: can't read "show_url": no such variable
and then it works when i ask another like
.tv dexter
whats wrong ?

i did what speechles said for the other fault and that worked but this is a new one.
Z
Znuff
Voice
Posts: 9
Joined: Mon May 17, 2010 1:00 am

Post by Znuff »

Increase the timeout value. Unfortunatelly, lately tvrage's API is slow as hell and sometimes request time out.

Nothing you can do about it.
g
granddad
Voice
Posts: 5
Joined: Mon May 19, 2008 5:17 pm

Post by granddad »

Znuff : thanks it works now.

Sorry for late respons but i was away.
R
Robby
Voice
Posts: 4
Joined: Thu Jan 27, 2011 3:33 pm
Location: Belgium

Updated version of TVInfo Light

Post by Robby »

Hello, I took the liberty of updating this nice script with the above fixes and some other improvements.
Znuff, if you could base your next version on this one that would be awesome. :D

Code: Select all

################################################################################
# TVInfo Light                                                                 #
# Based on dlx's tvrage lookup script                                          #
################################################################################
#                                                                              #
# v001 (Znuff@Egghelp) - 23/08/2011                                            #
# - Initial release, stripped appart dlx's tvrage script                       #
# v002 (Robby@Egghelp) - 07/09/2011                                            #
# - Replaced replacevar with a string map (speechles)                          #
# - Fixed "Illegal characters in URL path" (speechles)                         #
# - Added a message saying we're querying the server so users know the bot     #
#   got the command and isn't lagging on them                                  #
# - Return on error to prevent further erroneous processing, stops and fixes   #
#   a "no such variable" error                                                 #
# - In the tvlast proc: added a missing else, fixing a "no such variable"      #
#   error                                                                      #
# - Fixed a "no such variable" error in the tv proc                            #
# - Added ability to enable/disable this script per channel through .chanset,  #
#   +tv to enable, -tv to disable                                              #
#   NOTE: At first this will be disabled for all channels, so you will have    #
#         to enable this for all the channels you want the script to work on   #
# - Put variables/settings in an array called: tv                              #
# - Clean up script indentation, some excess spaces and some other minor stuff #
# - Increased default timeout to 30000 as TVRage can be very slow to respond   #
# v003 (Robby@Egghelp) - 16/12/2011                                            #
# - Fixed an error if episode titles contained a ’ character                   #
# - Fixed a bug if genres contained a - or / character, it would cut off the   #
#   the remaining part of the line output (found by Arkadietz@Egghelp)         #
#                                                                              #
################################################################################

bind pub -|- .tv tv
bind pub -|- .tvnext tvnext
bind pub -|- .tvlast tvlast

# Timeout value - in milliseconds
set tv(timeout) "30000"

# Set a prefix for the output, you can use %bull, %bold, %uline and %color
# No trailing space needed.
set tv(prefix) "TV:"

set tv(version) "003"
setudef flag tv

proc showinfo {chan arg} {
  global tv
  set arg "$tv(prefix) $arg"
  set arg [string map [list "%bold" "\002" "%uline" "\037" "%bull" "\u2022" "%color" "\003"] $arg]
  set arg [encoding convertto utf-8 $arg]
  putquick "PRIVMSG $chan :$arg"
}

proc tv {nick host hand chan arg} {
  if {![channel get $chan tv]} {return 0}

  global tv
  package require http

  putquick "PRIVMSG $chan :$tv(prefix) Please wait, querying server..."

  set arg [string map {" " "%20"} $arg]

  set url "http://services.tvrage.com/tools/quickinfo.php?show=[::http::formatQuery $arg]"
  set page [http::data [http::geturl $url -timeout $tv(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]} {
    showinfo $chan "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 "N/A"
    set next_ep_title "N/A"
    set next_ep_date ""
  }
  showinfo $chan "%color7Show:%color %bold$show_name%bold ($show_classification \| $show_genres)"
  showinfo $chan "%color7Premiered:%color %bold$show_premiered%bold %bull %color7Status:%color %bold$show_status%bold"
  showinfo $chan "%color7URL:%color %bold$show_url"
  # Cleanup the "Prev/Next Ep" line output a little bit to
  # make it shorter if some variables are not available, this
  # also fixes an error when next_ep and next_ep_date are not set.
  # Probably not the best way to do it :P but it looks better on
  # the channel imo.
  if {![info exists latest_ep]} {set latest_ep "N/A"}
  if {![info exists latest_ep_date]} {
    set latest_ep_date ""
  } else {
    set latest_ep_date " on %bold$latest_ep_date%bold"
  }
  if {![info exists next_ep]} {set next_ep "N/A"}
  if {$next_ep_date != ""} {set next_ep_date " on %bold$next_ep_date%bold"}
  # Finally show the output:
  showinfo $chan "%color7Previous Ep:%color %bold$latest_ep%bold$latest_ep_date %bull %color7Next Ep:%color %bold$next_ep%bold$next_ep_date"

  return 1
}

proc tvnext {nick host hand chan arg} {
  if {![channel get $chan tv]} {return 0}

  global tv
  package require http

  putquick "PRIVMSG $chan :$tv(prefix) Please wait, querying server..."

  set arg [string map {" " "_"} $arg]

  set url "http://services.tvrage.com/tools/quickinfo.php?show=[::http::formatQuery $arg]"
  set page [http::data [http::geturl $url -timeout $tv(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]
  regexp {Airtime@([A-Za-z, 0-9:]+)} $page gotairtime show_airtime

  if {![info exists show_name]} {
    showinfo $chan "Error! (timeout or something similar)"
    return 1
  }

  if {$gotnext == 0} {
    showinfo $chan "The next episode of %bold$show_name%bold is not yet scheduled. That makes me a %color7sad panda%color. :-("
  } else {
    showinfo $chan "The next episode of %bold$show_name%bold is %bold$next_ep_title \[$next_ep\]%bold, it will air on %bold$show_airtime $next_ep_date%bold. Previous episode was $latest_ep on $latest_ep_date."
  }

  return 1
}

proc tvlast {nick host hand chan arg} {
  if {![channel get $chan tv]} {return 0}

  global tv
  package require http

  putquick "PRIVMSG $chan :$tv(prefix) Please wait, querying server..."

  set arg [string map {" " "_"} $arg]

  set url "http://services.tvrage.com/tools/quickinfo.php?show=[::http::formatQuery $arg]"
  set page [http::data [http::geturl $url -timeout $tv(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]} {
    showinfo $chan "Error! (timeout or something similar)"
    return 1
  }

  if {$gotnext == 0} {
    showinfo $chan "The last episode of %bold$show_name%bold was %bold$latest_ep_title \[$latest_ep\]%bold, it aired on %bold$latest_ep_date%bold. Next episode is not yet scheduled. :-("
  } else {
    showinfo $chan "The last episode of %bold$show_name%bold was %bold$latest_ep_title \[$latest_ep\]%bold, it aired on %bold$latest_ep_date%bold. Next episode is %bold$next_ep%bold scheduled on %bold$next_ep_date%bold."
  }

  return 1
}

putlog "TVInfo Light v$tv(version): LOADED"
Last edited by Robby on Thu Dec 15, 2011 10:27 pm, edited 2 times in total.
F
FightingNavyman
Voice
Posts: 35
Joined: Tue Jan 18, 2011 12:39 pm

tvinfolight.tcl

Post by FightingNavyman »

we need an update for this script

[06:03:00pm] <~chachin> .tvnext supernatural
[06:03:01pm] <@R2D2> TV: Please wait, querying server...
[06:03:34pm] <@R2D2> TV: Error! (timeout or something similar)
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Post by Arkadietz »

[02:02:33] <Kiril> !tvnext house
[02:02:33] <Monica> TV: Please wait, querying server...
[02:03:04] <Monica> TV: Error! (timeout or something similar)
[02:03:42] <Kiril> !tv white collar
[02:03:43] <Monica> TV: Please wait, querying server...
[02:04:13] <Monica> TV: Error! (timeout or something similar)

and a lot of the same..

kiril@amon:~/Monica/scripts$ ping tvrage.com
PING tvrage.com (80.246.178.98) 56(84) bytes of data.
64 bytes from www.tvrage.com (80.246.178.98): icmp_seq=1 ttl=56 time=12.1 ms
64 bytes from www.tvrage.com (80.246.178.98): icmp_seq=2 ttl=56 time=12.0 ms
64 bytes from www.tvrage.com (80.246.178.98): icmp_seq=3 ttl=56 time=12.0 ms
64 bytes from www.tvrage.com (80.246.178.98): icmp_seq=4 ttl=56 time=12.0 ms
64 bytes from www.tvrage.com (80.246.178.98): icmp_seq=5 ttl=56 time=12.0 ms

bug with ganre it's not full: [02:43:38] <Monica> TV: Show: Terra Nova (Scripted | Action | Adventure | Drama | Family | Fantasy | Sci )

i want to know is it possible to speed up the response? 1 to 2 sec will be nice and can you insert and the remaining time until the new series up

for example:
Dec/06/2011 0d,2h,13m,51s from now

and will be cool if you're add !today where show what up today
On a unix system everything is a file ; if something is not a file , it is a proccess.
R
Robby
Voice
Posts: 4
Joined: Thu Jan 27, 2011 3:33 pm
Location: Belgium

Post by Robby »

@Arkadietz: The script is not at fault in this case, the problem is the TVRage API/Services server that can be very slow to respond at times.., a good tv(timeout) value for me is 30000, you might try setting it to 45000 or 60000. If it still times out, simply retry the command again.

I fixed the bug you found, thanks for reporting!
As for the features you requested, the API doesn't seem to provide that info (though there are 2 feeds for schedules, quickschedule and fullschedule) for a !today command, so I guess it would have to be grabbed from an HTML page or feed with some regex magic or something which is not really in my league. As for showing the remaining time, I'll see what I can do.

@FightingNavyman: Same thing here, the script is not at fault, try setting the timeout higher as I just explained.

On another note, due to me testing the command you used now at the time I write this I did encounter a bug where if there's a specific character (see changelog) in the title of the episode that the tvnext/tvlast command will break but would not generate that error message that you got. So, coincidence ftw! :D


I have updated the script to v003 in my post above.
G
GaveUp
Op
Posts: 139
Joined: Thu Jan 19, 2006 3:56 am

Post by GaveUp »

Robby wrote: As for the features you requested, the API doesn't seem to provide that info (though there are 2 feeds for schedules, quickschedule and fullschedule) for a !today command, so I guess it would have to be grabbed from an HTML page or feed with some regex magic or something which is not really in my league. As for showing the remaining time, I'll see what I can do.
For the time until the next episode airs the info that is needed to get this value is provided in the quickschedule results. Feel free to take a look at my tvrage script to see how this can be calculated. I make no claims that my way is the best, but it might be enough to get you started.
Post Reply