# This is a modified version of http://blog.durdle.com/nowplayingrss proc print_rssrow {chan rec view} { global tzoffset global show_tivor set showing [dbobj $rec get Showing] set showingfsid [dbobj $rec gettarget Showing] set program [dbobj $showing get Program] set title [strim [dbobj $program get Title]] set station [dbobj $showing get Station] set callsign [dbobj $station get CallSign] if { $callsign == "TIVOR" && $show_tivor == 0 } {return} 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 == 1 } { set eptitle [strim [dbobj $program get EpisodeTitle]] if {$eptitle != ""} { set eptitle "\"$eptitle\" " } } else { set eptitle "" } set seconds [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time] + $tzoffset] set timestr [clock format [expr [dbobj $showing get Date] * 86400 + [dbobj $showing get Time]] -format "%a, %d %b %Y %T GMT"] set entrylink "http://$::HTTP_HOST/showing/$showingfsid" puts $chan "" puts -nonewline $chan "<!\[CDATA\[$title\]\]>" puts $chan "$entrylink" puts -nonewline $chan "-View-" } puts -nonewline $chan "\]\]>" puts $chan "$entrylink" puts $chan "$timestr" puts $chan "" } proc rss_feed {chan desc url path prefix view} { global db puts $chan "" puts $chan "" puts $chan "" puts $chan "" puts $chan "Tivo $desc" puts $chan "http://$::HTTP_HOST/$url" puts $chan "TiVo $desc list" puts $chan "en-us" puts $chan "[clock format [clock seconds] -format "%a, %d %b %Y %T GMT"]" puts $chan "http://www.tivocommunity.com/tivo-vb/showthread.php?t=271578" puts $chan "NowPlayingRSS (http://blog.durdle.com/nowplayingrss/)" ForeachMfsFileTrans fsid name type $path $prefix 15 { set rec [db $db openid $fsid] print_rssrow $chan $rec $view } puts $chan "" puts $chan "" } proc action_rss {chan path env} { global nowshowingdir if {[string index $path 0] == "/"} { set path [string range $path 1 end] if {$path != ""} { if {[string range $path 0 9] == "nowplaying"} { rss_feed $chan "Now Playing" "nowshowing" $nowshowingdir "" 1 } elseif {[string range $path 0 3] == "todo"} { rss_feed $chan "ToDo" "ui/todo" "/Recording/Active" "4" 0 } } else { puts $chan [html_start ""] puts $chan [html_link "nowplaying.rss" "NowPlaying"] puts $chan " | [html_link "todo.rss" "ToDo"]" puts $chan [html_end] } } } proc serve_rss {chan feed head_req last_modified} { global nowshowingdir if {$feed == "nowplaying.rss"} { print_html_header_200 $chan "text/xml" [clock seconds] rss_feed $chan "Now Playing" "nowshowing" $nowshowingdir "" 1 } elseif {$feed == "todo.rss"} { print_html_header_200 $chan "text/xml" [clock seconds] rss_feed $chan "ToDo" "ui/todo" "/Recording/Active" "4" 0 } else { print_html_header_404 $chan } } register_content_handler "rss" "text/xml" "" 0 serve_rss register_content_handler "xsl" "text/xml" "$source_dir/themes" 0 serve_file register_module "rss" "RSS" "RSS Feeds"