PDA

View Full Version : Nag Message Remover for Unsubbed Series 1



cojonesdetoro
04-20-2004, 07:01 PM
EDIT 12/27/2004

This one's even better as it is more generalized. It works on my unsubbed SA1/3.0 but YMMV. If it doesn't work it's probably because the MFS path is different on your Tivo. You can browse MFS with TW to find where it needs to change.

It's not a TW module so you'll have to run from cron or something. Just cut and paste this code and call it delnag.tcl or sumthin:



#!/tvbin/tivosh

proc deletemsg {} {
global subject msg
puts "Found Mail with Subject: $subject"
puts "Deleting...."
dbobj $msg set Deleted 1
event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::MESSAGES 0
}


if { $argv == "" } {
puts "usage: $argv0 \'some string in subject\'"
puts " "
puts " This script will delete pre-tivo messages"
puts " Many of these are nag messages. "
puts " Include in parameters the subject of "
puts " the message like this: "
puts " $argv0 Tivo Service Interrupted"
puts " "
puts " note that it triggers on a substring so just "
puts " running this will also work: "
puts " "
puts " $argv0: Interrupted "
puts " "
puts " Just be careful to be specific enough to "
puts " not delete stuff you don't want to delete "
puts " "
puts " running this will delete all ptretivo messages: "
puts " "
puts " $argv0 DELETE-ALL "
puts " "
puts " it's a good way to eliminate nag messages "
}

set db [ dbopen ]

ForeachMfsFile fsid name type "/MessageItem/PreTivoCentral" "" {
RetryTransaction {
set msg [db $db openid $fsid]
set subject [dbobj $msg get Subject]
set deleted [dbobj $msg get Deleted]
if { $deleted != 1 } {
if { [ string first "$argv" "$subject" ] != -1 } {
deletemsg
} elseif { $argv == "DELETE-ALL" } {
deletemsg
}

}
}
}



Old information below this line -----------------


EDIT2: I have included the script called 'nagkiller' that is a tivoweb module. I have been using this one now for weeks with no noticable side effects. The delnag script is the one referred to in the text below and is buggy. I will leave it in case anyone wants to fix it. It does not rely on tivoweb.
------------------------
EDIT: There's a memory leak when running this script frequently. If you have Tivoweb then try the module shown further down the thread. if not, maybe running this script in the background with an endless loop might improve things.
-------------------------------------------------------

Here's a little script to remove those annoying "Daily Call Required" PreTivoCentral mail messages you get twice-daily when using an unsubbed Tivo.

Disclaimer: I have not tested the script extensively. It seems to work on my SA1/3.0 but YMMV. As always, use this at your own risk. You must accept all the consequences of using this software or not use it at all. This is very raw alpha code. You may also want to wait for more experienced developer feedback to make sure the script does not cause more subtle damage before using it.


The best way to use it would be to issue a cron job that runs it every so often. I didn't try doing an priority stuff so you may want to run from a setpri environment that will not cause a pause in the video. I run it from a cron job that runs every 30 minutes and do not notice any video stuttering when it is run.

Post your feedback here in order to help others and possibly improve the script.

Props to Jeff Keegan and the Tivoweb(and plus) project developers. By reading the tivoweb mail module, I was able to write this in 20 minutes.

EDIT: This script does nothing to 'fake out' the unsubbed Tivo into 'thinking' it has already had a successful dial-in. For that, you need to find fixup30.tcl. This just takes out the tivo message that pops up twice a day whenever you press the Tivo key. This message always has the subject "Daily Call Required". This script will only delete messages that are: not already deleted, have the subject "Daily Call Required" and are set to display when you press the Tivo key.

cojonesdetoro
04-24-2004, 04:10 PM
I have since found that running this script too frequently results in the "No EventSwitcher active" bug. Searches show it to be mostly a 3.1 problem but this is not the first time I've seen it in 3.0. It used to happen with a hack I was working on that leaked file handles.

I can't seem to find much information about this except that the only fix is a reboot once the bug is encountered. I'm going to try running wiht less frequency and see what happens. I was running it at 10 minute intervals since I didn't think there was any harm in that. I have switch to hourly so let's see what happens.

Does anyone know more about the nature of this bug and possible techniques to avoid it?

Perhaps the database open handles are never being cleared when the script exits. It's probably some sort of memory leak. Perhaps the only fix is to have the script run in an endless loop? That's messy and hogs resources.

