variable compat "2.1.b3" # This is a modified version of http://blog.durdle.com/nowplayingrss # content servers aren't auto-loaded, so moved them to rss_util.tcl --btux9 # modified to use djl's rss routines --btux9 register_menu "rss" "RSS" "RSS Feeds" {nowplaying.rss NPL-RSS "Now Playing RSS" todo.rss ToDo-RSS "To-Do RSS"} proc action_rss {chan path env} { puts $chan [f_menu rss][main_menu rss] } proc rss_feed {chan desc module path prefix view} { print_html_header_200 $chan "text/xml" [clock seconds] puts $chan [rss_start $module "TiVo $desc"] ForeachMfsFileTrans fsid name type $path $prefix 15 { set rec [db $::db openid $fsid] set showing [dbobj $rec get Showing] set station [dbobj $showing get Station] set callsign [dbobj $station get CallSign] ##TODO - support todo blocklist, obviate ShowTivorEntries config item if { $callsign != "TIVOR" || $::conf(ShowTivorEntries) } { set showingfsid [dbobj $rec gettarget Showing] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set manual 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 || $progbeh == 3 || $progbeh == 8 } { set manual 1 } } else { set seltype [dbobj $rec get SelectionType] if { $seltype == 10 || $seltype == 5 } { set manual 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 series [dbobj $program get Series] #set isepisode [dbobj $program get IsEpisode] if {$series != ""} { set episodic [defaultval 1 [dbobj $series get Episodic]] } else { set episodic 1 } if { $episodic } { set txt [strim [dbobj $program get EpisodeTitle]] if {$txt != ""} { set txt "\"$txt\" " } } else { set txt "" } set desc [strim [dbobj $program get Description]] if {$desc == "" } { append txt " No Description" } else { append txt " $desc" } if {$view} { append txt "\n[rss_link /$fsid.asx "-View-" ] " } set time [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time]] puts $chan [rss_item $title $txt "/showing/$showingfsid" $time] } } } proc action_.rss {chan path env} { set feed [file rootname [file tail $path]] if {$feed == "nowplaying"} { rss_feed $chan "Now Playing" $feed $::nowshowingdir "" 1 } elseif {$feed == "todo"} { rss_feed $chan "ToDo" $feed "/Recording/Active" "4" 0 } else { return [do_action rss_$feed $chan $path $env] } return 0 } # rss functions added by DJL 10/07 # updated by BTUx9, 11/07 ################################################################## proc rss_start {{feed ""} {title "RSS Feed"} {desc ""} {docs "http://dealdatabase.com/forum"} {image "/images/Gallery/liltivo.jpg"}} { upvar #1 h_end h set h {} if {$desc==""} {set desc "Generated by \[$::hostname\] at http://$::HTTP_HOST"} set modlink [rss_link /$feed.rss] set build [clock format [clock seconds] -format "%a, %d %h %Y %T GMT"] return " $title $modlink $desc en-us $build $docs TivoWebPlus $::TWP(VERSION) [rss_link $image] $title $modlink " } proc rss_item {title desc link {pubtime ""} {guid 0}} { if {$title == ""} return regsub -all "\n" $desc "
\n" desc #~ { #~ set pubdate [clock scan $pubdate] #~ } set ret "[ctag title $title][ctag description $desc][tag link [rss_link $link]]" if {$pubtime != ""} { append ret " [tag pubDate [clock format $pubtime -format "%a, %d %b %Y %T GMT"]]" } if {$guid} {append ret "$pubtime@$title"} return [tag item $ret] } proc rss_link {link {anchor ""} args} { # if anchor is blank, just return the full http:// link, with no tag if { [string index $link 0] == "/" } { set link "http://$::HTTP_HOST$::conf(Prefix)/[string range $link 1 end]" } if {$anchor==""} { return $link } return "$anchor" } proc ctag {tag args} { # this is a CDATA tag, used in rss feeds return "<$tag>" }