/[mplayer-eee-tv]/program/mojtv.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /program/mojtv.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12 by dpavlin, Wed Oct 28 23:11:25 2009 UTC revision 14 by dpavlin, Thu Oct 29 11:55:37 2009 UTC
# Line 9  use Data::Dump qw(dump); Line 9  use Data::Dump qw(dump);
9    
10  my $now = DateTime->now;  my $now = DateTime->now;
11    
12    my $record = qr/(e-Hrvatska|serija|dnevnik|vrijeme|telenovela|Simpsoni|Panther|Prijatelji|kulture|otvoreno|dossier.hr)/i;
13    
14  sub scrape {  sub scrape {
15          my $url = shift;          my $url = shift;
16          my $feed = XML::FeedPP->new( $url );          my $feed = XML::FeedPP->new( $url );
17          print "Title: ", $feed->title(), "\n";  #       print "Title: ", $feed->title(), "\n";
18          print "Date: ", $feed->pubDate(), "\n";  #       print "Date: ", $feed->pubDate(), "\n";
19          foreach my $item ( $feed->get_item() ) {          foreach my $item ( $feed->get_item() ) {
20                  my ( $channel, $date ) = split /\s*-\s*/, $item->title(), 2;                  my ( $channel, $date ) = split /\s*-\s*/, $item->title(), 2;
21                  my ( $dd, $mm, $yyyy ) = split /\./, $date, 3;                  my ( $dd, $mm, $yyyy ) = split /\./, $date, 3;
# Line 36  sub scrape { Line 38  sub scrape {
38                                          my $sec = $duration->hours * 60 * 60                                          my $sec = $duration->hours * 60 * 60
39                                                  + $duration->minutes * 60                                                  + $duration->minutes * 60
40                                                  + $duration->seconds;                                                  + $duration->seconds;
41  warn "# $t $dt = $sec\n";  #warn "# $t $dt = $sec\n";
42                                          printf "[ ] %4s %s %s %4d\t%s%s\n",                                          my $store = 1 if $description =~ $record && $t > $now;
43                                            printf "%s %4s %s %s %4d\t%s%s\n",
44                                                    $store ? 'echo' : '####',
45                                                  $channel,                                                  $channel,
46                                                  $dt->ymd('-'), $dt->hms(':'), $sec,                                                  $dt->ymd('-'), $dt->hms(':'), $sec,
47                                                  $description,                                                  $description,
48                                                  $link ? "\t<$link>" : '' if $t > $now;                                                  $link ? "\t<$link>" : ''
49                                            ;
50    
51    
52                                            if ( $store ) {
53                                                    my $hhmm = $dt->hms(':');
54                                                    $hhmm =~ s{:\d\d$}{};
55                                                    print "echo ./record-stream.sh 0 $channel $sec | at $hhmm\n";
56                                            }
57                                  };                                  };
58                                                    
59            
60                                  @last = ( $t, $line, $link );                                  @last = ( $t, $line, $link );
61                          }                          }
62                  }                  }

Legend:
Removed from v.12  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26