rc3105
04-24-2004, 04:25 PM
rename it whatever.itcl & throw it in /tivoweb-tcl/modules. the script will get sourced at tivoweb startup & can ping/pong/invoke itself periodically w/o requiring any new db handles or extra processes...

cojonesdetoro
04-24-2004, 10:32 PM
ping/pong/invoke itself periodically w/o requiring any new db handles or extra processes...

Sounds like a good idea. I'll give that a shot and see how it goes. I gotta figure out the best way to have a tivo module stay running in an endless loop. A module has to return control to Tivoweb. How do you fork off a process in tivosh? Is there a facility in Tivoweb for having a proc called at repeated intervals?

I was also thinking of just emulating a browser and going to tivoweb through a socket at port 80.

rc3105
04-24-2004, 11:15 PM
doesn't have to be a full blown module or worry about returning control, something as simple as



#ping-pong.itcl

proc ping_pong { } {
puts stdout "ping_pong"
#insert nag killer code here
after 30000 ping_pong
}

ping_pong


will add the procedure ping_pong to tivoweb & invoke it initially. then it schedules itself to run again in 30 seconds. vwait & event handlers will progress normally. if ping_pong's scheduled but another procedure hasn't returned control it'll execute when control returns to the vwait loop. as long as ping_pong-nag_killer doesn't take forever to execute & return control it won't impact tw performance measurably

cojonesdetoro
04-24-2004, 11:27 PM
Nice technique. I'll post it here after I got it working.

cojonesdetoro
04-24-2004, 11:56 PM
Ah, much better. Thanks for the tip. I did not know the 'after' command allowed that... very handy. It seems to work well so far.

Instructions:

