# reorder.itcl # Re-order SPS in TiVoWEB # Version 1.1 # 23/11/03 # by Stuart Anderton (sanderton at tivocommunity.com) # USE ONLY IF YOU HAVE BACKED UP YOUR SPs # Thanks to Jeff Howden for the original JavaScript proc action_roupdatesps {chan path env} { global db puts $chan [html_start "Reorder SPs"] regsub -all {set "id_list" } $env {lappend splist } newenv eval $newenv set currsplist [rogetsplist] set scurrsplist [lsort $currsplist] set ssplist [lsort $splist] set index 0 if {[llength $currsplist] == [llength $splist]} { foreach fsid $ssplist { if {[lindex $fsid 0] != [lindex [lindex $scurrsplist $index] 0]} { puts $chan "Error

" puts $chan "Mismatch between submitted and existing SP lists. Perhaps someone has edited the list on the TiVo? Your SP order has not beed updated." puts $chan [html_end] return 0 } incr index } } else { puts $chan "Error

" puts $chan "Mismatch between submitted and existing SP lists. Perhaps someone has edited the list on the TiVo? Your SP order has not beed updated." puts $chan [html_end] return 0 } set index 0 foreach fsid $splist { RetryTransaction { set sp [db $db openid $fsid] dbobj $sp set Priority $index } incr index } puts $chan "Season Pass reorder complete

" puts $chan "It may take a few minutes for the To Do List to be rebuilt." puts $chan [html_end] } proc rogetsplist {} { global db global tzoffset global seasonpassdir set splist {} ForeachMfsFile fsid name type $seasonpassdir "" { set series {} set theme {} RetryTransaction { set sp [db $db openid $fsid] set station [dbobj $sp get Station] set series [dbobj $sp get Series] set theme [dbobj $sp get Theme] if {$series != ""} { set callsign [dbobj $station get CallSign] set name [dbobj $series get Title] } elseif { $theme != ""} { set callsign {} set name [dbobj $theme get Name] } else { set starttime [dbobj $sp get StartTimeLocal] if {$starttime != ""} { set callsign [dbobj $station get CallSign] set name "Repeat manual recording, starting [clock format [expr $starttime +$tzoffset] -format %R]" } else { set callsign {} set name "Unidentified SP" } } } set item {} lappend item [strim $fsid] lappend item [strim $name] lappend item $callsign lappend splist $item } return $splist } proc action_reorder {chan path env} { global url_prefix set splist [rogetsplist] puts $chan [html_start "Reorder SPs"] puts $chan "" puts $chan {

} puts $chan {} puts $chan {} puts $chan {" puts $chan {} puts $chan {} puts $chan {} puts $chan {} puts $chan {} puts $chan {} puts $chan {} puts $chan {} puts $chan {} puts $chan {
Reorder Season Passes
} puts $chan {
} puts $chan "Be sure to have a current [html_link "/backup/" "backup"]
" puts $chan "of your SPs before using." puts $chan [html_end] } register_module "reorder" "Reorder SPs" "Reorder SP list"