proc rsstv_make_feed {title link description view {order asc}} { dom createDocument rss doc set rss [$doc documentElement] $rss setAttribute version 2.0 $rss setAttribute xmlns:tv http://www.grumet.net/rsstv set channel [$doc createElement channel] $rss appendChild $channel $channel appendChild [xmltv_simpleTextElement $doc title $title] $channel appendChild [xmltv_simpleTextElement $doc link $link] $channel appendChild [xmltv_simpleTextElement $doc description $description] $channel appendChild [xmltv_simpleTextElement $doc pubDate [rsstv_rfc822date [ns_time]]] $channel appendChild [xmltv_simpleTextElement $doc managingEditor aegrumet@alum.mit.edu] db_foreach q " select title, sub_title, description, tvchannel, to_char(when_start,'YYYYMMDDHH24MISS TZHTZM') as when_start, to_char(when_stop,'YYYYMMDDHH24MISS TZHTZM') as when_stop, to_char(case when when_order_by > sysdate then sysdate else when_order_by end,'Dy, DD Mon YYYY HH24:MI:SS TZHTZM') as pub_date from rsstv_feed_$view order by when_order_by $order " { set item [$doc createElement item] $item appendChild [xmltv_simpleTextElement $doc title $title] $item appendChild [xmltv_simpleTextElement $doc description $description] $item appendChild [xmltv_simpleTextElement $doc pubDate $pub_date] if { ![string equal $sub_title ""] } { $item appendChild [xmltv_simpleTextElement $doc tv:sub-title $sub_title] } $item appendChild [xmltv_simpleTextElement $doc tv:tvchannel $tvchannel] $item appendChild [xmltv_simpleTextElement $doc tv:start "$when_start"] $item appendChild [xmltv_simpleTextElement $doc tv:stop "$when_stop"] set guid [xmltv_simpleTextElement $doc guid "$tvchannel|$when_start"] $guid setAttribute isPermaLink false $item appendChild $guid $channel appendChild $item } return [$doc asXML] } proc rsstv_rfc822date seconds { return [ns_fmttime $seconds "%a, %d %b %Y %T %Z"] } proc xmltv_simpleTextElement {doc name value} { set element_node [$doc createElement $name] set value_node [$doc createTextNode $value] $element_node appendChild $value_node return $element_node } proc xmltv_ConanXML {} { dom createDocument rss doc set rss [$doc documentElement] $rss setAttribute version 2.0 $rss setAttribute xmlns:tv http://www.grumet.net/rsstv set channel [$doc createElement channel] $rss appendChild $channel $channel appendChild [xmltv_simpleTextElement $doc title {Non-broken Conan O'Brien Season Pass}] $channel appendChild [xmltv_simpleTextElement $doc link {http://www.grumet.net/rsstv/}] $channel appendChild [xmltv_simpleTextElement $doc description {New showings of Late Night with Conan O'Brien that begin between 12:35am and 12:40am Eastern.}] $channel appendChild [xmltv_simpleTextElement $doc pubDate [rsstv_rfc822date [ns_time]]] $channel appendChild [xmltv_simpleTextElement $doc managingEditor aegrumet@alum.mit.edu] db_foreach q { select title, description, channel as tvchannel, to_char(when_start,'YYYYMMDDHH24MISS TZD') as when_start, to_char(when_stop,'YYYYMMDDHH24MISS TZD') as when_stop from xmltv_programmes where title = 'Late Night With Conan O''Brien' and to_char(when_start,'HH24MI') between 35 and 40 and previously_shown_p = 'f' order by when_start asc } { set item [$doc createElement item] $item appendChild [xmltv_simpleTextElement $doc title $title] $item appendChild [xmltv_simpleTextElement $doc description $description] $item appendChild [xmltv_simpleTextElement $doc tv:tvchannel $tvchannel] $item appendChild [xmltv_simpleTextElement $doc tv:start "$when_start"] $item appendChild [xmltv_simpleTextElement $doc tv:stop "$when_stop"] set guid [xmltv_simpleTextElement $doc guid "$tvchannel|$when_start"] $guid setAttribute isPermaLink false $item appendChild $guid $channel appendChild $item } return [$doc asXML] }