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; |
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 |
} |
} |