5 Cent tip for today [ RSS Ticker ]

Started by newdep, July 24, 2004, 11:04:41 AM

Previous topic - Next topic

newdep

As a followup on the RSS feeder here a ticker version...

Hope you enjoy it...





#!/usr/bin/newlisp

;;

;; RSS Ticker v1.0 (c) Norman 2004

;;

;; Displays RSS Feed titels in your terminal screen

;; by using tput codes.

;;

;; Linux terminal version with ANSI and tput required

;;

;;

;; Usage:  "rss-ticker &"

;;

;;

;; enjoy... Norman 2004

;;



(set 'uri '(

"http://nu.nl/deeplink_rss2/index.jsp?r=Algemeen">http://nu.nl/deeplink_rss2/index.jsp?r=Algemeen"

"http://nu.nl/deeplink_rss2/index.jsp?r=Internet">http://nu.nl/deeplink_rss2/index.jsp?r=Internet"

"http://newlisp.org/blog/rss.cgi">http://newlisp.org/blog/rss.cgi"

"http://newlisp.org/rss.cgi?News">http://newlisp.org/rss.cgi?News"

"http://rss.news.yahoo.com/rss/linux">http://rss.news.yahoo.com/rss/linux"

"http://rss.news.yahoo.com/rss/science">http://rss.news.yahoo.com/rss/science"

"http://www.vpro.nl/cinema/binders/rss/index.jsp">http://www.vpro.nl/cinema/binders/rss/index.jsp"

"http://www.vpro.nl/cinema/includes_televisie/rss/index.jsp">http://www.vpro.nl/cinema/includes_tele ... /index.jsp">http://www.vpro.nl/cinema/includes_televisie/rss/index.jsp"

"http://www.vpro.nl/cinema/magazines/rss/index.jsp?newstype=1">http://www.vpro.nl/cinema/magazines/rss ... newstype=1">http://www.vpro.nl/cinema/magazines/rss/index.jsp?newstype=1"

))





;; refresh timer  - 5 seconds

(set 'refresh 5000)



;; text to display

(set 'feedtext "")



(until (net-error)

(dolist (u uri)



        (set 'url u )



        ;;

        ;; DE-XML

        ;;

        (xml-type-tags nil 'cdata '!-- nil)

        (set 'url (xml-parse (get-url url) (+ 1 2 8 16) ))



        ;;

        ;; strippp <!-- comments from top...

        ;;

        (until (= (first (nth 0 url)) 'rss ) (pop url))



        (set 'rsschannel (nth 2 (nth 0 url)))

        (set 'rsschannellen (length rsschannel))



        ;;

        ;; Seeking for ITEMS in CHANNEL

        ;;

        (dotimes (y rsschannellen)

         (if (list? (nth y rsschannel))

          (if (= (nth 0 (nth y rsschannel)) 'item )



                (begin

                (sleep refresh)

                        ;; terminal control codes

                        (! "tput sgr0")

                        (! "tput sc 2")

                        (! "tput cup 0 0")

                        (! "tput setaf 7")

                        (! "tput setab 1")

                        (! "tput el")

                        (println "** RSS ** " (lookup 'title rsschannel) " ** " (lookup 'title (nth y rsschannel)) )

                        (! "tput rc") ))))))
-- (define? (Cornflakes))