#!/tvbin/tivosh # # Remap HDTV locals for Zenith DTT900 # # Mapping of station call sign to DTV channel number set cmap(WMARDT) 22 set cmap(WMARDT3) 23 set cmap(WBALDT) 111 set cmap(WBALDT2) 112 set cmap(WJZDT) 131 set cmap(WMPT) 221 set cmap(WMPTDT2) 222 set cmap(WMPTDT3) 223 set cmap(WUTBDT) 241 set cmap(WBFFDT) 451 set cmap(WBFFDT2) 452 set cmap(WNUVDT) 541 # Mapping of signal type number to name set signaltypes [list "Unknown" "Antenna" "Cable" "DBS" "ATSC" "CableBox" "DirecTV" "LineInput"] # Only modify the source with the CableBox SignalType set signaltype 5 # # Iterate over all channels in the source, looking for call signs listed # in cmap. # proc map_channels {db fsid subobjid header} { global cmap set i 0 set printed 0 while {1} { RetryTransaction { set source [db $db openidconstruction $fsid $subobjid] set channels [dbobj $source get Channel] set nchannels [llength $channels] # Do at most 25 channels per transaction so we don't overflow set end [expr $i + 25] if {$end > $nchannels} { set end $nchannels } while {$i < $end} { set channel [lindex $channels $i] set cnumber [dbobj $channel get Number] set station [dbobj $channel get Station] set callsign [dbobj $station get CallSign] foreach cs [array names cmap] { if {$cs == $callsign} { if {$cnumber != $cmap($cs)} { if {!$printed} { puts "$header" set printed 1 } puts "\t$callsign $cnumber -> $cmap($cs)" dbobj $channel set Number $cmap($cs) } } } incr i } } if {$i == $nchannels} { break } } } set db [dbopen] set source_id 0 RetryTransaction { set setup [db $db open /Setup] foreach source [dbobj $setup get Source] { # Find the index of the source with the CableBox SignalType set type [dbobj $source get SignalType] if {$type == $signaltype} { set source_id [dbobj $source fsid] set source_subobjid [dbobj $source subobjid] break } set typename [lindex $signaltypes $type] puts "skipping source with SignalType $typename" } } if {!$source_id} { puts "unable to find cable box signal source" dbclose $db exit 1 } # First, update the current lineup set lineups {} set nlineups 0 RetryTransaction { set source [db $db openidconstruction $source_id $source_subobjid] set lineup_type [dbobj $source get LineupType] set headend [dbobj $source get Headend] foreach lineup [dbobj $headend get Lineup] { # Find the current lineup set type [dbobj $lineup get Type] if {$type <= $lineup_type} { lappend lineups [dbobj $lineup get Name] lappend lineups [dbobj $lineup fsid] lappend lineups [dbobj $lineup subobjid] incr nlineups } } } if {[llength $lineups] == 0} { puts "Unable to locate current lineup" dbclose $db exit 1 } for {set i 0} {$i < $nlineups} {incr i} { set name [lindex $lineups [expr $i * 3]] set fsid [lindex $lineups [expr $i * 3 + 1]] set subobjid [lindex $lineups [expr $i * 3 + 2]] map_channels $db $fsid $subobjid "Updating lineup $name" } # Finally, update the active channel list map_channels $db $source_id $source_subobjid "Updating active channel list" dbclose $db exit 0