PDA

View Full Version : How to clear down recording history?



mbriody
04-08-2004, 10:03 AM
I have over 800 entries in my recording history which I believe may be causing a problem with TivoWeb and one or more modules.

I've searched and cannot find any anything except EditTitle which claims to do the job but it doesn't seem to support SA's (I have a UK SA Series 1, 2.5.5).

Sanderton posted this code for me:

"This will wipe out you Recording History if you're feeling brave:

code:--------------------------------------------------------------------------------
#!/tvbin/tivosh

set db [dbopen]
ForeachMfsFile fsid name type "/Recording/History" "" {
RetryTransaction {
set item [db $db openid $fsid]
set state [dbobj $item get State]
if {$state == 2} {
dbobj $item MarkAsRubbish
}
}
}
dbclose $db
--------------------------------------------------------------------------------


(untested; may take a while to appear to do anything; running a daily call can provoke a grarbage collection if nothing happens, will probably reset the 28-day rule too) "

What I'd like is to be able to make this selective for say everything over X weeks or Y months. Is it possible by a mod to this code or is there another tool for the job?

mbriody
04-08-2004, 02:11 PM
Okay I tried this code but with the rubbish line commented out. Seems that a lot of entries are not returning valid dates. When I added some debug they came out as null strings. Here's the stat's:

Total records: 772
Invalid dates: 469
Rubbished : 250
Within date : 43
State <> 2 : 10

I browsed my history via TivoWeb's /mfs/Recording/History and noticed that a lot of entries do not have StartDate's in fact they have much truncated entries.

Here are the names of some of my history entries:

12411:76800:634669
12440:68400:664108
12457:66600:679167

etc.

Looking at these entries (which do have StartDates) the first 5 digits of the name are the same as the StartDate. Can anyone give me a code fragment that will give me access to the names above?

psxboy
04-08-2004, 02:23 PM
Dunno if this thread qualifies as "General Tivo Development" or not, but...

Try this:


#!/tvbin/tivosh

set weeks 2
set now [clock seconds]
set maxdate [expr $now - [expr $weeks * 604800]]
set db [dbopen]
ForeachMfsFile fsid name type "/Recording/History" "" {
set recdate [split $name ":"]
if {[expr [lindex $recdate 0] * 86400] < $maxdate} {
RetryTransaction {
set item [db $db openid $fsid]
set state [dbobj $item get State]
if {$state == 2} {
dbobj $item MarkAsRubbish
}
}
}
}
dbclose $db

Just change the "set weeks 2" to however many weeks prior to today's date you'd like to delete the history for.

-psxboy

drnull
04-08-2004, 02:35 PM
aww, man, ya beat me to it! And here I was having fun making a user friendly script! :-)



#!/tvbin/tivosh

source $tcl_library/tv/DbEnum.tcl


if {$argc == 0} {
puts "Usage: clearRec.tcl <daysAgo>"
puts " Cleans out recording history older than <daysAgo>"
exit -1
}

set now [clock seconds]
set ago [lindex $argv 0]

set deleteBefore [expr $now - $ago*86400]

set nowDate [clock format $now -format "%m/%d %I:%M%p"]
set agoDate [clock format $deleteBefore -format "%m/%d %I:%M%p"]

puts "Current TiVo Time: $nowDate"
puts "Deleting records older than $agoDate"

set db [dbopen]
ForeachMfsFile fsid name type "/Recording/History" "" {
RetryTransaction {
set recobj [db $db openid $fsid]
set state [dbobj $recobj get State]
set showobj [dbobj $recobj get Showing]
set date [dbobj $showobj get Date]
set time [dbobj $showobj get Time]
set time [expr $date*86400 + $time]

if {$time < $deleteBefore &&
$state == $RecordingState::Cancelled} {
## could also delete those that are Complete or Deleted?

set progobj [dbobj $showobj get Program]
set title [dbobj $progobj get Title]

set date [clock format $time -format "%m/%d %I:%M%p"]

puts "$state: $date: $title"
dbobj $recobj markasrubbish
}
}
}

dbclose $db


By the way, the command is markasrubbish lower cased... My tivo didn't like MarkAsRubbish. Who knows.

Also, I used the time off of the showing object. Not real sure what the difference in time would be between that and the recording itself (except maybe for padding...)

psxboy
04-08-2004, 03:27 PM
Well... user-friendly is always preferable over quick & dirty. I just figured since the original code was quick & dirty I'd stick with that theme. ;) And I make no claims as to the correct case of the "markasrubbish" line... I tested the logic without the payload. Didn't want to actually clear my history.

-psxboy

mbriody
04-08-2004, 03:34 PM
Thanks.

I'm running a slight variant on what you posted but it seems to have no effect. I've forced a Daily Call but it doesn't seem to have done a garbage collect. Is there a way to force one?

[LATER]

Changed the rubbish command to lower case and it appears to have done the trick.

Thanks all!

sanderton
04-09-2004, 06:07 AM
this type functionality would make a good addition to the tivoweb recording history module

for example, the ability to selectively remove episode(s)

one word of caution, carefull you don't you nuke anything in the history that's still in NowPlaying :eek:

That's why I put the State == 2 check in, but History shouldn't include current recordings.

More useful would be TW module to do the same thing but for /Recording/NoReRecord which would lift the 28 day rule ban on a selected recording (in theory).