variable compat "2.1.b3"
# 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
foreach {k v} $env {
if {$k=="id_list"} {lappend splist $v}
}
eval_env
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."
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."
return 0
}
set index 0
foreach fsid $splist {
RetryTransaction {
set sp [db $db openid $fsid]
dbobj $sp set Priority $index
}
incr index
}
puts $chan [bodytext_start]
puts $chan "Season Pass reorder complete
"
puts $chan "It may take a few minutes for the To Do List to be rebuilt."
puts $chan [bodytext_end]
}
proc rogetsplist {} {
global db
global tzoffset
global seasonpassdir
set splist {}
RetryTransaction {
set spcount [mfs scancount $seasonpassdir]
}
ForeachMfsFile fsid name type $seasonpassdir "" $spcount {
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 {$station == ""} {
set callsign ""
} else {
set callsign [dbobj $station get CallSign]
}
if {$series != ""} {
set name [dbobj $series get Title]
} elseif { $theme != ""} {
set name [dbobj $theme get Name]
} else {
set starttime [dbobj $sp get StartTimeLocal]
if {$starttime != ""} {
set name "Repeat manual recording, starting [clock format [expr $starttime +$tzoffset] -format %R]"
} else {
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} {
set splist [rogetsplist]
puts $chan [html_start "Reorder SPs"]
#~ puts $chan ""
js reorder
puts $chan "