create a file called 'whatever.itcl' (name doesn't matter) in the tivoweb modules directory and put this text in there.

Do a chmod 755 whatever.itcl

restart Tivoweb

Create a Tivo message in the 'PreTivoCentral' section with the subject "Daily Call Required" and see if it disappears.


EDIT: You may want to take out the 'puts' commands that print information or else it will fill up the tivoweb logs. You also may want to increase the 30 second interval if you see any performance related anamolies. Works fine here but YMMV.



#!/tvbin/tivosh
proc nagkiller {} {
global db
puts "nagkiller running at [ exec /bin/date ] "
# Main code that deletes PTC nag messages for unsubbed Tivo

# comment this out replaced with global statement above
#set db [ dbopen ]
ForeachMfsFileTrans fsid name type "/MessageItem/PreTivoCentral" "" 20 {
set msg [db $db openid $fsid]
set subject [dbobj $msg get Subject]
set deleted [dbobj $msg get Deleted]
if { $deleted != 1 && "$subject" == "{Daily Call Required}" } {
puts "Found PreTivoCentral Mail with subject: $subject"
puts "Deleting...."
dbobj $msg set Deleted 1
event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::MESSAGES 0
}
}
after 30000 nagkiller
}
nagkiller



Note: This module will not show up in the tivoweb main menu.

cojonesdetoro
04-25-2004, 01:28 PM
<slap to the forehead>

The dbopen should not be needed now...

Editted original script above

rc3105
04-27-2004, 09:05 PM
I've often wondered why there wasn't a cron module included with the main tivoweb distribution. scripts can launch binaries yanno...

cojonesdetoro
04-27-2004, 10:39 PM
scripts can launch binaries yanno...

Sho'nuff, I wrote a dirt-simple module to do CGI-like script execution. I thought aboout cron as well. The only thing is that while cron is working, tivoweb can't respond. There's also already a nice cron binary that does the job and takes few resourses (S1 version, anyway). Althoughm it would nice to edit the crontab AND run the module from tivoweb.

I think the bigger priority is to make TCL scripts run this way so as to avoid multiple tivosh instances and resources (defined procs and handles). I'm thinking of porting a pop mail client called tpop to run this way. It retrieves pop mail to tivo messages.

I also PMed Sanderton about this. He has this dailymail hack where he rewrote all these functions so that hack 'thought' it was running under tivoweb. It would have been easier to run it this with a parameter the mail schedule. He also has that great 'endpad' hack that lends itself well to this method.

I posted a message in the tivoweb development thread as well. I suggested the development of a 'silent resident module' standard. Silent because it doesn't necessarily show up on the main menu and resident because it
executes periodically.

BTW, is it just my browser or are buttons missing on this site?

cojonesdetoro
04-29-2004, 11:38 PM
I found a problem with this technique. If you either a full or quick restart of tivoweb the proc gets called again. It creates an additional event that calls the proc. I have to figure out a way to determine if the current iteration is a restart or a 'fresh' start of tivoweb.

rc3105
04-30-2004, 06:32 AM
#ping-pong.itcl

proc ping_pong { } {
puts stdout "ping_pong"
#insert nag killer code here
after 30000 ping_pong
}

if { [info exist boot_refresh] } {
set boot_refresh "refresh"
} else {
set boot_refresh "boot"
}

ping_pong


or you could declare a global that's incremented every time whatever.itcl is loaded, or you could check the list of registered events to see if ping_pong is allready scheduled, or <insert favorite scheduling algorithm here>... ;)

cojonesdetoro
04-30-2004, 10:17 PM
The boot_refresh var is exactly what I was seeking. How do you check the list of registered events?

EDIT:
removed stupid statement

EDIT2: Okay this change works in the main proc. if anyone is actually using this, replace the main code outside the proc with this:

if { [info exist boot_refresh] } {
set boot_refresh "refresh"
puts "Tivo reboot not adding event for nagkiller."
} else {
set boot_refresh "boot"
puts "Tivo boot. starting nagkiller."
nagkiller
}


I didn't think a variable set in a module was automatically global. I guess I just should have tried it.

jasch
05-01-2004, 01:19 AM
Will this work on a DTIVO S2? Probably not, but I am currently running a 2nd TIVO just as a player (I mfs_ftp programs to it), and I allways get the DVR SERVICE NEED TO BE ACTIVATED message...

Just asking...

cojonesdetoro
05-01-2004, 10:23 PM
Do you have tivoweb on there? Is the message a tivo mail message? Does it show up in the "Pre Tivo" section of the mail messages in tivoweb.

jasch
05-01-2004, 10:33 PM
Yes. It shows on pre-tivo central and the message board on TivoWeb..

jasch
05-01-2004, 10:39 PM
Tried the .itcl coded and I got:

nagkiller running at Sun May 2 01:32:36 UTC 2004
invalid command name "ForeachMfsFileTrans"
while executing
"ForeachMfsFileTrans fsid name type "/MessageItem/PreTivoCentral""
(procedure "nagkiller" line 8)
invoked from within
"nagkiller"
(file "./nagremove.itcl" line 26)

cojonesdetoro
05-02-2004, 11:11 PM
Tried the .itcl coded and I got:

nagkiller running at Sun May 2 01:32:36 UTC 2004
invalid command name "ForeachMfsFileTrans"
while executing
"ForeachMfsFileTrans fsid name type "/MessageItem/PreTivoCentral""
(procedure "nagkiller" line 8)
invoked from within
"nagkiller"
(file "./nagremove.itcl" line 26)

That's weird. ForeachMfsFileTrans is a function defined by Tivweb. Are you using tivoweb plus?

BTW, Even if we get everything working, you have to make sure you change the subject of the message that it's looking for so it will delete the one you want.

EDIT: Look in util.itcl in the main tivoweb directory. That's where that function is defined in TW+

jasch
05-03-2004, 12:29 AM
Yep. I running TWPv1.0, haven't changed anything (stock instalation)

backup
favicon
index
info
lj_utils
logos
logs
mail
mfsbrowser
nag
nagkiller running at Mon May 3 03:22:41 UTC 2004
NONE no value given for parameter "prefix" to "ForeachMfsFileTrans"
while executing
"ForeachMfsFileTrans fsid name type "/MessageItem/PreTivoCentral""
(procedure "nagkiller" line 8)
invoked from within
"nagkiller"
(file "/var/local/tivoweb-tcl/modules/nag.itcl" line 27)
invoked from within
"source $module "
phone
resources
sched
screen
search
theme
ui
webremote
whatson
Accepting Connections

cojonesdetoro
05-03-2004, 05:16 PM
Looks like a cut-n-paste problem. Make sure the script in your modules dir looks exactly like the one pasted here.

jasch
05-03-2004, 05:19 PM
Did it twice. CUT here, open teraterm, open Joe, and click ALT-R. After about 1-2 seconds (the time it takes for the script to be filled in), I hit save, chmod 755 and restart.

Anyway, I just subscribed the equipment, so there's no need for the nag remover anymore.

Thanks anyway for the help.

cojonesdetoro
12-28-2004, 08:13 PM
bump

new version. see top post.