Results 1 to 7 of 7

Thread: How to clear down recording history?

  1. #1
    Join Date
    Nov 2002
    Posts
    110

    How to clear down recording history?

    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?

  2. #2
    Join Date
    Nov 2002
    Posts
    110
    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?

  3. #3
    Join Date
    Jun 2003
    Posts
    591
    Dunno if this thread qualifies as "General Tivo Development" or not, but...

    Try this:

    Code:
    #!/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
    TCD652160 TivoHD
    1TB
    11.0m-01-2-652

  4. #4
    Join Date
    Oct 2003
    Location
    Charlottesville, VA
    Posts
    152
    aww, man, ya beat me to it! And here I was having fun making a user friendly script! :-)

    Code:
    #!/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...)
    Philips DSR7000 - ~200 hours, killhdinitrd'd 6.2a w/ NutKase's superpatch_67all

  5. #5
    Join Date
    Jun 2003
    Posts
    591
    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
    TCD652160 TivoHD
    1TB
    11.0m-01-2-652

  6. #6
    Join Date
    Nov 2002
    Posts
    110
    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!
    Last edited by mbriody; 04-08-2004 at 03:42 PM.

  7. #7
    Join Date
    Jun 2003
    Location
    Somerset, England
    Posts
    1,124
    Quote Originally Posted by rc3105
    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
    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).
    Stuart

    Newbies - see if your questions are answered here Experts - can you add to the knowledge stored here? Developers - are your hacks listed here?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •