#!/usr/bin/perl use POSIX qw(setsid); use Getopt::Std; use XML::Twig; use LWP::UserAgent; use English; use File::Path; my $ipod_news_path = "/home/zyz/milk/public_html/news/"; # Path to where you want the news text dumped my $url = 'http://today.reuters.com/rss/topNews/'; # Reuter's RSS feed url. May change from time to time my $manual_sync = 0; # Set this to '1' if your ipod is not mounted with 'sync' - may not work on all systems my $wait_time = 600; # Time (in seconds) between news updates ################################################################## # DO NOT EDIT BELOW THIS LINE # ################################################################## my $twig = XML::Twig->new(); my $item_url, $item_html, $item_text, $item_title; my $ua = LWP::UserAgent->new; $ua->agent(""); $user = getpwuid($<); getopts("dh", \%opts); if($opts{h}){ help(); } if($opts{d}){ daemonize(); $daemon = 1; } while(1){ if(!(-e $ipod_news_path)){ sleep 5; next; } else{ $mounted = 1; } opendir(DIR, $ipod_news_path); while($file = readdir(DIR)){ if($file =~ /^\.+/){ next; } unlink $ipod_news_path . "/" . $file; } closedir DIR; print "Fetching RSS feed...\n\n"; $twig->parseurl($url) or die "$!"; my $root = $twig->root; $root = $root->first_child(); print "Today\'s Headlines:\n\n"; foreach $item ($root->children('item')){ $item_title = $item->first_child_text('title'); print "$item_title...\n"; $item_url = $item->first_child_text('link'); $item_html = $ua->get($item_url)->content; $item_html =~ /Article Text Begins -->/; $item_text = $POSTMATCH; $item_text =~ /