# TivoWebPlus ## MelvinPurvis ## Wishlist operations used a hard coded table of names and category ID associations to form ## searches. This cannot take into account the variable attributes supported by different ## versions of the software and hardware. For example, Wishlist specifications for HDTV made ## in the real Tivo UI could not be displayed properly. ## Added code to auto-generate the javascript file genericgenre.js from the internal genre ## tables. This should make the options track whatever the tivo software supports. ## Applied that table only to the dtivo case because I cannot test the others. It should work ## for the SA versions, but the UK case looks like the category range is different, so ## changes would be required. ## Wishlist items are parsed into an http URL with parameters before being forwarded to the ## search module. The extraction of the query parameter was done from name of the wishlist. ## This method looked for an ampersand and assumed that the first such instance represented ## the boundary between the cat/scat part and the parameter. For categories such as ## "Audio & Video" this is manifestly untrue. Changed the handling to pick up the parameter ## from the appropriate db field based on the type of search (actor, director, keyword, etc.) ## added additional global indexes identifying critical genre values ## (supporting additional higuide functionality), ## performing the necessary indirection at initialization so that values of interest can be ## identified without searching. ## added lists of image file names for ustv and mpaa ratings ## action_channel modified by SteveT to retrieve and show some channel descriptive information ## added missing episode descriptions in conflicts, etc. ## numerous small formatting changes to improve appearance ## lgkahn grouping implemented for >=4 software 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} { 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 "4 5" [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 } 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 } 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 } else { set names $namestr } 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 mi last] } { if { $str == "" } { set str "{$last|$first $mi}" } else { set str "$str, {$last|$first $mi}" } } } elseif { $numspcs == 3 } { if { [regexp {(.*)_(.*)_(.*)_(.*)} $name junk first mi mii last] } { if { $str == "" } { set str "{$last|$first $mi $mii}" } else { set str "$str, {$last|$first $mi $mii}" } } } } set names $str regsub -all {,} $names " " names return $names } proc get_verbose_title { program episodic mrgeptitlenum } { # Non episodic programmes - return "Not An Episode" # No episode number or title - return "No Episode Title" # Episode number only - return "ep xxx" # Title only - return title no quotes, see comments above. # Episode number and title - return "ep xxx, " if { $episodic == 1 } { set epnumraw [strim [dbobj $program get EpisodeNum]] set epnumstring "" set eptitle "" if { $epnumraw != "" } { append epnumstring "Episode " $epnumraw } set eptitleraw [strim [dbobj $program get EpisodeTitle]] if { $eptitleraw != "" } { if { $epnumstring != "" } { # title and number if { $mrgeptitlenum == 1 } { append eptitle $epnumstring ", " $eptitleraw } else { append eptitle $eptitleraw } } else { # title but no number append eptitle $eptitleraw } } else { if { $epnumstring != "" } { # no title, but a number. Better than nothing. set eptitle $epnumstring } else { # no title or number! set eptitle "No Episode Title" } } } else { # not an episode - film (movie), one-off broadcast, or IsEp false series # shortened -- SteveT # set eptitle "Not an Episode--Program Info" set eptitle "Not an Episode" } return $eptitle } proc CreateHover { hovertext } { set hoverret "" if { $::description_hover && $hovertext != "" } { set hovertext [htmlEncode $hovertext] regsub -all {\"} $hovertext {\"} hovertext set hoverret "title=\"$hovertext\"" } else { set hoverret "" } return $hoverret } proc action_channellist {chan type env} { global channeltablestation channeltablenum global channeltablestation_alt channeltablenum_alt 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"]]] if { $::lang == "en" } { puts $chan [tr "" [td [html_link "/channellist/3" "Favourite"]]] } else { 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 } { set channelnumlist "[array names channeltablenum] [array names channeltablenum_alt]" } else { set channelnumlist [array names channeltablenum] } foreach channum [lsort -real $channelnumlist] { if { ([catch {set stationfsid $channeltablenum($channum)}] != 1 || [catch {set stationfsid $channeltablenum_alt($channum)}] != 1) && ([catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1) } { set favorite [lindex $data 1] if { $type == "3" && $favorite == 0 } { continue } set channum [join [split $channum .] -] 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 global channeltablestation_alt global logotableindex logotablename global cache_sp_fsid cache_sp_key global signaltypes if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Channel"] if { [catch {set data $channeltablestation($objectid)}] != 1 || [catch {set data $channeltablestation_alt($objectid)}] != 1 } { set channum [join [split [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"] ## section added to populate channel information table -- SteveT set favorite [lindex $data 1] if {$favorite == 1 } { set fav "Yes" } else { set fav "No" } set channel [lindex $data 5] set signaltype [lindex $data 6] # set signaltype description. list copied from tvlib/tcl/tv/DbEnum.tcl array set signaltypes [list 0 Unknown 1 Rooftop 2 Cable 3 DBS 4 ATSC 5 CableBox 6 DirecTV 7 LineInput ] if { [info exists signaltypes($signaltype)] } { set signaltypedesc $signaltypes($signaltype) } else { set signaltypedesc "unknown" } # deduce rcv flag based on which table channel is in set rcv "Yes" if { [catch {set dummy $channeltablestation($objectid)}] == 1 } { set rcv "No" } # build html string set channel_info_html "<small>Receive= <b><i>$rcv</b></i><br>Favorite= <b><i>$fav</i></b><br> \ SignalType= <b><i>$signaltype ($signaltypedesc)</i></b></small>" set chandesc "" set apgchannel "" set sat_info_html "" set chandesc_html "" regexp {([0-9]*)/(.*)} $channel junk channelid channelsubid RetryTransaction { catch { set channelobj [db $db openidconstruction $channelid $channelsubid] } catch { set apgchannel [dbobj $channelobj get ApgChannel] } if { $apgchannel != "" } { set chandesc [strim [dbobj $apgchannel get AboutText]] set chandesc_html "<small><small>$chandesc</small></small>" set chandef [dbobj $apgchannel get ChannelDefinition] set frameheader [dbobj $apgchannel get "FrameHeaderNetworkId"] # set descriptions for known satellites if {$frameheader == 0 } { set sat_text "Sat A (101)" } elseif {$frameheader == 2} { set sat_text "Sat C (110)" } elseif {$frameheader == 3} { set sat_text "Sat B (119)" } else { set sat_text $frameheader } set transponder [dbobj $chandef get "FrequencyIndex"] incr transponder set numstreams [dbobj $chandef get NumberOfStreams] set apgservicetype [dbobj $chandef get ServiceType] ## lists copied from tvlib/tcl/tv/DbEnum.tcl array set apgservicetypes [ list \ 1 AnalogTv 3 AtscAudio 4 AtscBroadcastData 2 AtscDigitalTv 70 DirecTvAc3Audio \ 65 DirecTvAudio 64 DirecTvDigitalTv 69 DirecTvHdDigitalTv 66 DirecTvHsData \ 67 DirecTvLsData 68 DirecTvMulticastIp 0 HttpOnly "" "no value"] if { [info exists apgservicetypes($apgservicetype)] } { set astdesc $apgservicetypes($apgservicetype) } else { set astdesc "unknown" } set apgspi [dbobj $chandef get Spi] array set apgspis [ list 13 ContinuousData 12 GeneralAudio 1 Gtv 9 GtvAc3 8 GtvAc3Davis \ 3 GtvCd 7 GtvDavis 5 GtvSd 16 HdtvAc3 15 HighSpeedData 0 HttpOnly 2 Ltv 10 LtvAc3 \ 4 LtvCd 11 LtvDavis 6 LtvSd 14 SessionData 127 StreamLanguageDescriptorList \ 126 StreamLanguageList 125 StreamList 124 Terrestrial "" "no value" ] if { [info exists apgspis($apgspi)] } { set spidesc $apgspis($apgspi) } else { set spidesc "unknown" } set apgstreamtype [dbobj $chandef get StreamType] array set apgstreamtypes [ list 200 Ac3Audio 198 ApgData 129 AtscA53Audio 193 Bhsd \ 195 ContinuousData 192 Davis 197 HdVideoPes 196 Hsd 199 MulticastIp 194 SessionData \ 3 StandardAudio 2 StandardVideo 0 Unknown 201 Wink "" "no value" ] if { [info exists apgstreamtypes($apgstreamtype)] } { set asttdesc $apgstreamtypes($apgstreamtype) } else { set asttdesc "unknown" } set sat_info_html "<small><br>NetworkID= <b><i>$sat_text</b></i><br>Transponder= <b><i>$transponder</b></i><br> \ NumStreams= <b><i>$numstreams</b></i>" set sat_info_html "$sat_info_html<br>ServiceType= <b><i>$apgservicetype ($astdesc)</b></i>" set sat_info_html "$sat_info_html<br>Spi= <b><i>$apgspi ($spidesc)</b></i>" set sat_info_html "$sat_info_html<br>StreamType= <b><i>$apgstreamtype ($asttdesc)</b></i></small>" } } puts $chan [html_table_start "width=96%" "Channel Information" "COLSPAN=3"] puts $chan [td "width=32%" $channel_info_html$sat_info_html] puts $chan [td "width=32% align=center" [h1 "$logostr $channum $callsign"]] puts $chan [td "width=32%" $chandesc_html] puts $chan [html_table_end] ## end of added section -- SteveT puts -nonewline $chan [html_link "/listings/$objectid" "View Upcoming Listings"] puts $chan "<P>" } else { puts $chan "<B>Error: Unknown Station '$objectid'</B><P>" } 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 "<p>(no season passes for this channel)" } puts $chan [html_end] } proc action_listings {chan path env} { global db global channeltablestation global channeltablestation_alt 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 || [catch {set data $channeltablestation_alt($stationid)}] != 1 } { set channum [join [split [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 "<B>Error: Unknown Station '$stationid'</B>" 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 "width=5" " "] [th "Day"] [th "width=10" " "] [th "Week"] [th "width=5" " "]] for {set i $minseconds} {$i <= $maxseconds} {incr i 86400} { if {$::lang == "en"} { set timestr [clock format $i -format "%a [nth_sup [clock format $i -format "%e"]] %b"] set weekstr "$timestr - [clock format $i -format "%a [nth_sup [clock format [expr $i+6*86400 < $maxseconds ? $i+6*86400 : $maxseconds] -format "%e"]] %b"]" } else { set timestr [clock format $i -format "%a %1m/%1d"] set weekstr "$timestr - [clock format [expr $i+6*86400 < $maxseconds ? $i+6*86400 : $maxseconds] -format "%a %1m/%1d"]" } puts $chan [tr "" [td " "] [td "align=center" [html_link "/listings/$stationid/$i" $timestr]] [td " "] [td "align=center" [html_link "/listings/$stationid/$i/1" $weekstr]] [td " "]] } puts -nonewline $chan [html_table_end] puts $chan "<P>" } else { set firstslash [string first "/" $seconds] if { $firstslash != -1 } { set week [defaultval 0 [string index $seconds [expr $firstslash + 1]]] set seconds [string range $seconds 0 [expr $firstslash - 1]] } else { set week 0 } set lastdayseconds [expr $week ? $seconds + 86400*6 : $seconds] set startsecs $seconds set firstday 1 set lastday 0 for {} {$startsecs <= $lastdayseconds && !$lastday } {incr startsecs 86400} { set day [expr $startsecs / 86400] set endsecs [expr $startsecs + 86400] if {$::lang == "en"} { set daystr [nth_sup [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 ""] [th "Time"] [th "Series"] [th "Episode"]] ForeachMfsFile fsid name type "/Schedule" "$stationid:$day:" { if {[catch [do_listingsrow $chan $fsid $startsecs $endsecs $stationid] error]} { puts "do_listingrow $fsid $startsecs $endsecs" puts "$error" } if { $startsecs == $seconds } { set firstday 0 } } incr day set lastday 1 ForeachMfsFile fsid name type "/Schedule" "$stationid:$day:" { if {[catch [do_listingsrow $chan $fsid $startsecs $endsecs $stationid] error]} { puts "do_listingrow $fsid $startsecs $endsecs" puts "$error" } set lastday 0 } puts -nonewline $chan [html_table_end] } puts $chan "<P>" set yesterday [expr $seconds - 86400] set tommorow [expr $startsecs] if {$::lang == "en"} { set daystr [nth_sup [clock format $yesterday -format "%e"]] set timestr [clock format $yesterday -format "%a $daystr %b"] set daystr [nth_sup [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 stationfsid} { global db global images 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]] set tzoffset [get_tzoffset $secs] if { ($secs + $tzoffset) >= $startsecs && ($secs + $tzoffset) < $endsecs } { if {$::lang == "en"} { set timestr [ftime $secs "%H:%M"] } else { set timestr [ftime $secs "%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 0 } set title [strim [dbobj $program get Title]] set eptitle [get_verbose_title $program $episodic 0] set description [strim [dbobj $program get Description]] set originalairdate [dbobj $program get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set hovertext "($airdatestr) $description" } else { set hovertext $description } set attrs [CreateHover $hovertext] if { $partcount != "" && $partindex != "" } { append eptitle " ($partindex/$partcount)" } if { $seriesfsid != "" } { set title [html_link "/series/$seriesfsid" $title] } #LJ show recording icons set imagenum -1 set today [clock seconds] if { $secs >= $today } { set date [expr $secs / 86400] set prgtime [expr ($secs - ($date * 86400))] set recfsid [lindex [get_fsidbyprefix "/Recording/Active" "4:$date:[string range "0000$prgtime" [expr [string length "$prgtime"] - 1] end]:"] 0] } else { set recfsid "" } 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 state [dbobj $rec get State] if {$state == 4} { set imagenum 3 } elseif {$state == 5} { set imagenum 20 } elseif {$state == 3} { set imagenum 8 # incr reccount 1 } elseif {$state == 6} { if {$::version3} { set recbeh [dbobj $rec get RecordingBehavior] set seltype [dbobj $recbeh get PresentationBehavior] if {$seltype == 6} { set imagenum 10 # incr reccount 1 } elseif {$seltype == 2} { set imagenum 11 # incr reccount 1 } elseif {$seltype == 3} { set imagenum 13 # incr reccount 1 } else { set imagenum 1 # incr reccount 1 } } else { set seltype [dbobj $rec get SelectionType] if {$seltype == 6} { set imagenum 10 # incr reccount 1 } elseif {$seltype == 9} { set imagenum 11 # incr reccount 1 } elseif {$seltype == 13} { set imagenum 13 # incr reccount 1 } else { set imagenum 1 # incr reccount 1 } } } } } if {$imagenum >= 0} { set imagef [lindex $images $imagenum] if { $imagenum == 20 } { set imageh [html_link "/confirmdelete/3/$recfsid" "[img "align=absmiddle" $imagef]" "title=\"Click to undelete\""] } else { set imageh [img "align=absmiddle" $imagef] } } else { if { $secs > [clock seconds] && [string first ">SIGN OFF</" $title] == -1 } { set duration [dbobj $showing get Duration] set imageh "[slotfree $secs $duration $chan] " } else { set imageh " " } } ## added desc_show -- SteveT puts $chan [tr "" [td $imageh] [td $timestr] [td $title] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]]] } } } } } ## Returns formatted desctext based on DescriptionShow setting -- added by SteveT proc desc_show {inp_desc} { if { $::description_show == 1 && $inp_desc != "" } { set desctext [htmlEncode $inp_desc] regsub -all {\"} $desctext {\"} desctext set desctext " <small><small>$desctext</small></small>" } else { set desctext "" } return $desctext } proc action_saveprogram {chan path env} { global db eval $env RetryTransaction { set rec [db $db openid $objectid] set seltype [dbobj $rec get SelectionType] } if {$seltype == 6 || $seltype == 9} { set newseltype 3 } else { set newseltype $seltype } # updaterec $objectid $title $eptitle $description $sul $newseltype $actorstr $gueststarstr $directorstr $execproducerstr $producerstr $writerstr $origairdate $episodenum $altepisodenum $manrec $isepisode $origisepisode $ismovie $origismovie $movieyear updaterec $objectid $title $eptitle $description $sul $newseltype $actorstr $gueststarstr $directorstr $execproducerstr $producerstr $writerstr $origairdate $episodenum $altepisodenum $manrec $isepisode $origisepisode $ismovie $origismovie $movieyear $tvrating $mpaarating $showingdate $grouptitle $groupwith $origtitle if { $origmanrec != $manrec || $origisepisode != $isepisode || $origismovie != $ismovie } { action_editprogram $chan $objectid "" } else { puts $chan [html_start "Edit Program"] puts $chan "<B>Program Updated Successfully</B><P>" puts $chan [html_link "/nowshowing" "Return to Now Playing"] puts $chan [html_end] } } proc action_editprogram {chan objectid env} { global db global mpaaratingnums mpaaratingvals global tvratingnums tvratingvals if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } puts $chan [html_start "Edit Program"] if {$::version >= 4} { # cant nest transactions so cache list for select lgk set txt "" ForeachMfsFile fsid21 namea type21 "/Recording/NowShowingByClassic" "" { RetryTransaction { set obj21 [db $db openidconstruction $fsid21] set showing21 [dbobj $obj21 get Showing] set program21 [dbobj $showing21 get Program] set name21 [strim [dbobj $program21 get Title]] set txt [concat $txt "<option value=\"$fsid21\">$name21</option>\r"] } } } RetryTransaction { set rec [db $db openid $objectid] set showing [dbobj $rec get Showing] try {set actualshowing [dbobj $rec get ActualShowing]} catch errCode { set actualshowing "" } if { $actualshowing == "" } { set showing [dbobj $rec get Showing] set actualshowing [dbobj $rec set ActualShowing $showing] } set actualshowing [lindex [dbobj $rec get ActualShowing] 0] set actualprog [dbobj $actualshowing get Program] set mpaarate [dbobj $actualprog get MpaaRating] set tvrate [dbobj $actualprog get TvRating] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set description [strim [dbobj $program get Description]] set series [dbobj $program get Series] set seriesfsid "" set thumbs "" if { $series != "" } { set seriesfsid [dbobj $series fsid] } #set isepisode [dbobj $program get IsEpisode] if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] } else { set episodic 0 } set eptitle [get_verbose_title $program $episodic 0] if { $episodic == 1 } { set episodenum [dbobj $program get EpisodeNum] set altepisodenum [dbobj $program get AltEpisodeNum] } else { set episodenum "" set altepisodenum "" } set tmstype 1 set tmsid [dbobj $program get TmsId] if { [string range $tmsid 0 1] == "MV" } { set tmstype 0 } if { $tmstype == 1 } { # Is Not a Movie set ismovie 0 set movieyear "" } else { # Is a Movie set ismovie 1 set movieyear [dbobj $program get MovieYear] } set seltype [dbobj $rec get SelectionType] set showingdate [dbobj $showing get Date] set showingtime [dbobj $showing get Time] set showingsecs [expr $showingdate * 86400 + $showingtime] set expdate [dbobj $rec get ExpirationDate] set expsecs [expr $expdate * 86400 + [dbobj $rec get ExpirationTime]] set nowsecs [clock seconds] set nowdate [expr $nowsecs / 86400] set nowtime [expr $nowsecs % 86400] set sulvals "[expr 24855 * 86400] 0" set sullabs "{Until I delete} {Expired}" set secs [expr $nowdate * 86400 + $showingtime] if {$secs < $nowsecs} { incr secs 86400 } for {set i 1} {$i <= 7} {incr i} { if {$::lang == "en"} { set daystr [nth_sup [ftime $secs "%e"]] set timestr [ftime $secs "%a $daystr %b %H:%M"] } else { set timestr [ftime $secs "%a %1m/%1d %l:%M %P"] } lappend sulvals $secs lappend sullabs $timestr incr secs 86400 } set sul "" if {$expdate == 24855} { # Record is set for save until I delete. set sul [expr 24855 * 86400] } elseif {$expsecs < $nowsecs} { set sul 0 } else { foreach secs [lrange $sulvals 2 end] { if {$secs < $nowsecs} { set sul $secs } } } if {$sul == ""} { set sul [lindex $sulvals end] } 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 } { set manrec 1 } else { set manrec 0 } } else { if { $seltype == 10 || $seltype == 5 } { set manrec 1 } else { set manrec 0 } } } set manrecvals "0 1" set manreclabs "{Normal Recording} {Manual Recording}" set epivals "0 1" set epilabs "{Not an Episode} {Episode}" set movievals "0 1" set movielabs "{Not a Movie} {Movie}" set origairdate [dbobj $program get OriginalAirDate] if { $origairdate != "" } { set origairdatesecs [expr $origairdate * 86400] if {$::lang == "en"} { set airdatestr [clock format $origairdatesecs -format "%e %b %Y"] } else { set airdatestr [clock format $origairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } # lgk new formatting of ashowingdatestr if { $showingdate != "" } { # set origairdatesecs [expr $origairdate * 86400] # secs already in showingsecs set ashowingdatestr [clock format $showingsecs -format "%e %b %Y"] } else { set ashowingdatestr "" } 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" "name=\"programedit\""] 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]]] #lgk hidden orig title puts $chan "<input type=hidden name=origtitle value=\"$title\">" #lgk end hidden orig title puts $chan [html_form_hidden "origmanrec" $manrec] puts $chan [html_form_hidden "origisepisode" $episodic] puts $chan [html_form_hidden "origismovie" $ismovie] puts $chan [tr "" [td ""] [td [html_form_select "manrec" $manrecvals $manreclabs $manrec "onchange=\"document.programedit.submit()\""][html_form_select "isepisode" $epivals $epilabs $episodic "onchange=\"document.programedit.submit()\""][html_form_select "ismovie" $movievals $movielabs $ismovie "onchange=\"document.programedit.submit()\""]]] if { $episodic == 1 } { puts $chan [tr "" [td "Episode Title"] [td [html_form_text 1 40 "eptitle" $eptitle]]] puts $chan [tr "" [td "Episode Description"] [td [html_form_text 3 40 "description" $description]]] puts $chan [tr "" [td "Episode #/Alt Episode #"] [td [html_form_text 1 10 "episodenum" $episodenum][html_form_text 1 10 "altepisodenum" $altepisodenum]]] puts $chan [html_form_hidden "movieyear" ""] } else { if { $ismovie == 1 } { puts $chan [tr "" [td "Movie Year"] [td [html_form_text 1 4 "movieyear" $movieyear]]] puts $chan [html_form_hidden "eptitle" ""] puts $chan [html_form_hidden "episodenum" ""] puts $chan [html_form_hidden "altepisodenum" ""] } else { puts $chan [html_form_hidden "eptitle" ""] puts $chan [html_form_hidden "movieyear" ""] puts $chan [html_form_hidden "episodenum" ""] puts $chan [html_form_hidden "altepisodenum" ""] } puts $chan [tr "" [td "Description"] [td [html_form_text 3 40 "description" $description]]] } puts $chan [tr "" [td "Original Air Date"] [td [html_form_text 1 10 "origairdate" $airdatestr]]] puts $chan [tr "" [td "Showing Date"] [td [html_form_text 1 10 "showingdate" $ashowingdatestr]]] 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]]] #lgk do rating block here if { $tvrate != "" } { puts $chan "<tr><td>TV Rating</td>" puts $chan "<Td><select name=\"tvrating\">" if {$tvrate == "0"} {set selected "SELECTED"} else {set selected ""} puts $chan "<option value=\"0\" $selected>None</option>" for {set i 0} {$i < [llength $tvratingnums]} {incr i} { set num [lindex $tvratingnums $i] set val [lindex $tvratingvals $i] if {$tvrate == $num} {set selected "SELECTED"} else {set selected ""} puts $chan "<option value=\"$num\" $selected>$val</option>" } puts $chan "</select><input type=hidden name=mpaarating value=\"\"></td></tr>" } elseif {$mpaarate != ""} { puts $chan "<tr><td>Movie Rating</td>" puts $chan "<Td><select name=\"mpaarating\">" if {$mpaarate == "0"} {set selected "SELECTED"} else {set selected ""} puts $chan "<option value=\"0\" $selected>None</option>" for {set i 0} {$i < [llength $mpaaratingnums]} {incr i} { set num [lindex $mpaaratingnums $i] set val [lindex $mpaaratingvals $i] if {$mpaarate == $num} {set selected "SELECTED"} else {set selected ""} puts $chan "<option value=\"$num\" $selected>$val</option>" } puts $chan "</select><input type=hidden name=tvrating value=\"\"></td></tr>" } else { puts $chan "<input type=hidden name=mpaarating value=\"\">" puts $chan "<input type=hidden name=tvrating value=\"\">" } if {$::version >= 4} { # lgk do grouping checkbox and list and group title here puts $chan "<tr><td>Group Title</td>" puts $chan "<td><input type=text name=grouptitle value=\"\"></td>" puts $chan "</tr>" puts $chan "<tr><td>Group With</td>" puts $chan "<Td><select name=\"groupwith\">" puts $chan "<option value=\"0\" SELECTED>None</option>" puts $chan "$txt" puts $chan "</select></td></tr>" } else { puts $chan "<input type=hidden name=grouptitle value=\"\">" puts $chan "<input type=hidden name=groupwith value=\"0\">" } puts $chan [html_table_end] puts $chan [html_form_input "submit" "Save" "Save"] puts $chan [html_form_end] puts $chan "<P>" puts $chan [html_link "javascript:history.go(-1)" "Cancel"] } puts $chan [html_end] } proc updaterec { id newtitle neweptitle newdesc newexpsecs newseltype newactorstr newgueststarstr newdirectorstr newexecproducerstr newproducerstr newwriterstr neworigairdate newepisodenum newaltepisodenum newmanrec newisepisode origisepisode newismovie origismovie newmovieyear tvrating mpaarating newshowingdate grouptitle groupwith origtitle} { global db RetryTransaction { set rec [db $db openid $id] set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] # set actualshowing [dbobj $rec get ActualShowing] set actualshowing [lindex [dbobj $rec get ActualShowing] 0] set actualprog [dbobj $actualshowing get Program] if { $tvrating != "" } { dbobj $actualprog set TvRating $tvrating } elseif { $mpaarating != "" } { dbobj $actualprog set MpaaRating $mpaarating } # lgk set new field showingdate # set showingdate [dbobj $showing get Date] # set origairdatesecs [ clock scan $neworigairdate ] # set originalairdate [ expr $origairdatesecs / 86400 ] # dbobj $program set OriginalAirDate $originalairdate set origshowingdatesecs [ clock scan $newshowingdate ] set originalshowingdate [ expr $origshowingdatesecs / 86400 ] dbobj $showing set Date $originalshowingdate 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 series [dbobj $program get Series] if {$series != ""} { dbobj $series set Episodic $newisepisode } # clear EpisodeTitle, set IsEpisode=0 if { $newisepisode == 0 && $neweptitle == ""} { dbobj $newpobj remove EpisodeTitle dbobj $newpobj set IsEpisode 0 } # end of clear episode title if { $newisepisode == 1 && $origisepisode == 1 } { dbobj $newpobj set EpisodeTitle $neweptitle if { $newepisodenum != "" } { dbobj $newpobj set EpisodeNum $newepisodenum } else { dbobj $newpobj set EpisodeNum 0 } if { $newaltepisodenum != "" } { dbobj $newpobj set EpisodeNum $newaltepisodenum } else { dbobj $newpobj set AltEpisodeNum 0 } } #lgk set isepisode episodetitle and reset title in both showing and actualshowing if grouping stuff set #also check that the groupwith has a series already # only go in code of groupwith != 0 if {$groupwith != 0 } { set rec2 [db $db openid $groupwith] set showing2 [dbobj $rec2 get Showing] set program2 [dbobj $showing2 get Program] # set actualshowing2 [dbobj $rec2 get ActualShowing] set actualshowing2 [lindex [dbobj $rec get ActualShowing] 0] set actualprog2 [dbobj $actualshowing2 get Program] #only reset titles if orig is not an episode if it is already an episode leave titles but regroup #also only do this if the groupwith object has a series under showing/program/series try {set series2 [dbobj $program2 get Series]} catch errCode { set series2 "" } if {$series2 != "" && $grouptitle != "" } { if { $origisepisode == 0 } { dbobj $program set Title $grouptitle dbobj $program set EpisodeTitle $origtitle dbobj $program set IsEpisode 1 dbobj $actualprog set Title $grouptitle dbobj $actualprog set EpisodeTitle $origtitle dbobj $actualprog set IsEpisode 1 dbobj $program2 set Title $grouptitle dbobj $program2 set IsEpisode 1 dbobj $actualprog2 set Title $grouptitle dbobj $actualprog2 set IsEpisode 1 # now copy series to object dbobj $program set Series $series2 dbobj $actualprog set Series $series2 } else { dbobj $program set Title $grouptitle dbobj $program set EpisodeTitle $neweptitle dbobj $program set IsEpisode 1 dbobj $actualprog set Title $grouptitle dbobj $actualprog set EpisodeTitle $neweptitle dbobj $actualprog set IsEpisode 1 dbobj $program2 set Title $grouptitle dbobj $program2 set IsEpisode 1 dbobj $actualprog2 set Title $grouptitle dbobj $actualprog2 set IsEpisode 1 # now copy series to object dbobj $program set Series $series2 dbobj $actualprog set Series $series2 } #now reset series title dbobj $series2 set Title $grouptitle # puts "processing showids = $showids" # #now reset series title in all shows in this series # foreach fsidold $showids { # set objold [db $db openidconstruction $fsidold] # set showingold [dbobj $objold get Showing] # set programold [dbobj $showingold get Program] # set actualshowingold [dbobj $objold get ActualShowing] # set actualprogold [dbobj $actualshowingold get Program] # try {set seriesold [dbobj $programold get Series]} catch errCode { set seriesold "" } # set isepisodeold [dbobj $programold get IsEpisode] # # now check if it is an episode and same episode as we are changing ... if so change title to new group title # if { $isepisodeold == 1 && $seriesold == $series2 } { # puts "processing $fsidold" # dbobj $programold set Title $grouptitle # dbobj $actualprogold set Title $grouptitle # event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::RECORDINGS_ON_DISK $fsidold # } # } } } dbobj $newpobj set Description $newdesc set tmsid [dbobj $program get TmsId] if { $newismovie == 1 && $origismovie == 1 || $newismovie == 0 && $origismovie == 0 } { # Movie flag didn't change if {$newmovieyear != "" } { dbobj $newpobj set MovieYear $newmovieyear } } else { if { $newismovie == 0 && $origismovie == 1 } { # Movie flag was set to "Not a Movie". set movieflag [ string range $tmsid 2 [ string length $tmsid ]] } else { # Movie flag was set to "Movie". set movieflag "MV" append movieflag $tmsid } dbobj $newpobj set TmsId $movieflag } if {$newexpsecs == 0} { set newexpsecs [clock seconds] } set newexpdate [expr $newexpsecs / 86400] set newexptime [expr $newexpsecs % 86400] dbobj $rec set ExpirationDate $newexpdate dbobj $rec set ExpirationTime $newexptime if {$::version3} { set recbeh [dbobj $rec get RecordingBehavior] if {$newexpdate == 24855} { dbobj $recbeh set DiskBehavior 2 } else { dbobj $recbeh set DiskBehavior 4 } dbobj $recbeh set PresentationBehavior 1 if {$newmanrec == 1} { dbobj $recbeh set ProgramGuideBehavior 3 } else { dbobj $recbeh set ProgramGuideBehavior 1 } dbobj $recbeh set TunerBehavior 1 dbobj $rec set SelectionType 3 } else { dbobj $rec set SelectionType $newseltype # FIXME -- 2.5 Manual Recording Change will need to go here in addition to whatever else is involved. } set origairdatesecs [ clock scan $neworigairdate ] set originalairdate [ expr $origairdatesecs / 86400 ] dbobj $program set OriginalAirDate $originalairdate 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 selectiontypes global presentationbehtypes global states global showtypes global channeltablestation global channeltablestation_alt 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 global showtypeindex global showtypeindexend global bitsindex global bitsindexend global avindex global avindexend 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] } #--------------------------------------------------------------------------------------- #Get general data here, rather than over and over again below #--------------------------------------------------------------------------------------- set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set titlePlain $title set series [dbobj $program get Series] set description [strim [dbobj $program get Description]] set movieyear [dbobj $program get MovieYear] if { [catch {set data $channeltablestation($stationid)}] != 1 || [catch {set data $channeltablestation_alt($stationid)}] != 1 } { set channum [join [split [lindex $data 0] .] -] set callsign [lindex $data 2] } else { set callsign [dbobj $station get CallSign] } #titlestrg is needed for the internet database searchs (IMDB and TvTome) set titlestrg [httpMapReply [strim [dbobj $program get Title]]] regsub -all "\%26" $titlestrg "and" titlestrg set starrating [dbobj $program get StarRating] if { $starrating > 0 } { set starratingstr "" for {set i 0} {$i < [expr ($starrating + 1) / 2]} {incr i} { append starratingstr "*" } if { [expr ($starrating + 1) % 2] == 1 } { append starratingstr "½" } } set seriesfsid "" set thumbs "" if { $series != "" } { set seriesfsid [dbobj $series fsid] set thumbs "[html_link "/thumbs/$seriesfsid" "<font size=1>(No thumbs)</font>"] " set score [dbobj $series get ThumbData] if { $score != "" } { set imagenum [get_thumbimagelj $score] if { [lindex $imagenum 0] >= 0} { set imagef [lindex $images [lindex $imagenum 0]] set thconf [lindex $imagenum 1] if { $thconf > 0 } { set thumbs [html_link "/thumbs/$seriesfsid" "[img "alt=\"Confidence: $thconf\"" $imagef]"] } } } } if { $seriesfsid != "" } { set title [html_link "/series/$seriesfsid" $title] } if { $rec != "" } { set seltype [dbobj $rec get SelectionType] if {$::version >= 3} { 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 "width=90%" "" ""] set eptitleraw [dbobj $program get EpisodeTitle] if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] } elseif { $eptitleraw != "" } { set episodic 1 } else { set episodic 0 } 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 } scan $callsign "MC%d" temp if { ![info exists temp] } { # don't display for music channels if { $tmstype == 1 } { #TV SHOWS set partindex [dbobj $showing get PartIndex] set partcount [dbobj $showing get PartCount] set partstr "" if { $partcount != "" && $partindex != "" } { set partstr " ($partindex/$partcount)" } if { $episodic == 1 } { puts $chan [tr "" [td "Episode Title"] [td [strim [dbobj $program get EpisodeTitle]]$partstr]] puts $chan [tr "" [td "Episode Description"] [td [strim [dbobj $program get Description]]]] puts $chan [tr "" [td "Episode Number"] [td [dbobj $program get EpisodeNum]]] puts $chan [tr "" [td "More Info"] [td "[html_link "http://www.tv.com/search.php?type=11&stype=all&qs=$titlestrg&x=0&y=0" "Search TV.com for '$titlePlain'" "target=_new"] --- Search provided by [html_link "http://www.tv.com" "TV.com" "target=_new"]."]] set altepisodenum [dbobj $program get AltEpisodeNum] if { $altepisodenum != "" } { puts $chan [tr "" [td "Alt Episode Number"] [td $altepisodenum]] } } else { puts $chan [tr "" [td "Description"] [td [strim [dbobj $program get Description]]]] } } else { # MOVIES puts $chan [tr "" [td "Description"] [td [strim [dbobj $program get Description]]]] puts $chan [tr "" [td "Year"] [td [dbobj $program get MovieYear]]] if { $movieyear == "" } { puts $chan "<tr><td>More Info</td><td>[html_link "http://www.imdb.com/Tsearch?title=$titlestrg&type=substring&sort=smart&tv=both" "Search IMDb for '$titlePlain'" "target=_new"]" } else { puts $chan "<tr><td>More Info</td><td>[html_link "http://www.imdb.com/Tsearch?title=$titlestrg&type=substring&from_year=$movieyear&to_year=$movieyear&sort=smart&tv=both" "Search IMDb for '$titlePlain'" "target=_new"]" } puts $chan " --- Search provided by [html_link "http://www.imdb.com" "The Internet Movie Database" "target=_new"].</td></tr>" if { $starrating > 0 } { puts $chan "<TR><TD>Rating</TD><TD>$starratingstr</TD></TR>" } } } set durationsecs 0 if { $rec != "" } { set stopdate [dbobj $rec get StopDate] set stoptime [dbobj $rec get StopTime] if { $stoptime == "" } { set stoptime [expr ([dbobj $showing get Time] + [dbobj $showing get Duration]) % 86400] } set startdate [dbobj $rec get StartDate] set starttime [dbobj $rec get StartTime] if { $starttime == "" } { set starttime [dbobj $showing get Time] } if { $stopdate != "" } { set durationsecs [expr ($stopdate * 86400 + $stoptime) - ($startdate * 86400 + $starttime)] } } set showingdurationsecs [dbobj $showing get Duration] if { $durationsecs == 0 } { set durationsecs $showingdurationsecs } set duration [format "%d:%02d" [expr $durationsecs / (60*60)] [expr ($durationsecs % (60*60)) / 60]] if { [expr $durationsecs - $showingdurationsecs + 90] < 0 } { append duration [format "/%d:%02d" [expr $showingdurationsecs / (60*60)] [expr ($showingdurationsecs % (60*60)) / 60]] } if { $tmstype != 1 } { set movieruntime [dbobj $program get MovieRunTime] if { $movieruntime > 0 } { if { $::dtivo } { append duration [format " (%d:%02d)" [expr $movieruntime / 60] [expr ($movieruntime % 60)]] } else { append duration [format " (%d:%02d)" [expr $movieruntime / 100] [expr ($movieruntime % 100)]] } } } puts $chan [tr "" [td "Duration"] [td $duration]] set originalairdate [dbobj $program get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth_sup [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } puts $chan [tr "" [td "Original Air Date"] [td $airdatestr]] } set premiere [dbobj $showing get Premiere] if { $premiere != "" } { puts $chan [tr "" [td "Premiere Type"] [td [lindex $premieretypes [expr $premiere - 1]]]] } set actors [dbobj $program get Actor] if { $actors != "" } { set actorstr [PrintNames $actors 1] puts $chan [tr "" [td "Actors"] [td $actorstr]] } set gueststars [dbobj $program get GuestStar] if { $gueststars != "" } { set gueststarstr [PrintNames $gueststars 1] puts $chan [tr "" [td "Guest Stars"] [td $gueststarstr]] } set hosts [dbobj $program get Host] if { $hosts != "" } { set hoststr [PrintNames $hosts 1] puts $chan [tr "" [td "Hosts"] [td $hoststr]] } set directors [dbobj $program get Director] if { $directors != "" } { set directorstr [PrintNames $directors 2] puts $chan [tr "" [td "Directors"] [td $directorstr]] } set execproducers [dbobj $program get ExecProducer] if { $execproducers != "" } { set execproducerstr [PrintNames $execproducers] puts $chan [tr "" [td "Exec Producers"] [td $execproducerstr]] } set producers [dbobj $program get Producer] if { $producers != "" } { set producerstr [PrintNames $producers] puts $chan [tr "" [td "Producers"] [td $producerstr]] } set writers [dbobj $program get Writer] if { $writers != "" } { set writerstr [PrintNames $writers] puts $chan [tr "" [td "Writers"] [td $writerstr]] } set genres [dbobj $program get Genre] if { $::dtivo } { if { $genres != "" } { set genrestr "" set showingbitstr "" set showingtypestr "" set advisorystr "" foreach genre $genres { set genreindex [lsearch $genrenums $genre] if { $genreindex != -1 } { if {$genre >= 30 && $genre <= 45} { if { $advisorystr != "" } { append advisorystr ", " } append advisorystr [strim [lindex $genrevals $genreindex]] } elseif {($genreindex > $avindex && $genreindex <= $avindexend) || ($genreindex >= $bitsindex && $genreindex <= $bitsindexend)} { if { $showingbitstr != "" } { append showingbitstr ", " } append showingbitstr [strim [lindex $genrevals $genreindex]] } elseif {$genreindex > $showtypeindex && $genreindex <= $showtypeindexend} { if { $showingtypestr != "" } { append showingtypestr ", " } append showingtypestr [strim [lindex $genrevals $genreindex]] } else { if { $genrestr != "" } { append genrestr ", " } append genrestr [strim [lindex $genrevals $genreindex]] } } } if { $genrestr != "" } { puts $chan [tr "" [td "Genres"] [td $genrestr]] } } } else { if { $genres != "" } { set genrestr "" foreach genre $genres { set genreindex [lsearch $genrenums $genre] if { $genreindex != -1 } { if { $genrestr != "" } { append genrestr ", " } append genrestr [strim [lindex $genrevals $genreindex]] } } puts $chan [tr "" [td "Genres"] [td $genrestr]] } } if { $tmstype == 1 } { set tvrating [dbobj $showing get TvRating] if { $tvrating == "" } { # 6.3a has TvRating's in the Program catch {set tvrating [dbobj $program get TvRating]} } if { $tvrating != "" } { set tvratingindex [lsearch $tvratingnums $tvrating] if { $tvratingindex != -1 } { set tvratingstr [strim [lindex $tvratingvals $tvratingindex]] } else { set tvratingstr "" } puts $chan [tr "" [td "Rating"] [td $tvratingstr]] } } else { set mpaarating [dbobj $program get MpaaRating] if { $mpaarating != "" } { set mpaaratingindex [lsearch $mpaaratingnums $mpaarating] if { $mpaaratingindex != -1 } { set mpaaratingstr [strim [lindex $mpaaratingvals $mpaaratingindex]] } else { set mpaaratingstr "" } puts $chan [tr "" [td "Rating"] [td $mpaaratingstr]] } } if { $::dtivo } { if { $genres != "" } { if { $showingbitstr != "" } { puts $chan [tr "" [td "Bits"] [td $showingbitstr]] } if { $advisorystr != "" } { puts $chan [tr "" [td "Advisory"] [td $advisorystr]] } if { $showingtypestr != "" } { puts $chan [tr "" [td "Type"] [td $showingtypestr]] } } } else { set showingbits [dbobj $showing get Bits] if { $showingbits != "" } { set showingbitstr "" set index 0 foreach showingbitnum $showingbitnums { if { $showingbitnum & $showingbits } { if { $showingbitstr != "" } { append showingbitstr ", " } append showingbitstr [strim [lindex $showingbitvals $index]] } incr index } puts $chan [tr "" [td "Bits"] [td $showingbitstr]] } set advisorys [dbobj $program get Advisory] if { $advisorys != "" } { set advisorystr "" foreach advisory $advisorys { set advisoryindex [lsearch $advisorynums $advisory] if { $advisoryindex != -1 } { if { $advisorystr != "" } { append advisorystr ", " } append advisorystr [strim [lindex $advisoryvals $advisoryindex]] } } puts $chan [tr "" [td "Advisory"] [td $advisorystr]] } set showtype [dbobj $program get ShowType] if { $showtype != "" } { set showstr [lindex $showtypes [expr $showtype - 1]] puts $chan [tr "" [td "Type"] [td $showstr]] } } if { $station != "" } { if { [info exists channum] } { puts $chan [tr "" [td "Channel"] [td [html_link "/channel/$stationid" "$channum $callsign"]]] } else { puts $chan [tr "" [td "Channel"] [td $callsign]] } } set showingstart [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time]] if {$::lang == "en"} { set daystr [nth_sup [ftime $showingstart "%e"]] set timestr [ftime $showingstart "%a $daystr %b %H:%M"] } else { set timestr [ftime $showingstart "%1m/%1d %l:%M %P"] } puts $chan [tr "" [td "Showing Date"] [td $timestr]] if { $rec != "" } { set programsource [dbobj $rec get ProgramSource] set programsourcefsid "" if { $programsource != "" } { set programsource [lindex $programsource 0] set programsourcefsid [dbobj $programsource fsid] set programsourcetype [dbobj $programsource get Type] } set expirationdate [dbobj $rec get ExpirationDate] if { $expirationdate == 0 || $expirationdate == "" || $expirationdate == 24855 } { set timestr "" } else { set expirationsecs [expr $expirationdate * 86400 + [dbobj $rec get ExpirationTime]] if {$::lang == "en"} { set daystr [nth_sup [ftime $expirationsecs "%e"]] set timestr [ftime $expirationsecs "%a $daystr %b %H:%M"] } else { set timestr [ftime $expirationsecs "%1m/%1d %l:%M %P"] } } puts $chan [tr "" [td "Expiration Date"] [td $timestr]] set deletiondate [dbobj $rec get DeletionDate] if { $deletiondate == 0 || $deletiondate == "" || $deletiondate == 24855 } { set timestr "" } else { ## check for blank DeletionTime, per Cheezmo -- added by SteveT #set deletionsecs [expr $deletiondate * 86400 + [dbobj $rec get DeletionTime]] set deletiontime [dbobj $rec get DeletionTime] if { $deletiontime == "" } { set deletiontime 0 } set deletionsecs [expr $deletiondate * 86400 + $deletiontime] if {$::lang == "en"} { set daystr [nth_sup [ftime $deletionsecs "%e"]] set timestr [ftime $deletionsecs "%a $daystr %b %H:%M"] } else { set timestr [ftime $deletionsecs "%1m/%1d %l:%M %P"] } } puts $chan [tr "" [td "Deletion Date"] [td $timestr]] set canceldate [dbobj $rec get CancelDate] if { $canceldate == 0 || $canceldate == "" } { set timestr "" } else { set cancelsecs [expr $canceldate * 86400 + [dbobj $rec get CancelTime]] if {$::lang == "en"} { set daystr [nth_sup [ftime $cancelsecs "%e"]] set timestr [ftime $cancelsecs "%a $daystr %b %H:%M"] } else { set timestr [ftime $cancelsecs "%1m/%1d %l:%M %P"] } } puts $chan [tr "" [td "Cancel Date"] [td $timestr]] set cancelreason [dbobj $rec get CancelReason] if { $cancelreason == "" } { set cancelstr "" } else { set cancelstr [UIGetCancelReason [expr $cancelreason - 1]] } puts $chan [tr "" [td "Cancel Reason"] [td $cancelstr]] set errorstring [strim [dbobj $rec get ErrorString]] if { $errorstring != "" } { while { [set findex [string first "" $errorstring]] >= 0 } { set errorstring "[string range $errorstring 0 [expr $findex-1]]<BR>[string range $errorstring [expr $findex+1] end]" } puts $chan [tr "" [td "Error String"] [td $errorstring]] } set recquality [dbobj $rec get RecordQuality] switch -exact $recquality { 0 { set recqualitystr "Basic" } 40 { set recqualitystr "Medium" } 75 { set recqualitystr "High" } default { set recqualitystr "Best" } } puts $chan [tr "" [td "Quality"] [td $recqualitystr]] set score "" if {$::version >= 3} { if {$presbeh == 6} { set score [dbobj $rec get SubPriority] } } elseif {$seltype == 6} { set score [dbobj $rec get Score] } if {$score != ""} { set dscore [ReadableThumbs $score] puts $chan [tr "" [td "Score"] [td $dscore]] } set bookmark [dbobj $rec get Bookmark] if { $bookmark != "" } { set timems [expr [dbobj $bookmark get TimeMs] / 1000] set timestr [format "%d:%02d:%02d" [expr $timems / (60*60)] [expr ($timems % (60*60)) / 60] [expr $timems % 60]] puts $chan [tr "" [td "Bookmark"] [td $timestr]] } set nsecswatched [dbobj $rec get NSecondsWatched] if { $nsecswatched > 0 } { set timestr [format "%d:%02d:%02d" [expr $nsecswatched / (60*60)] [expr ($nsecswatched % (60*60)) / 60] [expr $nsecswatched % 60]] puts $chan [tr "" [td "Time Watched"] [td $timestr]] } set nvisits [dbobj $rec get NVisit] if { $nvisits > 0 } { puts $chan [tr "" [td "Num Visits"] [td $nvisits]] } if { $seltype != "" } { if {$::version >= 3} { if {$progbeh == 3} { if {$presbeh == 1} { set seltypestr "Manual" } elseif {$presbeh == 2} { set seltypestr "Manual Season Pass" } else { set seltypestr "Manual" } } else { set seltypestr [lindex $presentationbehtypes [expr $presbeh - 1]] } } else { set seltypestr [lindex $selectiontypes [expr $seltype - 1]] } puts $chan [tr "" [td "Selection Type"] [td $seltypestr]] } set state [dbobj $rec get State] set statestr [lindex $states [expr $state - 1]] puts $chan [tr "" [td "State"] [td $statestr]] if { [catch {dbobj $rec get StreamFileSize} streamsize] } { set streamsize 0 } if { $streamsize == "" } { set streamsize 0 } set parts [dbobj $rec get Part] if { ($streamsize == 0) && ($state == 3 || $parts == "") } { switch -exact $recquality { 0 { set bitrate [expr $::uktivo ? 1700000 : 1630000] } 40 { set bitrate 2760000 } 75 { set bitrate 3660000 } default { set bitrate 5960000 } } set seconds [dbobj $showing get Duration] set size "[expr ($seconds * ($bitrate / (8 * 1024))) / 1024] MB (estimated)" } else { set size 0 if { $streamsize == 0 } { foreach part $parts { set file [dbobj $part get File] if { [catch {mfs streamsize $file} sizes] } { } else { incr size [expr ([lindex $sizes 0] / 1024) * [lindex $sizes 1] / 1024] } } } else { set size [expr $streamsize / 1024] } append size " MB" } puts $chan [tr "" [td "Size"] [td $size]] } # added MFS Data and links for debugging -- SteveT if {$seriesfsid != ""} { set strSeries ", [html_link /object/$seriesfsid SeriesObject]" } else { set strSeries "" } set strMFSData "tmsid=$tmsid, [html_link /object/$objectid ShowingObject]$strSeries" puts $chan [tr "" [td "MFS Data"] [td $strMFSData]] puts -nonewline $chan [html_table_end] puts $chan "<P>" } 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 } { if [PrefixMatches "6.3" $::tivoswversion] { append actionstr [tr "" [td [html_link "/getseasonpass/$objectid" "Get Season Pass <i>(experimental)</i>"]]] } else { 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 "<P>" } puts $chan [html_end] } proc print_recoptions {chan type quality kal startearly endlate kam showtype keepuntil {duration 0} } { set duration [expr $duration/60] 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}" ## added 10 value -- SteveT set kamvals "1 2 3 4 5 10 0" set kamlabs "{1 episode} {2 episodes} {3 episodes} {4 episodes} {5 episodes} {10 episodes} {All Episodes}" if {$::version >= 3} { 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}" ## added 60 and 30 values -- SteveT set startvals "60 30 10 5 4 3 2 1 0" set startlabs "{60 minutes early} {30 minutes early} {10 minutes early} {5 minutes early} {4 minutes early} {3 minutes early} {2 minutes early} {1 minute early} {On-time}" if {$::version >= 3} { foreach startval [lsort -integer $startvals] { ## changed 5 to 60 -- SteveT if { $startval != 0 && ($duration == 0 && $startval <= 60 || $startval <= [expr $duration/2]) } { lappend startvals [expr $startval * -1] if { $startval == 1 } { set minutes "minute" } else { set minutes "minutes" } lappend startlabs "$startval $minutes late" } } } 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}" if {$::version >= 3} { foreach endval $endvals { if { $endval != 0 && ($duration == 0 && $endval <= 5 || $endval <= [expr $duration/2]) } { set endvals [concat [list [expr $endval * -1]] $endvals] if { $endval == 1 } { set minutes "minute" } else { set minutes "minutes" } set endlabs [concat [list "$endval $minutes earlier"] $endlabs] } } } puts $chan [tr "" [td "Record Quality"] [td "width=55%" [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]]] } proc action_recoptions {chan objectid env} { global db global defrecquality RetryTransaction { if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } if { [regexp {([0-9]*)/(.*)} $objectid junk fsid subobjid] } { set showing [db $db openidconstruction $fsid $subobjid] } else { set showing [db $db openid $objectid] } set duration [dbobj $showing get Duration] } 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 $duration puts -nonewline $chan [html_table_end] puts $chan "<P>" puts $chan [html_form_hidden "objectid" $objectid] puts $chan [html_form_input "submit" "Conflicts" "Conflicts"] puts $chan [html_form_end] puts $chan "<P>" puts $chan [html_link "javascript:history.go(-1)" "Cancel"] puts $chan [html_end] } proc action_conflicts {chan path env} { global db global num_tuners 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 "width=90%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "Program"] [th "Episode"] [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 "<P>" if { $::dtivo && $::num_tuners == 2} { set conflicts 0 foreach conflict $conflictslist { RetryTransaction { set rec [db $db openid $conflict] set showing [dbobj $rec get Showing] set showingfsid "[dbobj $showing fsid]/[dbobj $showing subobjid]" set startearlysecs [defaultval 0 [dbobj $rec get StartPadding]] set endlatesecs [defaultval 0 [dbobj $rec get EndPadding]] } set conflict_conflictslist [GetConflictsList $showingfsid $startearlysecs $endlatesecs] set conflictindex [lsearch -exact $conflict_conflictslist $conflict] set conflict_conflictslist [lreplace $conflict_conflictslist $conflictindex $conflictindex] foreach conflict_conflict $conflict_conflictslist { if { [lsearch -exact $conflictslist $conflict_conflict] != -1 } { incr conflicts } } } if { $conflicts > 0 } { puts $chan "<font color=\"#FF0000\"><b>Conflicts exist for both tuners. Continuing will cancel all listed conflicts.</b></font><br>" puts $chan "To avoid having all conflicts deleted, please free up one of the tuners by<br>" puts $chan "manually deleting one or more of the conflicts and try again.<br>" } else { puts $chan "Conflicts exist for only one tuner. Continuing will not cancel anything listed." set conflictslist "" } puts $chan "<P>" } } else { puts $chan [html_start "Conflicts"] puts $chan [h1 "No Conflicts"] } puts $chan [html_table_start "width=90%" "" "ALIGN=TOP"] puts $chan [tr "ALIGN=CENTER" [th "Program"] [th "Episode"] [th "Date"] [th "Time"] [th "COLSPAN=2" "Channel"]] 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 "<P>" 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 [html_link "javascript:history.go(-1)" "Cancel"] puts $chan [html_end] } proc do_conflictsrow {chan showing startearlysecs endlatesecs} { global db global channeltablestation global channeltablestation_alt 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]] set showingendsecs [expr $showingsecs + [dbobj $showing get Duration] + $endlatesecs] set showingsecs [expr $showingsecs - $startearlysecs] if {$::lang == "en"} { set daystr [nth_sup [ftime $showingsecs "%e"]] set timestr [ftime $showingsecs "%a $daystr %b"] set timestr2 [ftime $showingsecs "%H:%M"] set timestr3 [ftime $showingendsecs "%H:%M"] } else { set timestr [ftime $showingsecs "%1m/%1d"] set timestr2 [ftime $showingsecs "%l:%M %P"] set timestr3 [ftime $showingendsecs "%l:%M %P"] } set station [dbobj $showing get Station] set stationid [dbobj $station fsid] if { [catch {set data $channeltablestation($stationid)}] != 1 || [catch {set data $channeltablestation_alt($stationid)}] != 1 } { set channum [join [split [lindex $data 0] .] -] set callsign [lindex $data 2] } ## show episode name and optional description of episode -- added by SteveT if { $eptitle == "" } { set eptitle "Not an Episode" } set description [strim [dbobj $program get Description]] set originalairdate [dbobj $program get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set description "($airdatestr) $description" } puts $chan [tr "" [td $title] [td [html_link "/showing/$showingfsid" $eptitle][desc_show $description]] [td $timestr] [td "$timestr2-$timestr3"] [td $channum] [td $callsign]] } proc action_confirmdelete {chan path env} { global db eval $env if {[info exists submit] && $submit == "Merge Shows"} { action_merge $chan $path $env return } 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} { set rlist [lsort -dictionary [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 "<B>Delete the following:?</B><P>\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 "width=98%" "" ""] 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]] set day [ftime $seconds "%a"] if {$::lang == "en"} { set daystr [nth_sup [ftime $seconds "%e"]] set date [ftime $seconds "$daystr %b"] set time [ftime $seconds "%H:%M"] } else { set date [ftime $seconds "%1m/%1d"] set time [ftime $seconds "%l:%M %P"] } ## show description of episode -- added by SteveT set description [strim [dbobj $program get Description]] set originalairdate [dbobj $program get OriginalAirDate] } if { $episodetitle == "" } { set episodetitle "Not an Episode" } if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set description "($airdatestr) $description" } set episodetitle "$episodetitle [desc_show $description]" ########### if { $type == 6 || $type == 7 || $type == 8} { puts $chan [tr "" [td $day] [td "NOWRAP" $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 "<B>Undelete" } else { set tmpstr "<B>Delete" } append tmpstr " '$title' - $day $date $time ?</B>" if { $episodetitle != "" } { append tmpstr "<BR>'$episodetitle'" } puts $chan $tmpstr puts $chan "<P>" 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 [html_link "javascript:history.go(-1)" "Cancel"] } } if { $type == 6 || $type == 7 || $type == 8} { puts $chan [html_table_end] puts $chan [html_form_input "submit" "submit" "Yes"] puts $chan "<INPUT TYPE=\"BUTTON\" VALUE=\"No\" onClick=\"history.go(-1)\">" puts $chan [html_form_end] } puts $chan [html_end] } 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 "<B>$deletestr Successful</B>" } else { puts $chan "<B>$deletestr Failed</B>" } puts $chan "<P>" 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 -dictionary [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 "width=98%" "" ""] 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 "<B>Successfully Deleted</B>" } else { set success_str "<B>Delete Failed</B>" } 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 "<BR><B>$deletestr Successful</B>" } else { puts $chan "<BR><B>$deletestr Failed</B>" } } } if { $type == 6 } { puts $chan [html_table_end] } puts $chan "<P>" puts $chan [html_link "/nowshowing" "Now Playing"] 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 -dictionary [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 "width=98%" "" ""] 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 "<B>Successfully Deleted</B>" } else { set success_str "<B>Delete Failed</B>" } 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 "<B>$deletestr Successful</B>" } else { puts $chan "<B>$deletestr Failed</B>" } } } if { $type == 7 || $type == 8} { puts $chan [html_table_end] } puts $chan "<P>" 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 images global programindexstartday global nowshowingdir set watch 1 eval $env if {[string index $objectid 0] == "/"} { set objectid [string range $objectid 1 end] } RetryTransaction { set series [db $db openid $objectid] set title [strim [dbobj $series get Title]] set score [dbobj $series get ThumbData] set seriesfsid [dbobj $series fsid] set thumbs "[html_link "/thumbs/$seriesfsid" "<font size=1>(No thumbs)</font>"] " if { $score != "" } { set imagenum [get_thumbimagelj $score] if { [lindex $imagenum 0] >= 0} { set imagef [lindex $images [lindex $imagenum 0]] set thconf [lindex $imagenum 1] if { $thconf > 0 } { set thumbs [html_link "/thumbs/$seriesfsid" "[img "alt=\"Confidence: $thconf\"" $imagef]"] } } } puts $chan [html_start "Series: '$title'"] puts $chan [h1 "$thumbs $title"] } puts $chan [h2 [html_link "/nowshowing" "Now Playing"]] set delete_th "" puts $chan [html_table_start "width=98%" "" ""] #LJ2 added mins; tr was "ALIGN=CENTER" puts $chan [tr "ALIGN=CENTER" [th ""] [th "Episode"] [th "Num"] [th "Orig.Air Date"] [th "Chan"] [th "COLSPAN=2" "Date"] [th "Time"] [th "Duration"]] set rcount 0 ForeachMfsFile fsid name type $nowshowingdir "" { if {[catch [do_seriesrow $chan $fsid $objectid 0 2 $rcount] error]} { puts "do_seriesrow $fsid $objectid 0 2 $rcount" puts $error } incr rcount } puts -nonewline $chan [html_table_end] puts $chan "<P>" puts $chan [h2 [html_link "/ui/todo" "Upcoming Showings"]] puts $chan [html_table_start "width=98%" "" ""] # LJ added mins; tr was "ALIGN=CENTER" puts $chan [tr "ALIGN=CENTER" [th ""] [th "Episode"] [th "Num"] [th "Orig.Air Date" ] [th "Chan"] [th "COLSPAN=2" "Date"] [th "Time"] [th "Duration"]] set slists [get_programshowings $objectid $watch] # puts $chan $slists 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 set rcount 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 $chan $showing $recfsid 0" puts $error } incr rcount 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] } proc action_record [info args action_record] "eval \$env [info body action_record]" proc do_seriesrow {chan fsid objectid multi type args} { global db global images global cache_ns_rec global cache_ns_series global channeltablestation global channeltablestation_alt if {[llength $args] > 0} { set rcount [lindex $args 0] } set index [lsearch $cache_ns_rec $fsid] if { $index != -1 } { set seriesfsid [lindex $cache_ns_series $index] if {$seriesfsid != $objectid} { return } } set suggestion 0 set vod 0 RetryTransaction { if { $index == -1 } { set rec [db $db openid $fsid] set showing [dbobj $rec get Showing] set station [dbobj $showing get Station] 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 program [dbobj $showing get Program] set series [dbobj $program get Series] } set stationfsid [dbobj $station fsid] set showingtime [dbobj $showing get Time] set showingdurationsecs [dbobj $showing get Duration] set durationsecs 0 set stopdate [dbobj $rec get StopDate] set stoptime [dbobj $rec get StopTime] if { $stoptime == "" } { set stoptime [expr ($showingtime + $showingdurationsecs) % 86400] } set startdate [dbobj $rec get StartDate] set starttime [dbobj $rec get StartTime] if { $starttime == "" } { set starttime $showingtime } if { $stopdate != "" } { set durationsecs [expr ($stopdate * 86400 + $stoptime) - ($startdate * 86400 + $starttime)] } if { $durationsecs == 0 } { set durationsecs $showingdurationsecs } set duration [format "%d:%02d" [expr $durationsecs / (60*60)] [expr ($durationsecs % (60*60)) / 60]] set state [dbobj $rec get State] set showingfsid [dbobj $rec gettarget Showing] if {$::version >= 3} { set recbeh [dbobj $rec get RecordingBehavior] set seltype [dbobj $recbeh get PresentationBehavior] set presbeh $seltype if { $presbeh == 6 } { set suggestion 1 } } else { set seltype [dbobj $rec get SelectionType] if { $seltype == 6 } { set createby [dbobj $rec get CreatedBy] if { $createby == 2 } { set vod 1 } else { set suggestion 1 } } } if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] } else { set episodic 0 } set eptitle [get_verbose_title $program $episodic 0] set description [strim [dbobj $program get Description]] 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] if { [catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set callsign [lindex $data 2] } else { 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 {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set hovertext "($airdatestr) $description" } else { set hovertext $description } set attrs [CreateHover $hovertext] set seconds [expr [dbobj $showing get Date] * 86400 + $showingtime] set day [ftime $seconds "%a"] if {$::lang == "en"} { set daystr [nth_sup [ftime $seconds "%e"]] set date [ftime $seconds "$daystr %b"] set time [ftime $seconds "%H:%M"] } else { set date [ftime $seconds "%1m/%1d"] set time [ftime $seconds "%l:%M %P"] } 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 {$multi == 6} { set delete_td [td "ALIGN=CENTER" [html_form_checkbox "fsid_${rcount}_$fsid" ""]] } #LJ added durn to next two puts lines ## Added desc_show -- SteveT if { $type == 2 } { puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] [td $epnum] [td $airdatestr] [td [html_link "/channel/$stationfsid" $callsign]] [td $day] [td "NOWRAP" $date] [td $time] [td $duration] $delete_td] } else { puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] [td $epnum] [td $airdatestr] [td [html_link "/channel/$stationfsid" $callsign]] [td $day] [td "NOWRAP" $date] [td $duration] $delete_td] } } } } proc do_seriesrowtodo {chan showing recfsid space} { global db global images global channeltablestation global channeltablestation_alt set showingfsid "[dbobj $showing fsid]/[dbobj $showing subobjid]" set program [dbobj $showing get Program] set series [dbobj $program get Series] if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] } else { set episodic 0 } set eptitle [get_verbose_title $program $episodic 0] set description [strim [dbobj $program get Description]] 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] ## return immediately if not in watched channels - added by SteveT if { [catch {set data $channeltablestation($stationfsid)}] == 1 } { return } if { [catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set callsign [lindex $data 2] } else { set callsign [dbobj $station get CallSign] } set epnum [dbobj $program get EpisodeNum] set durationsecs [dbobj $showing get Duration] set duration [format "%d:%02d" [expr $durationsecs / (60*60)] [expr ($durationsecs % (60*60)) / 60]] set originalairdate [dbobj $program get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set hovertext "($airdatestr) $description" } else { set hovertext $description } set attrs [CreateHover $hovertext] set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time]] set day [ftime $seconds "%a"] if {$::lang == "en"} { set daystr [nth_sup [ftime $seconds "%e"]] set date [ftime $seconds "$daystr %b"] set time [ftime $seconds "%H:%M"] } else { set date [ftime $seconds "%1m/%1d"] #SteveT set time [ftime $seconds "%l:%M %P"] set time [ftime $seconds "%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 {$::version >= 3} { 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 { #LJ For slot free # set imageh "" ## changed line below per didolgi -- SteveT #set imageh [slotfree [expr $seconds - [get_tzoffset $seconds]] [dbobj $showing get Duration] $chan] set imageh [slotfree [expr $seconds ] [dbobj $showing get Duration] $chan] } if {$space == 1} { set spacestr [td "WIDTH=\"30\"" ""] } else { set spacestr "" } set delete_td "" #LJ added " [td $durn]" to the next line ## Added desc_show -- SteveT puts $chan [tr "" [td $imageh] $spacestr [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] [td $epnum] [td $airdatestr] [td [html_link "/channel/$stationfsid" $callsign]] [td $day] [td "NOWRAP" $date] [td "nowrap" $time] [td $duration] $delete_td] } proc action_todo {chan todotype env} { global db global channeltablestation global channeltablestation_alt 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 "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [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 "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [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 "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [th "Program"] [th "Episode"] [th "Score"]] set path "/Recording/Pending" set prefix "" } elseif {$todotype == 7} { puts $chan [html_start "To Do"] puts $chan " <script language=\"JavaScript\"> <!-- function CheckAll(x, y) { for (var i=0; i < document.form.elements.length; i++) { var c = document.form.elements\[i\]; if ((c.name.substr(0,x.length) == x) && (c.type == 'checkbox')) { c.checked = y; } } } //--> </script>" puts $chan [html_form_start "POST" "/confirmdelete/7/" "name=\"form\""] puts $chan [html_table_start "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [th "Program"] [th "Episode"] [th "<input name=\"selectall\" type=\"checkbox\" value=\"Check All\" title=\"Select/Deselect All\" onClick=\"CheckAll('fsid_', selectall.checked);\">"]] set path "/Recording/Active" set prefix "4" } elseif {$todotype == 8} { puts $chan [html_start "Scheduled Suggestions"] puts $chan " <script language=\"JavaScript\"> <!-- function CheckAll(x, y) { for (var i=0; i < document.form.elements.length; i++) { var c = document.form.elements\[i\]; if ((c.name.substr(0,x.length) == x) && (c.type == 'checkbox')) { c.checked = y; } } } //--> </script>" puts $chan [html_form_start "POST" "/confirmdelete/8/" "name=\"form\""] puts $chan [html_table_start "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [th "Program"] [th "Episode"] [th "Score"] [th "<input name=\"selectall\" type=\"checkbox\" value=\"Check All\" title=\"Select/Deselect All\" onClick=\"CheckAll('fsid_', selectall.checked);\">"]] 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 {$::version >= 3} { 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] } if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] set seriesfsid [dbobj $series fsid] } else { set episodic 0 set manual 1 } set eptitle [get_verbose_title $program $episodic 0] set originalairdate [dbobj $program get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set hovertext "($airdatestr) $description" } else { set hovertext $description } set attrs [CreateHover $hovertext] if { [catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set callsign [lindex $data 2] } else { set callsign [dbobj $station get CallSign] } set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time]] set day [ftime $seconds "%a"] if {$::lang == "en"} { set daystr [nth_sup [ftime $seconds "%e"]] set date [ftime $seconds "$daystr %b"] set time [ftime $seconds "%H:%M"] } else { set date [ftime $seconds "%1m/%1d"] set time [ftime $seconds "%l:%M %P"] } set scorestr "" if {$todotype != 0 && $todotype != 7} { if {$::version >= 3} { set score [dbobj $rec get SubPriority] } else { set score [dbobj $rec get Score] } set scorestr [td "nowrap" [html_link "/thumbs/$seriesfsid" [ReadableThumbs $score]]] } set delete_td "" if {$todotype == 7 || $todotype == 8} { set delete_td [td "ALIGN=CENTER" [html_form_checkbox "fsid_${rcount}_$fsid" ""]] incr rcount } ## Added desc_show -- SteveT if { $manual } { puts $chan [tr "" [td $day] [td "NOWRAP" $date] [td "NOWRAP ALIGN=RIGHT" $time] [td [html_link "/channel/$stationfsid" $callsign]] [td [html_link "/showing/$showingfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] $scorestr $delete_td] } else { puts $chan [tr "" [td $day] [td "NOWRAP" $date] [td "NOWRAP ALIGN=RIGHT" $time] [td [html_link "/channel/$stationfsid" $callsign]] [td [html_link "/series/$seriesfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] $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 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 stationname [dbobj $station get Name] 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 {$::version >= 3} { 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] } set eptitleraw [dbobj $program get EpisodeTitle] #set isepisode [dbobj $program get IsEpisode] if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] } else { if { $eptitleraw == "" } { set episodic 0 } else { set episodic 1 } set watchonly 1 } set eptitle [get_verbose_title $program $episodic 0] set originalairdate [dbobj $program get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set hovertext "($airdatestr) $description" } else { set hovertext $description } set attrs [CreateHover $hovertext] set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time]] set day [ftime $seconds "%a"] if {$::lang == "en"} { set daystr [nth_sup [ftime $seconds "%e"]] set date [ftime $seconds "$daystr %b"] } else { set date [ftime $seconds "%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 { $::tyshow_links && $type != "" } { set delete_td "$delete_td [td [html_link "/asx/$fsid.asx" "View"]]" } ## Added desc_show -- SteveT if {$title == "Multipart" && $stationname == "n/a"} { puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $title]] [td [html_link "/showing/$showingfsid" "<small>[htmlEncode $hovertext]</small>" "Multipart recording"]] [td $day] [td "NOWRAP" $date] [td $stationname] $delete_td [td "<small>[html_link "/asx/$fsid.asx" "$fsid"]</small>"]] } elseif {$manual || $watchonly} { puts $chan [tr "" [td $imageh] [td [html_link "/showing/$showingfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] [td $day] [td "NOWRAP" $date] [td $stationname] $delete_td [td "<small>[html_link "/asx/$fsid.asx" "$fsid"]</small>"]] } else { puts $chan [tr "" [td $imageh] [td [html_link "/series/$seriesfsid" $title]] [td [html_link "/showing/$showingfsid" $eptitle $attrs][desc_show $hovertext]] [td $day] [td "NOWRAP" $date] [td $stationname] $delete_td [td "<small>[html_link "/asx/$fsid.asx" "$fsid"]</small>"]] } } 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 Playing"] puts $chan " <script defer language=\"JavaScript\"> <!-- function init() { if (!(document.getElementById || document.all || document.layers)) return; //document.oncontextmenu=new Function(\"return false\"); for (i=0;i<document.links.length;i++) { link = document.links\[i\]; if (link.tagName == \"A\" && link.href.indexOf('/asx/') !=-1) { document.links\[i\].onmouseover = function() {document.oncontextmenu=function() {return false}}; document.links\[i\].onmousedown = checkIt; document.links\[i\].onmouseup = function() {return false}; document.links\[i\].onmouseout = function() {document.oncontextmenu=null}; } } } function checkIt(e) { if (window.Event) { butt = (e.which == 3); href = \"\" + e.target; } else { butt = (window.event.button == 2); href = \"\" + window.event.srcElement; } if (butt) { i = href.indexOf('/asx/'); if (i!=-1) { j = href.indexOf('.asx'); location.href = 'tivo://$::ip_address/' + href.substr(i+5,j-i-5); } } return false; } window.onload = init; //--> </script>" # Sort support for non-v3.0 users sourced from LJ's folders module # http://www.ljay.org.uk/tivoweb/folders.itcl puts $chan "<font size=2>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 "</font>" if {$::version == 3} { RetryTransaction { set state [db $db open "/State/MyWorld"] if { [info exists sort] } { if { $sort > 0 } { dbobj $state set NowShowingSortOrder $sort } else { dbobj $state remove NowShowingSortOrder } } 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" } } set sort 0 } elseif {$::version >= 4} { # This may also be valid for all versions >= 4 rather than just 6... RetryTransaction { set state [db $db open "/State/MyWorld"] if { [info exists sort] } { if { $sort > 1 } { dbobj $state set NowShowingSortOrder $sort } else { dbobj $state remove NowShowingSortOrder } } else { set sort [dbobj $state get NowShowingSortOrder] } } switch -exact -- $sort { 2 { set nowshowingdir "/Recording/NowShowingByFlatTitle" } default { set nowshowingdir "/Recording/NowShowingByClassic" } } if {$sort != 1} {set sort 0} } else { global nowshowingdir } if {![info exists sort]} {set sort 0} # ASSERT: If sort==0 then display rows directly from $nowshowingdir, # Otherwise sort the rows using the $sort order. set delete_th "" if {$nstype == 6} { puts $chan " <script language=\"JavaScript\"> <!-- function CheckAll(x, y) { for (var i=0; i < document.form.elements.length; i++) { var c = document.form.elements\[i\]; if ((c.name.substr(0,x.length) == x) && (c.type == 'checkbox')) { c.checked = y; } } } //--> </script>" puts $chan [html_form_start "POST" "/confirmdelete/6/" "name=\"form\""] set delete_th "[th "<input name=\"selectall\" type=\"checkbox\" value=\"Check All\" title=\"Select/Deselect All\" onClick=\"CheckAll('fsid_', selectall.checked);\">"]" } if { $::tyshow_links } { set delete_th "$delete_th [th ""]" } puts $chan [html_table_start "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th ""] [th "Program"] [th "Episode"] [th "COLSPAN=2" "Date"] [th "Chan"] $delete_th [th "<small>FSID</small>"]] set rcount 0 set shows "" ForeachMfsFileTrans fsid name type $nowshowingdir "" 15 { set rec [db $db openid $fsid] # 2: Title, 1: Expiration, 0: Classic switch -exact -- $sort { 2 { set showing [dbobj $rec get Showing] set program [dbobj $showing get Program] set sortkey [strim [dbobj $program get Title]] lappend shows [list $fsid $sortkey] } 1 { set showing [dbobj $rec get Showing] set expdate [dbobj $rec get ExpirationDate] set expsecs [expr $expdate * 86400 + [dbobj $rec get ExpirationTime]] set sortkey [expr {[string index $name 0] == "A" ? "B[expr abs($expsecs)]" : "A[expr abs($expsecs)]" }] lappend shows [list $fsid $sortkey] } 0 { if {$nstype == 6} { print_nowshowingrow $chan $rec $nstype $rcount incr rcount } else { print_nowshowingrow $chan $rec $nstype } } } } if { $sort > 0 } { # 2: Title, 1: Expiration, 0: Classic switch -exact -- $sort { 2 { set shows [lsort -ascii -index 1 $shows] } 1 { set shows [lsort -dictionary -index 1 $shows] } } set rcount 0 foreach show $shows { RetryTransaction { set fsid [lindex $show 0] 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"] if {[info procs "action_merge"] == "action_merge"} { puts $chan [html_form_input "submit" "submit" "Merge Shows"] } puts $chan [html_form_end] } puts $chan [html_end] } proc action_deletedshows {chan path env} { global db set first 1 puts $chan [html_start "Deleted Shows"] puts $chan [html_table_start "width=98%" "" ""] 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"] [th "Chan"] [th "<small>FSID</small>"]] } print_nowshowingrow $chan $rec "" } } puts $chan [html_table_end] if {$first} { puts $chan "<B>No shows available for undelete</B>" } else { puts $chan "<font size=2>To undelete a show click the icon next to its name</font>" } 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 "<B>Deletion of Season Pass Successful</B><P>" } 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 if {$::version < 6} { event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::SEASON_PASS $objectid } puts $chan "<B>Updated Season Pass Successfully</B><P>" } 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] if {$::version < 6} { event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::SEASON_PASS $spfsid } } else { set spfsid 1 } if {$spfsid != 0} { puts $chan "<B>Creation of Season Pass Successful</B>" puts $chan "<BR>Episodes for this season pass may take some time to schedule.<P>" } else { puts $chan "<B>ERROR - Creation of Season Pass FAILED</B>" puts $chan "<BR>When using v6.3 a Season Pass needs to be created via the TiVo UI for the same channel, before one can be create via TWP.<P>" } } puts $chan [html_link "/ui/wishlists" "View Wishlists"] puts $chan "<BR>" puts $chan [html_link "/ui/seasonpass" "View Season Passes"] puts $chan [html_end] } proc action_editseasonpass {chan objectid env} { global db global channeltablestation global channeltablestation_alt 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 {$::version >= 3} { 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 [defaultval 0 [dbobj $sp get StartTimeLocal]] set firstrun "" } elseif { $type == 3 } { set theme [dbobj $sp get Theme] set title [strim [dbobj $theme get Name]] if {$::version >= 3} { 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 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set channum [join [split [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]] } 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 {$::lang == "en"} { 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 "<P>" 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 "<P>" puts $chan [html_link "javascript:history.go(-1)" "Don't Change"] puts $chan [html_end] } proc action_getseasonpass {chan objectid env} { global db global channeltablestation global channeltablestation_alt 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 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set channum [join [split [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 "width=98%" "" ""] # 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 "<P>" 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 "<P>" puts $chan [html_link "javascript:history.go(-1)" "Cancel"] puts $chan [html_end] } proc action_reprioritize {chan path env} { global db global seasonpassdir set spcount 0 eval $env if {$spcount == 0} { action_seasonpass $chan "reprioritize" "" return } set rlist [info vars "fsid_*"] foreach sp $rlist { lappend spitems [concat [lrange [split $sp "_"] 1 2] [expr \$$sp]] } set clist [list] set nlist [list] set vlist [list] foreach item [lsort -integer -index 1 $spitems] { set spfsid [lindex $item 0] set oldprio [lindex $item 1] set newprio [lindex $item 2] if {$newprio != $oldprio} { lappend clist $spfsid lappend nlist $newprio lappend vlist $oldprio } } set errors [list] set priority 0 ForeachMfsFile fsid name type $seasonpassdir "" { incr priority set index [lsearch $clist $fsid] if {$index != -1} { set oldprio [lindex $vlist $index] if {$oldprio != $priority} { lappend errors "Old Form Data, Please Refresh" break } } } foreach newprio $nlist { set index [lsearch $vlist $newprio] if {$index == -1} { lappend errors "Priority $newprio already taken" } else { set vlist [lreplace $vlist $index $index] } } if {[llength $vlist] != 0} { lappend errors "Unused Priorities '$vlist'" } #RetryTransaction { # foreach spfsid $clist prio $nlist { # set sp [db $db openid $spfsid] # puts $chan "dbobj $sp set Priority [expr $prio - 1]<br>" # dbobj $sp set Priority [expr $prio - 1] # } #} # MOD: Replace the above code with something that does not # barf with "commit failed (0x00030019)" errors when # large transactions are attempted. while {[llength $clist] > 0} { set idx -1 RetryTransaction { foreach spfsid $clist prio $nlist { set sp [db $db openid $spfsid] dbobj $sp set Priority [expr $prio - 1] incr idx if {$idx >=15} {break} } } set clist [lreplace $clist 0 $idx] set nlist [lreplace $nlist 0 $idx] } if {$errors != ""} { puts $chan [html_start "Season Passes"] puts $chan "The following errors were encountered:<BR>" foreach error $errors { puts $chan "$error<BR>" } puts $chan [html_end] } else { action_seasonpass $chan "reprioritize" "" } } proc action_seasonpass {chan path env} { global db global images global seasonpassdir global channeltablestation global channeltablestation_alt if {$path == "reprioritize"} { set reprio 1 } else { set reprio 0 } puts $chan [html_start "Season Passes"] if {$reprio} { set priolist [list] RetryTransaction { set spcount [mfs scancount $seasonpassdir] } for {set i 1} {$i <= $spcount} {incr i} { lappend priolist $i } puts $chan " <script language=\"JavaScript\"> <!-- function compareNumbers(a, b) { return a - b; } function ReorderPrio(sobj) { var oldprio = 0; var newprio = sobj.value; var numprios = document.form.spcount.value; var plist = new Array(); var j = 0; for (var i=0; i < document.form.elements.length; i++) { var c = document.form.elements\[i\]; if ((c.name.substr(0,5) == 'fsid_') && (c.type == 'select-one')) { if (c.name != sobj.name) { plist\[j\] = c.value; j++ } } } plist.sort(compareNumbers); for (var i=0; i < plist.length; i++) { if (plist\[i\] != i + 1) { oldprio = i + 1; break; } } if (oldprio == 0 && plist\[i\] != $spcount) { oldprio = $spcount; } plist.push(oldprio); plist.sort(compareNumbers); var valid = 1; for (var i=0; i < numprios - 1; i++) { if (plist\[i\] != i + 1) { valid = 0; } } if (valid && oldprio != 0) { for (var i=0; i < document.form.elements.length; i++) { var c = document.form.elements\[i\]; if ((c.name.substr(0,5) == 'fsid_') && (c.type == 'select-one')) { if (c.name != sobj.name) { var cval = Number(c.value); if (newprio < oldprio) { if (cval >= newprio && cval <= oldprio) { c.value = cval + 1; } } else { if (cval <= newprio && cval >= oldprio) { c.value = cval - 1; } } } } } } } //--> </script>" puts $chan [html_form_start "POST" "/reprioritize" "name=\"form\""] puts $chan [html_form_hidden "spcount" $spcount] } puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th ""] [th "Pri"] [th "Title"] [th "Chan"] [th "KAM"] [th "Show Type"]] set priority 0 set lastrprio -1 set error 0 ForeachMfsFileTrans fsid name type $seasonpassdir "" 20 { set sp [db $db openid $fsid] set type [defaultval 1 [dbobj $sp get Type]] set rprio [lindex [split $name "~"] 0] regsub {^0+(.+)} $rprio {\1} rprio if {$rprio < 0 || ($lastrprio >= 0 && $lastrprio == $rprio)} { set error 1 } set lastrprio $rprio 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]]] if {$reprio} { append rowstr [td [html_form_select "fsid_${fsid}_${priority}" $priolist $priolist $priority "onChange=\"ReorderPrio(this)\""]] } else { append rowstr [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] if { [catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set callsign [lindex $data 2] } else { 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 [defaultval 0 [dbobj $sp get StartTimeLocal]] set starttime [expr $starttimelocal - [get_tzoffset $starttimelocal]] 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]" } if { [catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set callsign [lindex $data 2] } else { 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]]] if {$reprio} { append rowstr [td [html_form_select "fsid_${fsid}_${priority}" $priolist $priolist $priority "onChange=\"ReorderPrio(this)\""]] } else { append rowstr [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]]] if {$reprio} { append rowstr [td [html_form_select "fsid_${fsid}_${priority}" $priolist $priolist $priority "onChange=\"ReorderPrio(this)\""]] } else { append rowstr [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] if {$reprio} { puts $chan [html_form_input "submit" "RePrioritize" "RePrioritize"] puts $chan [html_form_input "reset" "Reset" "Reset"] puts $chan [html_form_end] } else { puts $chan [html_table_start "" "" ""] puts $chan [tr "" [th "Actions"]] puts $chan [tr "" [td [html_link "/reprioritize" "RePrioritize"]]] puts -nonewline $chan [html_table_end] puts $chan "<font size=2>To edit a season pass click the icon next to its name</font>" } if {$error} { puts $chan "<P><B>Error: your season pass priority list is corrupted, reorganizing them may help</B>" } puts $chan [html_end] } 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] set imageg [lindex $images 3] puts $chan [html_start "WishLists"] puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th ""] [th "Title"] [th "Type"] [th ""]] ForeachMfsFileTrans fsid name type "/Theme" "" 20 { set theme [db $db openid $fsid] set type [defaultval 1 [dbobj $theme get ThemeType]] # fetch a user comprehensible name set title [strim [dbobj $theme get Name]] # the following seeks the first ampersand as the dividing point between # the category and subcategory. The failes when the category is "Audio & Video" #set ampindex [string first "&" $title] #if {$ampindex != -1} { # set query [string range $title [expr $ampindex + 2] end] #} else { # set query $title #} set query "" switch -exact $type { 1 { set query [strim [dbobj $theme get KeywordPhrase]] } 2 { set query [strim [dbobj $theme get Actor]] } 3 { set query [strim [dbobj $theme get Director]] } 6 { set query [strim [dbobj $theme get KeywordPhrase]] } 5 { set query "" } } set genre [dbobj $theme get GenreFilterPath] set cat [defaultval 0 [lindex $genre 0]] set scat [defaultval 0 [lindex $genre 1]] set query [string toupper [httpMapReply $query]] set url "/search?searchby=" set sp [dbobj $theme get SeasonPass] switch -exact $type { 1 {append url "3&q=$query&" } 2 {if { [string range $query [expr [string length $query] - 3] end] == "%09" } { append url "4&q=$query&" } else { append url "4&q=$query%09&" } } 3 {append url "5&q=$query&" } 6 {append url "1&q=$query&" } 5 {append url "0&q=&" } } append url "cat=$cat&scat=$scat" if {$type == 4} { # (Sorry, no link for Advanced wishlists! ;) set title1 $title } else { set title1 [html_link $url $title] } set imagestr "" if { $sp != "" } { set spfsid [dbobj $sp fsid] set imagestr [html_link "/editseasonpass/$spfsid" [img "alt=\"Edit Season Pass\"" $imagef]] } else { set imagestr [html_link "/add-theme-sp?id=$fsid" [img "alt=\"Click to convert to an auto-recording WishList\"" $imageg]] } set themestr [lindex $themetypes [expr $type - 1]] puts $chan [tr "" [td $imagestr] [td $title1] [td $themestr] [td [html_link "/delete-wishlist?id=$fsid" "Delete"]]] } puts $chan [html_table_end] puts $chan "<font size=2>To edit the Season Pass for an auto-recording WishList click on the star icon next to its name.<br>To make a WishList auto-record click the yellow dot next to its name.</font>" puts $chan "<p>" puts $chan [html_link "/showwishlists" "Show All WishList Matches"] puts $chan "<p>" 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 "width=98%" "" ""] 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 "width=98%" "" ""] 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 "width=98%" "" ""] 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 "width=98%" "" ""] 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 "width=98%" "" ""] 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 <aaron@schrab.com> proc alt_showing {tofind_tmsid tofind_fsid} { global db set showings [get_programshowings $tofind_fsid 1] foreach showing $showings { set seconds [lindex $showing 0] set stationfsid [lindex $showing 1] set date [expr $seconds / 86400] set time [expr $seconds % 86400] set timestr [format "%05d" $time] ForeachMfsFile recfsid name type "/Recording/Active" "4:$date:$timestr:" { RetryTransaction { set rec [db $db openid $recfsid] set show [dbobj $rec get Showing] set prog [dbobj $show get Program] set id [dbobj $prog get TmsId] if {$id == $tofind_tmsid} { return "todo [dbobj $show fsid]/[dbobj $show subobjid]" } } } } # Also check if it's in Now Showing ForeachMfsFile recfsid name type "/Recording/TmsId" "$tofind_tmsid:" { RetryTransaction { set rec [db $db openid $recfsid] set show [dbobj $rec get Showing] return "nowshowing [dbobj $show fsid]/[dbobj $show subobjid]" } } return "" } proc do_historyrow {infname} { upvar $infname inf return [tr "" [td [expr {$inf(imagef) == "" ? "" : [img {alt=""} $inf(imagef)]}]] [td $inf(day)] [td $inf(date)] [td "ALIGN=RIGHT NOWRAP" $inf(time)] [td $inf(channel)] [td $inf(title)] [td $inf(episode)]] } proc history_showinfo { show returninf } { global channeltablestation global channeltablestation_alt upvar $returninf inf set inf(showing) $show set inf(imagef) "" set prog [dbobj $show get Program] set inf(program) $prog set title [strim [dbobj $prog get Title]] set series [dbobj $prog get Series] set seriesfsid "" if { $series == "" } { set inf(title) $title set inf(isEpisode) 0 } else { set seriesfsid [dbobj $series fsid] set inf(title) [html_link "/series/$seriesfsid" $title] set inf(isEpisode) [defaultval 1 [dbobj $series get Episodic]] } #set inf(isEpisode) [defaultval 0 [dbobj $prog get IsEpisode]] set ep [get_verbose_title $prog $inf(isEpisode) 0] set fsid [dbobj $show fsid] set subid [dbobj $show subobjid] set desc [strim [dbobj $prog get Description]] set originalairdate [dbobj $prog get OriginalAirDate] if { $originalairdate != "" } { set originalairdatesecs [expr $originalairdate * 86400] if {$::lang == "en"} { set daystr [nth [clock format $originalairdatesecs -format "%e"]] set airdatestr [clock format $originalairdatesecs -format "$daystr %b %Y"] } else { set airdatestr [clock format $originalairdatesecs -format "%1m/%1d/%Y"] } } else { set airdatestr "" } if { $airdatestr != "" } { set hovertext "($airdatestr) $desc" } else { set hovertext $desc } set attrs [CreateHover $hovertext] ## Added desc_show -- SteveT set inf(episode) [html_link "/showing/$fsid/$subid" $ep $attrs][desc_show $hovertext] set station [dbobj $show get Station] set stationfsid [dbobj $station fsid] if { [catch {set data $channeltablestation($stationfsid)}] != 1 || [catch {set data $channeltablestation_alt($stationfsid)}] != 1 } { set callsign [lindex $data 2] } else { set callsign [dbobj $station get CallSign] } set inf(channel) [html_link "/channel/$stationfsid" $callsign] set seconds [expr [dbobj $show get Date] * 86400 + [dbobj $show get Time]] set inf(day) [ftime $seconds "%a"] if {$::lang == "en"} { set daystr [nth_sup [ftime $seconds "%e"]] set inf(date) [ftime $seconds "$daystr %b"] set inf(time) [ftime $seconds "%H:%M"] } else { set inf(date) [ftime $seconds "%1m/%1d"] set inf(time) [ftime $seconds "%l:%M %P"] } } proc history_rectype {recfsid} { global db global images # 10 = manual # 9 = single # 8 = sp # 7 = wl # 6 = suggestion # 3 = invisible or TiVo generated recordings set type 0 set rec [db $db openid $recfsid] if {$::version >= 3} { set recbeh [dbobj $rec get RecordingBehavior] set presbeh [dbobj $recbeh get PresentationBehavior] set progbeh [dbobj $recbeh get ProgramGuideBehavior] if { $progbeh == 3 || $progbeh == 8 } { set type 10 } else { switch -exact $presbeh { 1 { set type 9 } 2 { set type 8 } 3 { set type 7 } 6 { set type 6 } 9 { set type 9 } 10 { set type 10 } default { set type 3 } } } } else { set seltype [dbobj $rec get SelectionType] switch -exact $seltype { 3 { set type 9 } 5 { set type 10 } 6 { set type 6 } 9 { set type 8 } 10 { set type 8 } 13 { set type 7 } 11 { set type 9 } default { set type 3 } } } switch -exact $type { 8 { set i 11 } 7 { set i 13 } 6 { set i 10 } default { set i 1 } } return "$type [lindex $images $i]" } proc history_conflicts {fsid} { global db RetryTransaction { set rec [db $db openid $fsid] set spad [defaultval 0 [dbobj $rec get StartPadding]] set epad [defaultval 0 [dbobj $rec get EndPadding]] set show [dbobj $rec get Showing] set date [dbobj $show get Date] set time [dbobj $show get Time] set length [dbobj $show get Duration] set start [expr $date * 86400 + $time] set end [expr $start + $length + $epad] set start [expr $start - $spad] } set conflictlist [RecConflictsList $start $end] return [lindex $conflictlist 0] } proc action_history_detail {chan path env} { global db global images set f "COLSPAN=7 ALIGN=CENTER" set alt "" puts $chan [html_start "Recording History"] set fsid $path RetryTransaction { set rec [db $db openid $fsid] set rectype [lindex [history_rectype $fsid] 0] if {$::version >= 3} { set recprio [dbobj $rec get SubPriority] } else { set recprio [dbobj $rec get Score] } set creason [dbobj $rec get CancelReason] if {$creason == 20} { set confrec [dbobj $rec get ConflictsWithRecording] set confid [dbobj $confrec fsid] } set show [dbobj $rec get Showing] history_showinfo $show inf set id [dbobj $inf(program) get TmsId] set id2 [dbobj $inf(program) fsid] puts $chan [html_table_start "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th ""] [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [th "Program"] [th "Episode"]] puts $chan [do_historyrow inf] } # Default text about alternate showings. set altshow "another showing was scheduled recently" if {$inf(isEpisode) && $id != ""} { set alt [alt_showing $id $id2] if {$alt != ""} { set altid [lindex $alt 1] if {$altid != ""} { set altshow [html_link "/showing/$altid" "another showing"] if {[lindex $alt 0] == "nowshowing"} { append altshow " is already available." } else { append altshow " is scheduled." } } } } if {$creason == 2} { puts $chan [tr "" [th $f "won't be recorded because $altshow"]] } elseif {$creason == 10 || $creason == 20} { puts $chan [tr "" [th $f "won't be recorded because it conflicts with"]] set otherconflicts "" set conflicts [history_conflicts $fsid] # If nothing was found, it was probably cancelled recently. # Better to show what TiVo thought was conflicting than nothing if {$conflicts == ""} { set conflicts $confid } RetryTransaction { foreach c $conflicts { set other 0 set conftype [history_rectype $c] set type [lindex $conftype 0] if { $type > 4 } { set confrec [db $db openid $c] set confshow [dbobj $confrec get Showing] history_showinfo $confshow conf if {[dbobj $confrec get State] != 2} { set conf(imagef) [lindex $conftype 1] } set line [do_historyrow conf] if {($rectype == 7 || $rectype == 8) && ($type == 7 || $type == 8)} { if {$::version >= 3} { set confprio [dbobj $confrec get SubPriority] if {$confprio > $recprio} { set other 1 } } else { set confprio [dbobj $confrec get Score] if {$confprio < $recprio} { set other 1 } } } elseif { $type < $rectype } { set other 1 } if { $other } { append otherconflicts $line } else { puts $chan $line } } } } if {$otherconflicts != ""} { puts $chan [tr "" [th $f "it also conflicts with"]] puts $chan $otherconflicts } if {$alt != ""} { puts $chan [tr "" [th $f "But $altshow"]] } else { puts $chan [tr "" [th $f "No other showing is scheduled to be recorded"]] } } puts $chan [html_table_end] } proc init_db {} { global db global genrenums genrevals global showingbitnums showingbitvals global advisorynums advisoryvals global tvratingnums tvratingvals tvratingimages global mpaaratingnums mpaaratingvals mpaaratingimages global defrecquality global tivoswversion global datagroup global states global premieretypes global showtypes global presentationbehtypes global selectiontypes global showtypeindex global showtypeindexend global bitsindex global bitsindexend global avindex global avindexend global repeatindex global hdtvindex global liveindex global ccindex global images if {$::version >= 3} { RetryTransaction { set avconfig [db $db open /State/AvConfig] set defrecquality [defaultval 100 [dbobj $avconfig get RecordQuality]] set service [db $db open /State/ServiceConfig] set datagroup [dbobj $service get DataGroupList] } } else { RetryTransaction { set setup [db $db open /Setup] set defrecquality [defaultval 100 [dbobj $setup get RecordQuality]] set service [dbobj $setup get ServiceInfo] set datagroup [dbobj $service get DataGroupList] } } set selectiontypes "{Show Recommendation} {Package Recommendation} {By Name} {By Channel} Manual {Suggestion} {Fuzzy Package} Bookmark {Season Pass} {Manual Season Pass} Guide IPreview WishListPass Extended ManualExtended CaptureRequest DailyData" set presentationbehtypes "Single {Season Pass} Wishlist {Watch Only} {Tivo Clips} Suggestion {Tivo Clips Suggestion} Invisible {Manual Season Pass} Manual {Cache History}" set states "{To Do} Cancelled {In Progress} {Now Showing} Deleted {To Do} Allocated" set showtypes "Serial {Short Film} Special {Limited Series} Series Miniseries {Paid Programming}" set premieretypes "{Season Finale} {Series Finale} Premiere {Season Premiere} {Series Premiere}" if { [PrefixMatches "3." $tivoswversion] } { set images "ExpireNever-256.8.png SelectIcon-256.12.png" } elseif { [PrefixMatches "2.5.5" $tivoswversion] } { set images "ExpireNever-256.8.png SelectIcon-256.10.png" } else { set images "ExpireNever-256.8.png SelectIcon-256.9.png" } append images " ThumbUp2-256.8.png ExpireSoon-256.8.png ThumbDn1-256.8.png Expired-256.8.png ThumbDn2-256.8.png ThumbUp3-256.9.png Recording-256.9.png ThumbDn3-256.8.png TivoSuggest-256.8.png SeasonPass.9.png ThumbUp1-256.8.png WishListPass.2.png LargeSquarePredicted3DownThumbs.3.png LargeSquarePredicted2DownThumbs.3.png LargeSquarePredicted1DownThumbs.3.png LargeSquarePredicted1UpThumbs.3.png LargeSquarePredicted2UpThumbs.3.png LargeSquarePredicted3UpThumbs.3.png recycle1.png PaidSuggest-256.3.png" if { [PrefixMatches "4" $tivoswversion] } { set genres [GetResourceData 655360 655377 655495 1 0] } elseif { [PrefixMatches "3.0" $tivoswversion] } { set genres [GetResourceData 655360 655377 655495 1 0] } elseif { [PrefixMatches "2.5.2" $tivoswversion] } { set genres [GetDTivoGenres] } elseif { [PrefixMatches "2.5" $tivoswversion] } { set genres [GetResourceData 655360 655377 655495 1 0] } elseif { [PrefixMatches "2.0" $tivoswversion] } { set genres [GetResourceData 720896 720913 721031 1 0] } else { if {$::dtivo} { set genres [GetDTivoGenres] } else { set genres [GetSAGenres] } } set genrenums [lindex $genres 0] set genrevals [lindex $genres 1] #if { [PrefixMatches "2.5.1" $tivoswversion] } { # set tvratings [GetResourceData 851968 851993 851998 1 0] #} elseif { [PrefixMatches "2.0.1" $tivoswversion] } { # set tvratings [GetResourceData 983040 983065 983070 1 0] #} #set tvratingnums [lindex $tvratings 0] #set tvratingvals [lindex $tvratings 1] set tvratingnums "1 2 3 4 5 6" set tvratingvals "TV-Y7 TV-Y TV-G TV-PG TV-14 TV-MA" set tvratingimages "tvy7.png tvy.png tvg.png tvpg.png tv14.png tvma.png" #if { [PrefixMatches "2.5.1" $tivoswversion] } { # set showingbits [GetResourceData 1441792 1441843 1441863 0 1] #} elseif { [PrefixMatches "2.0.1" $tivoswversion] } { # set showingbits [GetResourceData 1572864 1572915 1572935 0 1] #} #set showingbitnums [lindex $showingbits 0] #set showingbitvals [lindex $showingbits 1] set showingbitnums "1 2 4 8 16 32 64 128 256 512 1024 65536 131072 262144 524288 1048576" set showingbitvals "CC Stereo Sub {In Prog} Class SAP Blackout Intercast {Three D} R Letterbox S V L D FV" #if { [PrefixMatches "2.5.1" $tivoswversion] } { # set advisorys [GetResourceData 917504 917533 917542 1 0] #} elseif { [PrefixMatches "2.0.1" $tivoswversion] } { # set advisorys [GetResourceData 1048576 1048605 1048614 1 0] #} #set advisorynums [lindex $advisorys 0] #set advisoryvals [lindex $advisorys 1] set advisorynums "1 2 3 4 5 6 7 8 9 10" set advisoryvals "AL GL N BN GV V MV SC RP AC" #set mpaaratings [GetResourceData 65536 65567 65578 1 0] #set mpaaratingnums [lindex $mpaaratings 0] #set mpaaratingvals [lindex $mpaaratings 1] set mpaaratingnums "1 2 3 4 5 6 7 8 9 10 11 12" set mpaaratingvals "G PG PG-13 R X NC-17 AO {Rated NR} U 12 15 18" set mpaaratingimages "MPAA_G.png MPAA_PG.png MPAA_PG-13.png MPAA_R.png MPAA_NC-17.png MPAA_AO.png MPAA_X.png MPAA_NR.png" if { $::dtivo } { set showtypeindex [lsearch $genrevals "Show Types"] set showtypeindexend [lsearch $genrevals "Talk"] set bitsindex [lsearch $genrevals "All Day Ticket"] set bitsindexend [lsearch $genrevals "Season Premiere"] set avindex [lsearch $genrevals "Audio & Video"] set avindexend [lsearch $genrevals "Widescreen"] # must use indirection to get a value that will identify the repeat marker set repeatindex [lindex $genrenums [lsearch $genrevals "Repeat"]] # must use indirection to get a value that will identify the hdtv marker set hdtvindex [lindex $genrenums [lsearch $genrevals "HDTV"]] set liveindex [lindex $genrenums [lsearch $genrevals "Live"]] set ccindex [lindex $genrenums [lsearch $genrevals "CC"]] } else { set showtypeindex -1 set showtypeindexend -1 set bitsindex -1 set bitsindexend -1 set avindex -1 set avindexend -1 set repeatindex -1 set hdtvindex -1 set liveindex -1 set ccindex -1 } GenerateCategorySubCategoryJS } # Replaces cancelreasons global variable proc UIGetCancelReason { item } { return [lindex {{Switched To Live TV} {Recorded A Different Showing} {Stayed On Live TV} {Internal Error} {Power Was Off} Expired {Got A Better Suggestion} {Demo Mode} {Unexpected Conflict} {User Requested Recording} {User Requested Season Pass} {Explicitly Deleted} {Channel Lineup Changed} {Program Guide Changed} {Recorder Emergency} {User Cancelled Season Pass} {Fuzzies Turned Off} {Fuzzy Stopped Early} Unknown {Program Source Conflict} {Converted Live Cache} {Live Cache Only Successful} {Program So urce Disk Conflict} {Explicitly Deleted From To Do} {Program Source Modified} {Not Authorized} {No Re-record} {No Signal} {Max Recordings Exceeded} {Capture Request Expired} {No Signal Tuner One} {No Signal Tuner Two} {Max Recordings Now Showing} {Video Manager Denied Tuner}} $item] } proc action_history {chan path env} { global db global filter if {[string index $path 0] == "/"} { set path [string range $path 1 end] } if {$path == ""} { puts $chan [html_start "Recording History"] puts $chan [html_form_hidden backPath $path] puts $chan [html_form_end] puts $chan [html_table_start "" "" ""] puts $chan [tr "ALIGN=CENTER" [th "Recording History"]] puts $chan [tr "" [td [html_link "/history/list/0,5" "Next 5 days"]]] puts $chan [tr "" [td [html_link "/history/list/future" "All future"]]] puts $chan [tr "" [td [html_link "/history/list/-5,0" "Past 5 days"]]] puts $chan [tr "" [td [html_link "/history/list/past" "All past"]]] puts $chan [tr "" [td [html_link "/history/list/all" "All"]]] puts $chan [tr "" [td [html_link "/filter" "View/Change Filter"]]] puts $chan [html_table_end] puts $chan [html_end] return } else { set spath [split $path /] set path [join [lrange $spath 1 end] /] switch -exact [lindex $spath 0] { detail { action_history_detail $chan $path $env return } list { set now [clock seconds] switch -exact -- $path { all { set mintime 0 set maxtime 2147483647 } "future" { set mintime $now set maxtime 2147483647 } past { set mintime 0 set maxtime $now } default { set range [split $path ,] set mintime [expr $now + [lindex $range 0] * 86400] set maxtime [expr $now + [lindex $range 1] * 86400] } } } default { print_html_header_404 $chan return } } } puts $chan [html_start "Recording History"] # Added by Lenroc for TWP filtering of Recording History # Shows a form to edit the filter. If there is a filter in place, also allows the user to clear it. puts $chan [html_form_start "POST" "/filter"] puts $chan [html_form_hidden backPath $path] if { $filter == "" } { set filtering 0 } else { set filtering 1 } puts $chan "Filtering is " if { !$filtering } { puts $chan "not"} puts $chan "active. " puts $chan [html_form_input "submit" "submit" "Edit Filter"] if { $filtering } { puts $chan " | " puts $chan [html_form_input "submit" "submit" "Clear Filter"] } puts $chan [html_table_start "width=98%" "" ""] puts $chan [tr "ALIGN=CENTER" [th "COLSPAN=2" "Date"] [th "Time"] [th "Chan"] [th "Program"] [th "Episode"] [th "Reason"]] ForeachMfsFile fsid name type "/Recording/History" "" { set alt "" set recdate [split $name ":"] regsub {^(-?)0+([1-9])} [lindex $recdate 1] {\1\2} rectime set rectime [expr [lindex $recdate 0] * 86400 + $rectime] if {$rectime > $mintime && $rectime < $maxtime} { RetryTransaction { set rec [db $db openid $fsid ] set creason [dbobj $rec get CancelReason] set show [dbobj $rec get Showing] history_showinfo $show inf set id [dbobj $inf(program) get TmsId] set id2 [dbobj $inf(program) fsid] } set findalt 0 switch $creason { 2 { set reason [html_link "/history/detail/$fsid" "Duplicate"] } 5 { set reason "Power Was Off" ; set findalt 1 } 12 { set reason "Deleted" } 14 { set reason "no longer in program guide" ; set findalt 1 } 16 { set reason "Cancelled season pass" } 10 - 20 { set reason [html_link "/history/detail/$fsid" "Conflict"] set findalt 1 } 23 { set reason "Not enough space" } 24 { set reason "Cancelled recording" } 25 { set reason "Season pass modified" } default { set reason [UIGetCancelReason [expr $creason - 1]] } } if {$findalt == 1 && $inf(isEpisode) && $id != ""} { set alt [alt_showing $id $id2] if {$alt == ""} { set reason "<b>$reason</b>" } else { if {[lindex $alt 0] == "nowshowing"} { set alttext "available" } else { set alttext "scheduled" } set alt [lindex $alt 1] set alt [html_link "/showing/$alt" "alternate $alttext"] append reason " ($alt)" } } # Added by Lenroc for TWP filtering of Recording History. if { [string last ",alt," $filter]==-1 || $alt=="" } { # Only passes if $alt=="", meaning that it's an unresolved conflict, OR if "alt" is not in $filter, meaning we aren't trying to filter out resolved conflicts anyway if {[string last ",$creason," $filter] == -1} { # Only prints if $creason is not in $filter, meaning that it's a reason we want to see puts $chan [tr "" [td $inf(day)] [td "NOWRAP" $inf(date)] [td "ALIGN=RIGHT NOWRAP" $inf(time)] [td $inf(channel)] [td $inf(title)] [td $inf(episode)] [td $reason]] } } } } puts $chan [html_table_end] puts $chan [html_end] } proc action_filter {chan path env} { # By Lenroc for TWP filtering of Recording History # The filter editing page # This is where the user is taken if they click "Edit Filter" or # "Clear Filter" from the Recording History list, or the "View/Edit # Filter" link under "User Interface", "Recording History". # Based on the button they clicked, either the $filter will be # cleared (set to ""), or the user will be presented with a GUI # to edit the filter. global filter set submit "" set backPath "" eval $env if { [string last "Clear" $submit] != -1 } { set filter "" puts $chan [html_start "Filter Cleared"] puts $chan "<meta http-equiv=\"refresh\" content=\"4;URL=/history/list/$backPath\" />" puts $chan "Your filter has been cleared. You can reload TivoWeb to bring back the previous Filter." puts $chan "<P>You will be taken back shortly, or you can " puts $chan [html_link "/history/list/$backPath" "go back yourself"] puts $chan "." puts $chan [html_end] } else { puts $chan [html_start "Filtering"] puts $chan "<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" puts $chan "<META HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no-cache\">" puts $chan "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" puts $chan "<meta http-equiv=\"expires\" content=\"FRI, 13 APR 1999 01:00:00 GMT\">" puts $chan [html_form_start "POST" "/editfilter"] puts $chan [html_table_start "" "Edit Filter Settings" "COLSPAN=2"] puts $chan [tr "" [th "Reason"] [th "Hide"]] puts $chan [tr "" [td "Cancelled recording"] [td "ALIGN=CENTER" [html_form_checkbox "24" [checked 24]]]] puts $chan [tr "" [td "Cancelled season pass"] [td "ALIGN=CENTER" [html_form_checkbox "16" [checked 16]]]] puts $chan [tr "" [td "Conflict, Resolved"] [td "ALIGN=CENTER" [html_form_checkbox "alt" [checked alt]]]] puts $chan [tr "" [td "Conflict, Unresolved"] [td "ALIGN=CENTER" [html_form_checkbox "con" [checked con]]]] puts $chan [tr "" [td "Deleted"] [td "ALIGN=CENTER" [html_form_checkbox "12" [checked 12]]]] puts $chan [tr "" [td "Duplicate"] [td "ALIGN=CENTER" [html_form_checkbox "2" [checked 2]]]] puts $chan [tr "" [td "MaxRecordingsExceeded"] [td "ALIGN=CENTER" [html_form_checkbox "29" [checked 29]]]] puts $chan [tr "" [td "MaxShowingsNowPlaying"] [td "ALIGN=CENTER" [html_form_checkbox "33" [checked 33]]]] puts $chan [tr "" [td "No longer in program guide"] [td "ALIGN=CENTER" [html_form_checkbox "14" [checked 14]]]] puts $chan [tr "" [td "Not enough space"] [td "ALIGN=CENTER" [html_form_checkbox "23" [checked 23]]]] puts $chan [tr "" [td "Power Was Off"] [td "ALIGN=CENTER" [html_form_checkbox "5" [checked 5]]]] puts $chan [tr "" [td "Season pass modified"] [td "ALIGN=CENTER" [html_form_checkbox "25" [checked 25]]]] puts $chan [html_table_end] puts $chan [html_form_input "submit" "submit" "Apply Now"] puts $chan [html_link "javascript:history.go(-1)" "Cancel"] puts $chan "<P>To filter out a class of entries in the Recording History, place a checkmark in the appropriate box above, and click \"Apply Now\"." if {$backPath != ""} { puts $chan [html_form_hidden backPath $backPath] } puts $chan [html_form_end] puts $chan "The current filter is:<p align=center>Filter = " puts $chan $filter puts $chan [html_end] } } proc checked {reason} { # By Lenroc for TWP filtering of Recording History # A utility proc used by action_filter # Returns "yes" if the $reason passed in is currently in the filter # which means that it should be checked when displaying the filter GUI # Needed because the html_form_checkbox proc in html.itcl doesn't accept a boolean # value for it's checked parameter, rather it checks the new checkbox if any parameter is passed in. global filter set checked "" if { [string last ",$reason," $filter] != -1 } { set checked "yes" } if { [string compare "con" $reason] == 0 } { if { [string last ",10," $filter] != -1 || [string last ",20," $filter] != -1 } { set checked "yes" } } return $checked } proc action_editfilter {chan path env} { # By Lenroc for TWP filtering of Recording History # A utility proc used by action_filter. This is where the user is sent # after clicking "Apply". This takes the form data submitted by # action_filter, parses it, and sets the current $filter to the one # selected by the user. # Contains a Meta-Redirect to send the user back quickly after applying # the filter, only if they were originally browsing the Recording History # when they clicked "Edit Filter". If they were editing the filter from # the "User Interface" > "Recording History" > "View/Edit Filter", then # it will show them the new filter but not go back automatically. global filter set backPath "" eval $env regsub -all -- "\" \"on\"\;set \"" $env "," newFilter regsub "set \"backPath\" .*\;" $newFilter "" newFilter regsub "submit\" \"Apply Now\"\;" $newFilter "" newFilter regsub "set \"" $newFilter "," newFilter regsub ",con," $newFilter ",10,20," newFilter puts $chan [html_start "Filter Setting Changed"] if { $newFilter == "," } { set filter "" } else { set filter $newFilter } updateconfig "Filter" $filter if { $backPath != "" } { puts $chan "<meta http-equiv=\"refresh\" content=\"3;URL=/history/list/$backPath\" />" puts $chan "Your new filter has been applied. You will be taken back shortly, or you can " puts $chan [html_link "/history/list/$backPath" "go back now"] } else { puts $chan "Your new Filter has been Applied.<P>" puts $chan [html_link "/history" "Done"] } puts $chan [html_end] } ########################################## proc action_ui {chan path env} { global db global ui_submenu if {[string index $path 0] == "/"} { set path [string range $path 1 end] } if {$path == ""} { puts $chan [html_start "User Interface" $ui_submenu] puts $chan [html_table_start "" "" "ALIGN=TOP"] puts $chan [tr "" [th "" "User Interface"]] puts $chan [tr "" [td [html_link "/ui/seasonpass" "Season Pass"]]] puts $chan [tr "" [td [html_link "/nowshowing" "Now Playing"]]] puts $chan [tr "" [td [html_link "/ui/todo" "ToDo"]]] puts $chan [tr "" [td [html_link "/ui/suggestions" "Scheduled Suggestions"]]] puts $chan [tr "" [td [html_link "/ui/pending" "Suggestions"]]] puts $chan [tr "" [td [html_link "/ui/deletedshows" "Deleted Shows"]]] puts $chan [tr "" [td [html_link "/ui/preferences" "Preferences"]]] puts $chan [tr "" [td [html_link "/ui/channellist" "Channel Guide"]]] #puts $chan [tr "" [td [html_link "/ui/space" "Space Usage"]]] puts $chan [tr "" [td [html_link "/ui/wishlists" "WishLists"]]] puts $chan [tr "" [td [html_link "/history" "Recording History"]]] puts -nonewline $chan [html_table_end] puts $chan [html_end] } elseif {$path == "todo"} { if {$::multi_delete} { action_todo $chan 7 $env } else { action_todo $chan 0 $env } } elseif {$path == "suggestions"} { if {$::multi_delete} { action_todo $chan 8 $env } else { action_todo $chan 1 $env } } elseif {$path == "pending"} { action_todo $chan 2 $env } elseif {$path == "seasonpass"} { action_seasonpass $chan "" $env } elseif {$path == "channellist"} { action_channellist $chan "" $env } elseif {$path == "preferences"} { action_preferences $chan "" $env #} elseif {$path == "space"} { # action_space $chan "" $env } elseif {$path == "deletedshows"} { action_deletedshows $chan "" $env } elseif {$path == "wishlists"} { action_wishlists $chan "" $env } } proc GetDTivoGenres { } { global db set keys "" RetryTransaction { set apgboot [db $db open /ApgBoot] set categorysystem [dbobj $apgboot get RootCategorySystem] set labels [dbobj $categorysystem get Labels] foreach clabel $labels { set index [dbobj $clabel get Index] #set fcoreset [dbobj $clabel get FCoreSet] if {$index != 0 && [lsearch $keys $index] == -1} { set vlabel [strim [dbobj $clabel get Label]] lappend keys $index lappend vals $vlabel } set subcat [dbobj $clabel get Subcategory] if {$subcat != ""} { set labels2 [dbobj $subcat get Labels] foreach clabel2 $labels2 { set index [dbobj $clabel2 get Index] #set fcoreset [dbobj $clabel2 get FCoreSet] if {$index != 0 && [lsearch $keys $index] == -1} { set vlabel [strim [dbobj $clabel2 get Label]] lappend keys $index lappend vals $vlabel } } } } } return [list $keys $vals] } proc GetSAGenres { } { global db set keys "" set vals "" if {[MfsFileExists /DataSet/GenreVersion]} { RetryTransaction { set dataset [db $db open /DataSet/GenreVersion] set genres [dbobj $dataset gettarget Data] } set incrsize 50 foreach genrefsid $genres { regsub {/-1$} $genrefsid {} fsid set done 0 set idx 0 while {!$done} { RetryTransaction { set genre [db $db openid $fsid] set subgenres [dbobj $genre gettarget Child] set numsubs [llength $subgenres] if {$subgenres != ""} { set maxcount [expr ($numsubs > $idx + $incrsize) ? ($idx + $incrsize) : $numsubs] for {set i $idx} {$i < $maxcount} {incr i} { set subgenre [dbobj $genre get Child $i] set index [dbobj $subgenre get Value] if {$index != 0 && [lsearch $keys $index] == -1} { set vlabel [strim [dbobj $subgenre get Name]] lappend keys $index lappend vals $vlabel } } if {$numsubs == $maxcount} { set done 1 } else { incr idx $incrsize } } else { set done 1 } } } } } return [list $keys $vals] } proc GetResourceData { refid startid endid startindex bits } { global db set keys "" set vals "" RetryTransaction { set sws [db $db open /SwSystem/ACTIVE] set offset [expr $refid/65536 - 1] set resource [dbobj $sws get ResourceGroup $offset] set id [dbobj $resource get Id] if { $id == $refid } { set items [dbobj $resource get Item] foreach item $items { set id [dbobj $item get Id] if { $id >= $startid && $id <= $endid } { if { $bits == 1 } { set value [expr 1 << ($id - $startid + $startindex)] } else { set value [expr $id - $startid + $startindex] } set strval [strim [dbobj $item get String]] if { $strval != "" } { lappend keys $value lappend vals $strval } } } } else { error "Error: refid didn't match" } } return [list $keys $vals] } proc GenerateCategorySubCategoryJS { } { global source_dir global genrenums genrevals set categoriesIndex -1 set subcategoriesIndex 0 set categoriesStr "" set subCategoriesStr "" set groupStr "" set groupCatStr "" set firstGroupCatStr "" set currentCategoryNum 0 foreach genrenum $genrenums genreval $genrevals { if {$genrenum < 32} { # we have found a new category incr categoriesIndex if {$groupStr != ""} { # insert the movie set of indexes into the theme array if {$currentCategoryNum == 9 && $groupCatStr == ""} { set groupCatStr $firstGroupCatStr } # ( append groupStr "$groupCatStr\)\n" } if {$firstGroupCatStr == ""} { # we need to save the movie set of indexes since Themes use the same subcategories set firstGroupCatStr $groupCatStr } set groupCatStr "" append categoriesStr "categories\[$categoriesIndex\] = \"[strim $genreval]\"\n" append categoriesStr "categoriesval\[$categoriesIndex\] = \"$genrenum\"\n" append groupStr "group\[[expr $categoriesIndex + 1]\] = new Array\(" # ) set currentCategoryNum $genrenum } else { incr subcategoriesIndex append subCategoriesStr "subcategories\[$subcategoriesIndex\] = \"[strim $genreval]\"\n" append subCategoriesStr "subcategoriesval\[$subcategoriesIndex\] = \"$genrenum\"\n" if {$groupCatStr == ""} { append groupCatStr $subcategoriesIndex } else { append groupCatStr ", $subcategoriesIndex" } } } incr categoriesIndex # ( append groupStr "$groupCatStr\)\n" set groupStr "var group = new Array\([expr $categoriesIndex + 1]\)\ngroup\[0\] = new Array\(\)\n$groupStr\n" set categoriesStr "var categories = new Array\($categoriesIndex\)\nvar categoriesval = new Array\($categoriesIndex\)\n$categoriesStr\n" incr subcategoriesIndex set subCategoriesStr "var subcategories = new Array\($subcategoriesIndex\)\nvar subcategoriesval = new Array\($subcategoriesIndex\)\n$subCategoriesStr\n" set genericGenreFile "$source_dir/scripts/genericgenre.js" append jsString "function loadgenre(x, y) \{\n" append jsString " var cat = document.search.cat\n" append jsString " var scat = document.search.scat\n" append jsString " var m,i\n" append jsString "\n" append jsString " for (m = cat.options.length - 1; m > 0; m--)\n" append jsString " cat.options\[m\] = null\n" append jsString " cat.options\[0\] = new Option(\"All\", 0)\n" append jsString " for (i = 0; i < categories.length; i++) \{\n" append jsString " cat.options\[i+1\] = new Option(categories\[i\], categoriesval\[i\])\n" append jsString " if (categoriesval\[i\] == x) \{\n" append jsString " cat.options\[i+1\].selected = true\n" append jsString " loadscat(i + 1)\n" append jsString " \}\n" append jsString " \}\n" append jsString " if (x == 0) \{\n" append jsString " cat.options\[0\].selected = true\n" append jsString " \} else \{\n" append jsString " for (m = scat.options.length - 1; m > 0; m--) \{\n" append jsString " if (scat.options\[m\].value == y)\n" append jsString " scat.options\[m\].selected = true\n" append jsString " \}\n" append jsString " \}\n" append jsString "\n" append jsString "\}\n" append jsString "\n" append jsString "function loadscat(x) \{\n" append jsString " var scat = document.search.scat\n" append jsString " var m,i\n" append jsString " var y = scat.value\n" append jsString "\n" append jsString " for (m = scat.options.length - 1; m > 0; m--)\n" append jsString " scat.options\[m\] = null\n" append jsString " scat.options\[0\] = new Option(\"Don't specify a sub-category\", 0)\n" append jsString " scat.options\[0\].selected = true\n" append jsString " for (i = 0; i < group\[x\].length; i++) \{\n" append jsString " scat.options\[i+1\] = new Option(subcategories\[group\[x\]\[i\]\], subcategoriesval\[group\[x\]\[i\]\])\n" append jsString " if (scat.options\[i+1\].value == y) \{\n" append jsString " scat.options\[i+1\].selected = true\n" append jsString " \}\n" append jsString " \}\n" append jsString "\}\n" append jsString "\n" catch { set writefile [open $genericGenreFile w] puts $writefile $categoriesStr puts $writefile $subCategoriesStr puts $writefile $groupStr puts $writefile $jsString close $writefile } } global ui_submenu set ui_submenu "" #set ui_submenu "[html_link "/ui/seasonpass" "Season Pass"] [html_link "/ui/nowshowing" "Now Showing"] [html_link "/ui/todo" "ToDo"] [html_link "/ui/suggestions" "Scheduled Suggestions"] [html_link "/ui/pending" "Suggestions"] [html_link "/ui/preferences" "Preferences"] [html_link "/ui/channellist" "Channel Guide"] [html_link "/ui/wishlists" "WishLists"]" if { $reload == 0 } { init_db } register_module "ui" "User Interface" "A Web-based Clone of the TiVo UI, with Filtering"