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.

TVRage.com Schedule Script (Latest: 2.0)

Support & discussion of released scripts, and announcements of new releases.
Post Reply
G
GaveUp
Op
Posts: 139
Joined: Thu Jan 19, 2006 3:56 am

Post by GaveUp »

I had/have some documentation that I want to add (in code and end user doc) before submitting it to the archive. That was the only thing keeping me, but I haven't bothered to finish the documentation as it's been so long since I've been able to run/debug/dev the script I don't even know if it still works as it should and I do not want to push a version out that is bugged/doesn't work.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Gotcha. Well, the only bugs I've seen so far, was one that was posted previously, about

if {![parseCountry $text show(country)]} {

and then, I also fixed the wordwrap function so it's not inserting an extra space after the prefix, I used:

regsub { : } $out { :} out

The only thing I'd say the documents needed, was to note the newer +tvannounce setting, and maybe explain what the log stuff does. Other than those minor things, it looks good.
G
GaveUp
Op
Posts: 139
Joined: Thu Jan 19, 2006 3:56 am

Post by GaveUp »

Thanks for the prefix info. Where abouts did you put that regsub so I can throw it in my local copy? That one had been bother me for a while when I was working on the code. Most of the documentation I was talking about was in the code for purposes of maintenance. Function and parameter descriptions, return values, etc.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Code: Select all

proc wordwrap {str {len 200} {prefix {}} {splitChr { }}} {
        set out {}
        set cur $prefix
        set i 0
        foreach word [split [set str][unset str] $splitChr] {
                if {[incr i [string len $word]]>$len} {
                        lappend out [join $cur $splitChr]
                        #set out [string map {" : " " :"} $out]
                        # my hack - rosc
                        regsub { : } $out { :} out
                        if {[regexp {^.*(\003\d\d)} $cur -> lastColor]} {
                                set cur [join [list $prefix $lastColor $word] ""]
                        } else {
                                set cur [join [list $prefix $word] ""]
                        }
                        set i [string len $word]
                } else {
                        lappend cur $word
                }
                incr i
        }
        lappend out [join $cur $splitChr]
        # my hack - rosc
        regsub { : } $out { :} out
        return $out
}
Figured I'd use the regsub where the string map used to be too, so it only replaces the 1st occurance of { : }, where string map would replace all of em (could cause a prob if : was in the descriptions or somn)

When I've used a similar word-wrapper in scripts, I did this to append prefixes and whatnot:

Code: Select all

# this takes the wrapped output $out and stuffs prefixes into it.
# This would be used after the very last 'lappend out [join $cur $splitChr]' 
# in the word-wrapper.


# this adds prefix to each line and (con't) at the end of split lines except
# the very last
set j 0
foreach line2 $out {
        # modified to suit tvrage.tcl
        # put the prefix at the beginning of each line
        set line2 [linsert $line2 0 $prefix]
        if {$j >= 1} {
                # this puts (con't) at the end of a split line
                set line2 [linsert $line2 end (con't)]
                # but not the very last split line, where it's not needed.
                set j [expr $j - 1]
                 
        } 
        lappend out $line2
}
return $out     
                
#end---------------     

# It's also possible to format the split lines to have prefix, title, con't, etc:
                 
set j 0;set count 0
foreach line2 $out {
        set line2 [linsert $line2 0 $prefix]
        if {$count == 0} {
                # gives the 1st line a title string at the beginning,
                # $text was the original query name (this is from the dream.tcl script I made)
                set line2 [linsert $line2 0 \002[string totitle $text]\002:]
                incr count
                if {$j >= 1} {
                        # puts (con't) at the end of the line
                        set line2 [linsert $line2 end \002(con't)\002]
                        set j [expr $j - 1]
                }
        } else {
                # puts "title (con't)" at the beginning of the next line, so you
                # can put like, "Entry continued from last line"
                set line2 [linsert $line2 0 \002([string totitle $text] con't)\002]
                if {$j >= 1} {
                        # puts (con't) at end of line, except the very last
                        set line2 [linsert $line2 end \002(con't)\002]
                        set j [expr $j - 1]
                }
                }
        }
        lappend out $line2
}
I didn't spend a whole lot of time trying to figure out why the wordwrapper in the tvrage script was appending a space after the prefix, so I just did the regsub hack. But the above should do the trick of appending the prefix without any extra spaces. Presumably the regsub is faster, but I didn't check.
G
GaveUp
Op
Posts: 139
Joined: Thu Jan 19, 2006 3:56 am

Post by GaveUp »

Thanks again, I appreciate it. That should take care of the last small bug I was aware of.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

invalid format placeholders

Post by rosc2112 »

Just a quick suggestion. As I was fixing up my theme file and testing things out, it would be useful if the command placeholders worked in the Invalid help command strings, like:

# Format of summary request invalid.
set tvrage(summaryInvalidFormatLine) "PRIVMSG {%%chan%%} :\00307Invalid summary format {%%request%%}
Use: {%%summaryTrigger%%} <show> <episode> where <episode> is formatted as: SeasonxEpisode"

edit:

and like:
set tvrage(invalidCountry) "PRIVMSG {%%chan%%} :\00307Error: \00308\'\003\00304{%%country%%}\00308'\003 is not a supported.
Valid countries: {%%upperAvailableCountries%%}"
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

I think I found a bug! Yay :)

I'm not sure I'm I'm misreading the helpfile, for the primetime command, it should be '!primetime wed uk' for example? When I give it both params, the script kicks an error:

Code: Select all

Currently: can't read "days(sun uk)": no such element in array
Currently:     while executing
Currently: "expr (7 - $today) + $days([string tolower $text])"
Currently:     ("sun" arm line 3)
Currently:     invoked from within
Currently: "switch $arg {
Currently:                                     today { set w 0 }
Currently:                                     tomorrow { set w 1 }
Currently:                                     yesterday { set w -1 }
Currently:                                     mon -
Currently:                                     tue -
Currently:                                     wed -
Currently:                                     thu -
Currently:                                     fri -
Currently:                             ..."
Currently:     (procedure "::tvrage::primetime" line 22)
Currently:     invoked from within
Currently: "::tvrage::primetime $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
If I run the command with only one option, day of week, or country, it works.

Edit: Ohhh, I figured out the error:

set w [expr (7 - $today) + $days([string tolower $text])]

should be:

set w [expr (7 - $today) + $days([string tolower $arg])]
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Nevermind about the placeholders, I figured out how they worked and hacked it to do what I wanted :)
/should really lay off the caffeine after midnight ;)
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Yay another bug <grin>

If you look for a summary for an existing show, but non-existent episode:

<rosc> .tvsum idol 10x99
TVRage: TVRage: ERROR: can't read "show(episode_url)": no such element in array
Tcl error [::tvrage::getSummary]: can't read "show(found)": no such element in array
.set errorInfo

Currently: can't read "show(found)": no such element in array
Currently: while executing
Currently: "if {$show(found)} {
Currently: displayInfo [templateParser $tvrage(summaryLine) [array get show]]
Currently: } else {
Currently: displayInfo [templateParser $tvrage(noShowLine..."
Currently: (procedure "::tvrage::getSummary" line 13)
Currently: invoked from within
Currently: "::tvrage::getSummary $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"

I'll see if I can fix it.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Fixed:

Code: Select all

In proc getEpisodeInfo

if {[catch {set token [http::geturl $show(episode_url) -timeout [expr $tvrage(httpTimeout) * 1000]]} error]} {
     debug ERROR "TVRage: ERROR: $error"
     set show(found) 0
     return
}
The prob was, there is info, but in a different format than usual. I tried using an && in the test to use the url shown in that example output (from american idol 1x99) but then that broke all of the placeholders and I didn't feel like mucking it up even more, so just had it set the show(found) var and return.

But I found another buglet, at least it's kind of annoying, the debug ERROR stuff comes through despite having the debug setting set to NONE =) I don't see a switch for it in 'proc debug' so I don't see a simple way to turn off the error msgs, cept by commenting them out.

Hmm on second thought, I guess those msgs can be useful..

But I found another question for ya <grin>

What is the log stuff for? I only see it being read, but not written to. I'm not sure what it's supposed to be for. Now I see what ya meant about documentation :)

Edit: Hmm..when I enable the log thingy, it throws an error:

Tcl error in script for 'timer18088':
invalid command name "readTVLog"

.set errorInfo

Currently: invalid command name "readTVLog"
Currently: while executing
Currently: "readTVLog"

I figured that was because the timer wasn't finding the proc outside the namespace. I tried copying the proc outside of the namespace, but then got var errors and didn't feel like mucking with it, so scratch that. I disabled the log option til I know what it's for <grin>


Something else that could use a little tweaking, if you try to get a schedule for too far in the past/future (like !schedule -10 or !schedule 10), it doesn't return any msg. Perhaps it should at least return the notCached message?


We'll get this thing fixed and set for the tcl archive at least :^)
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Found/fixed another boog:

When running the schedule command, if you give it a day-of-week and country, it was choking. (eg, !schedule mon uk) Fixed this:

Code: Select all

Original:
printSchedule $show(country) [expr (7 - $currDay) + $days([string tolower $text])] $chan $nick

Fix:
printSchedule $show(country) [expr (7 - $currDay) + $days([string tolower $desiredDay])] $chan $nick
Also somewhat fixed the prob mentioned in the previous post, about the script not returning any error msg:

Code: Select all

if {[string is integer $desiredDay ]} {
         if {$desiredDay <= 6 && $desiredDay >= [expr (-1 * $tvrage(cacheForDays))]} {
                       printSchedule $show(country) $desiredDay $chan $nick
        # my hack
         } else {
                       puthelp "PRIVMSG $nick :No schedule is cached for $desiredDay days."
                       #displayInfo [templateParser $tvrage(notCached) "$desiredDay days"]
                       return
         }
I tried to use the displayInfo function, but I don't quite understand how it works, so I just used a puthelp in there for now.

I also changed/fixed the pub/msg bind option, when I had this set to try msg binds, the script was failing, cos obviously msg binds use different params than pub, and there's no msg procs, so, I added msg procs..

I know there's a way to use pub binds/procs for msg, I didn't look it up tho. I think it's something like:

proc whatever {nick uhost hand {chan text}}

I also added a setudef +tvquiet, so that channels can be flagged to send output to privmsg only (commands are run in channel, response is sent to privmsg)

In the conf file, I changed:

# Set triggers to pub(1) or msg(2) or both (3)
set tvrage(pubTriggers) 3

Then in the script:

Code: Select all

        # Changed to allow both pub and msg binds -Rosc
        if {$tvrage(pubTriggers) == 1} {
                set tvrage(triggerType) "pub"
        } elseif {$tvrage(pubTriggers) == 2} {
                set tvrage(triggerType) "msg"
        } else {
                set tvrage(triggerType) "pub msg"
        }

        # added this foreach to enable both pub and msg binds.. Added msg procs as well, as setting
        # set tvrage(pubTriggers) did not work with the triggers set to msg type. -Rosc

        foreach triggerType2 $tvrage(triggerType) {
                if {$tvrage(enableSchedule)} {
                        foreach trigger [split $tvrage(todayTrigger) " "] {
                                bind $triggerType2 $tvrage(todayFlags) $trigger [namespace current]::today:$triggerType2

                        }
                # repeat for each bind
        };# end of foreach triggerType
Then of course, I renamed each of the pub bind procs, like so:

Code: Select all

New msg proc:

        proc availableCountries:msg {nick uhost hand text} {
                if {![onchan $nick]} {return}
                availableCountries:pub $nick $uhost $hand privmsg $text
                return
        }


Modified pub proc:

       proc availableCountries:pub {nick uhost hand chan text} {
                variable tvrage
                if {$chan == "privmsg"} {
                        set chan $nick
                } elseif {[channel get $chan tvquiet]} {
                        set chan $nick
                } elseif {![channel get $chan tv]} {
                        return
                }
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Coupla more fixes for ya :)

I added a new error msg type into the themes file for invalid Schedule request formats, so now all the possible if/elses in proc schedule return some kind of msg. Also, as we discussed last night on irc, I fixed the updateCache thingy a bit. I think I'll just post a diff file when I get done in a bit :)
s
speedism
Voice
Posts: 2
Joined: Thu Mar 22, 2007 12:27 am

trigger error?

Post by speedism »

[04:28] Loading TVRage.com Primetime Schedule Script v1.0 RC2
[04:28] tvrage.tcl info: Loaded tvrage.conf successfully.
[04:28] tvrage.tcl info: Loaded themes/default.theme successfully.
[04:28] Tcl error in file 'conf':
[04:28] couldn't set loop variable: "trigger"
while executing
"foreach trigger [split $tvrage(todayTrigger) " "] {
bind $tvrage(triggerType) $tvrage(todayFlags) $trigger [namespace current]::today
}"
(in namespace eval "::tvrage" script line 42)
invoked from within
"namespace eval tvrage {

set tvrage(version) "v1.0 RC2"
set tvrage(versionLine) "TVRage.com Primetime Schedule Script $tvrage(version)"
set tvrage(scr..."
(file "scripts/tvrage/tvrage.tcl" line 1)
invoked from within
"source scripts/tvrage/tvrage.tcl"
(file "conf" line 240)
[04:28] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)




my conf source line is: source script/tvrage/tvrage.tcl

Any help?
s
scr1pt
Voice
Posts: 11
Joined: Fri Mar 30, 2007 1:12 am

Post by scr1pt »

get this error when trying to install DICT

tclDict-8.5.2$ ./configure
checking for correct TEA configuration... ok
checking for Tcl configuration... configure: WARNING: "Cannot find Tcl configuration definitions"
s
scr1pt
Voice
Posts: 11
Joined: Fri Mar 30, 2007 1:12 am

Post by scr1pt »

fixed....
done alot of reading :)
Post Reply